mirror of
https://github.com/rubickCenter/rubick
synced 2026-03-09 15:30:26 +08:00
✨ 支持内网部署配置能力
This commit is contained in:
@@ -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: [],
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user