diff --git a/feature/src/assets/request/index.ts b/feature/src/assets/request/index.ts index e003247..fa61b9e 100644 --- a/feature/src/assets/request/index.ts +++ b/feature/src/assets/request/index.ts @@ -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; }, }; diff --git a/feature/src/views/settings/index.vue b/feature/src/views/settings/index.vue index 46bfd3b..201a59c 100644 --- a/feature/src/views/settings/index.vue +++ b/feature/src/views/settings/index.vue @@ -14,6 +14,12 @@ 全局快捷键 + + + 内网部署配置 +
@@ -32,26 +38,6 @@ {{ shortCut.showAndHidden }}
- - - - - - - - - - - - - - - - - - - -
通用
@@ -80,17 +66,6 @@ >
- - - - - - - - - - -
@@ -147,15 +122,17 @@
+ 新增全局快捷功能
+ diff --git a/package.json b/package.json index 057a849..3e469cd 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/common/utils/localPlugin.ts b/src/common/utils/localPlugin.ts index 87d42f2..06635bf 100644 --- a/src/common/utils/localPlugin.ts +++ b/src/common/utils/localPlugin.ts @@ -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({ - baseDir, -}); +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: [], diff --git a/src/core/plugin-handler/index.ts b/src/core/plugin-handler/index.ts index b83e351..c0db313 100644 --- a/src/core/plugin-handler/index.ts +++ b/src/core/plugin-handler/index.ts @@ -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"; } /** diff --git a/src/main/common/api.ts b/src/main/common/api.ts index f5796b1..186ebaf 100644 --- a/src/main/common/api.ts +++ b/src/main/common/api.ts @@ -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) => {