mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-22 20:32:42 +08:00
✨ 支持内网部署配置能力
This commit is contained in:
parent
58aabb9f1e
commit
371565744e
@ -1,30 +1,53 @@
|
||||
import axios from "axios";
|
||||
|
||||
let baseURL = "https://gitee.com/monkeyWang/rubick-database/raw/master";
|
||||
let access_token = "";
|
||||
|
||||
try {
|
||||
const dbdata = window.rubick.db.get("rubick-localhost-config");
|
||||
baseURL = dbdata.data.database;
|
||||
access_token = dbdata.data.access_token;
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
const instance = axios.create({
|
||||
baseURL: baseURL || "https://gitee.com/monkeyWang/rubick-database/raw/master",
|
||||
});
|
||||
|
||||
export default {
|
||||
async getTotalPlugins() {
|
||||
const res = await axios.get(
|
||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/total-plugins.json"
|
||||
);
|
||||
let targetPath = "plugins/total-plugins.json";
|
||||
if (access_token) {
|
||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||
}
|
||||
const res = await instance.get(targetPath);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async getFinderDetail() {
|
||||
const res = await axios.get(
|
||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/finder.json"
|
||||
);
|
||||
let targetPath = "plugins/finder.json";
|
||||
if (access_token) {
|
||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||
}
|
||||
const res = await instance.get(targetPath);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async getSystemDetail() {
|
||||
const res = await axios.get(
|
||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/system.json"
|
||||
);
|
||||
let targetPath = "/plugins/system.json";
|
||||
if (access_token) {
|
||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||
}
|
||||
const res = await instance.get(targetPath);
|
||||
return res.data;
|
||||
},
|
||||
async getWorkerDetail() {
|
||||
const res = await axios.get(
|
||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/worker.json"
|
||||
);
|
||||
let targetPath = "/plugins/worker.json";
|
||||
if (access_token) {
|
||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||
}
|
||||
const res = await instance.get(targetPath);
|
||||
return res.data;
|
||||
},
|
||||
|
||||
@ -33,16 +56,20 @@ export default {
|
||||
return res.data;
|
||||
},
|
||||
|
||||
async getSearchDetail(url: string) {
|
||||
const res = await axios.get(
|
||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/search.json"
|
||||
);
|
||||
async getSearchDetail() {
|
||||
let targetPath = "/plugins/search.json";
|
||||
if (access_token) {
|
||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||
}
|
||||
const res = await instance.get(targetPath);
|
||||
return res.data;
|
||||
},
|
||||
async getDevDetail(url: string) {
|
||||
const res = await axios.get(
|
||||
"https://gitee.com/monkeyWang/rubick-database/raw/master/plugins/dev.json"
|
||||
);
|
||||
async getDevDetail() {
|
||||
let targetPath = "/plugins/dev.json";
|
||||
if (access_token) {
|
||||
targetPath = `${encodeURIComponent(targetPath)}/raw?access_token=${access_token}&ref=master`
|
||||
}
|
||||
const res = await instance.get(targetPath);
|
||||
return res.data;
|
||||
},
|
||||
};
|
||||
|
@ -14,6 +14,12 @@
|
||||
</template>
|
||||
全局快捷键
|
||||
</a-menu-item>
|
||||
<a-menu-item key="localhost">
|
||||
<template #icon>
|
||||
<DatabaseOutlined />
|
||||
</template>
|
||||
内网部署配置
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</div>
|
||||
<div class="settings-detail">
|
||||
@ -32,26 +38,6 @@
|
||||
{{ shortCut.showAndHidden }}
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="settings-item-li">-->
|
||||
<!-- <div class="label">插件分离快捷键</div>-->
|
||||
<!-- <div-->
|
||||
<!-- class="value"-->
|
||||
<!-- tabIndex="-1"-->
|
||||
<!-- @keyup="(e) => changeShortCut(e, 'separate')"-->
|
||||
<!-- >-->
|
||||
<!-- {{ shortCut.separate }}-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="settings-item-li">-->
|
||||
<!-- <div class="label">返回主界面</div>-->
|
||||
<!-- <div-->
|
||||
<!-- class="value"-->
|
||||
<!-- tabIndex="-1"-->
|
||||
<!-- @keyup="(e) => changeShortCut(e, 'quit')"-->
|
||||
<!-- >-->
|
||||
<!-- {{ shortCut.quit }}-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div class="title">通用</div>
|
||||
@ -80,17 +66,6 @@
|
||||
></a-switch>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="setting-item">-->
|
||||
<!-- <div class="title">本地搜索启动</div>-->
|
||||
<!-- <div class="settings-item-li">-->
|
||||
<!-- <div class="label">搜索启动应用&文件</div>-->
|
||||
<!-- <a-switch-->
|
||||
<!-- v-model:checked="local.search"-->
|
||||
<!-- checked-children="开"-->
|
||||
<!-- un-checked-children="关"-->
|
||||
<!-- ></a-switch>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
<div v-if="currentSelect[0] === 'global'">
|
||||
<a-collapse>
|
||||
@ -147,15 +122,17 @@
|
||||
</div>
|
||||
<div @click="addConfig" class="add-global">+ 新增全局快捷功能</div>
|
||||
</div>
|
||||
<Localhost v-if="currentSelect[0] === 'localhost'" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ToolOutlined, LaptopOutlined } from "@ant-design/icons-vue";
|
||||
import { ToolOutlined, LaptopOutlined, DatabaseOutlined } from "@ant-design/icons-vue";
|
||||
import debounce from "lodash.debounce";
|
||||
import { ref, reactive, watch, toRefs, toRaw } from "vue";
|
||||
import keycodes from "./keycode";
|
||||
import Localhost from "./localhost.vue";
|
||||
|
||||
const { remote, ipcRenderer } = window.require("electron");
|
||||
|
||||
|
90
feature/src/views/settings/localhost.vue
Normal file
90
feature/src/views/settings/localhost.vue
Normal file
@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<a-alert
|
||||
message="把插件发布到公网 npm 如果不符合您的公司安全要求,rubick 支持内网私有源和私有插件库,如果您需要内网部署使用,可以自行配置以下规则。"
|
||||
type="warning"
|
||||
style="margin-bottom: 20px"
|
||||
/>
|
||||
<a-form
|
||||
name="custom-validation"
|
||||
ref="formRef"
|
||||
:model="formState"
|
||||
:rules="rules"
|
||||
v-bind="layout"
|
||||
>
|
||||
<a-form-item has-feedback label="npm 源" name="register">
|
||||
<a-input
|
||||
placeholder="https://registry.npm.taobao.org"
|
||||
v-model:value="formState.register"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item has-feedback label="database url" name="database">
|
||||
<a-input
|
||||
placeholder="https://gitee.com/monkeyWang/rubick-database/raw/master"
|
||||
v-model:value="formState.database"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item has-feedback label="access_token" name="access_token">
|
||||
<a-input
|
||||
placeholder="内网gitlab仓库必填"
|
||||
v-model:value="formState.access_token"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item :wrapper-col="{ span: 18, offset: 6 }">
|
||||
<a-button @click="submit" type="primary">确定</a-button>
|
||||
<a-button style="margin-left: 10px" @click="resetForm">恢复默认</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, toRaw } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
|
||||
let _rev: any;
|
||||
|
||||
let defaultConfig = {
|
||||
register: "https://registry.npm.taobao.org",
|
||||
database: "https://gitee.com/monkeyWang/rubick-database/raw/master",
|
||||
access_token: "",
|
||||
};
|
||||
|
||||
try {
|
||||
const dbdata = window.rubick.db.get("rubick-localhost-config");
|
||||
defaultConfig = dbdata.data;
|
||||
_rev = dbdata._rev;
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
const formState = ref(JSON.parse(JSON.stringify(defaultConfig)));
|
||||
|
||||
const rules = {
|
||||
register: [{ required: true, trigger: "change" }],
|
||||
database: [{ required: true, trigger: "change" }],
|
||||
};
|
||||
const layout = {
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 18 },
|
||||
};
|
||||
|
||||
const resetForm = () => {
|
||||
formState.value = {
|
||||
register: "https://registry.npm.taobao.org",
|
||||
database: "https://gitee.com/monkeyWang/rubick-database/raw/master",
|
||||
access_token: "",
|
||||
};
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
const changeData: any = {
|
||||
_id: "rubick-localhost-config",
|
||||
data: toRaw(formState.value),
|
||||
};
|
||||
|
||||
if (_rev) {
|
||||
changeData._rev = _rev;
|
||||
}
|
||||
|
||||
window.rubick.db.put(changeData);
|
||||
message.success("设置成功!重启插件市场后生效!");
|
||||
};
|
||||
</script>
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rubick",
|
||||
"version": "2.0.1-beta.12",
|
||||
"version": "2.0.1-beta.13",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
|
@ -3,12 +3,27 @@ import fs from "fs";
|
||||
import getLocalDataFile from "./getLocalDataFile";
|
||||
import { PluginHandler } from "@/core";
|
||||
import { PLUGIN_INSTALL_DIR as baseDir } from "@/common/constans/main";
|
||||
import { API } from "@/main/common/api";
|
||||
|
||||
const configPath = path.join(getLocalDataFile(), "./rubick-local-plugin.json");
|
||||
|
||||
const pluginInstance = new PluginHandler({
|
||||
let registry;
|
||||
let pluginInstance;
|
||||
(async () => {
|
||||
try {
|
||||
registry = (await API.dbGet({ data: { id: "rubick-localhost-config" } })).data.register;
|
||||
console.log(registry);
|
||||
pluginInstance = new PluginHandler({
|
||||
baseDir,
|
||||
});
|
||||
registry,
|
||||
});
|
||||
} catch (e) {
|
||||
pluginInstance = new PluginHandler({
|
||||
baseDir,
|
||||
registry,
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
global.LOCAL_PLUGINS = {
|
||||
PLUGINS: [],
|
||||
|
@ -9,6 +9,7 @@ import got from "got";
|
||||
import fixPath from "fix-path";
|
||||
|
||||
import spawn from "cross-spawn";
|
||||
import { ipcRenderer } from "electron";
|
||||
|
||||
fixPath();
|
||||
|
||||
@ -37,7 +38,19 @@ class AdapterHandler {
|
||||
);
|
||||
}
|
||||
this.baseDir = options.baseDir;
|
||||
this.registry = options.registry || "https://registry.npm.taobao.org";
|
||||
|
||||
let register = options.registry || "https://registry.npm.taobao.org";
|
||||
|
||||
try {
|
||||
const dbdata = ipcRenderer.sendSync("msg-trigger", {
|
||||
type: "dbGet",
|
||||
data: { id: "rubick-localhost-config" },
|
||||
});
|
||||
register = dbdata.data.register;
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
this.registry = register || "https://registry.npm.taobao.org";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ const dbInstance = new LocalDb(app.getPath("userData"));
|
||||
|
||||
dbInstance.init();
|
||||
|
||||
const API: any = {
|
||||
export const API: any = {
|
||||
currentPlugin: null,
|
||||
DBKEY: "RUBICK_DB_DEFAULT",
|
||||
getCurrentWindow: (window, e) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user