🐛 修复系统插件无法打开ui界面问题

This commit is contained in:
muwoo 2022-01-17 16:00:23 +08:00
parent 8107d74537
commit 240175c571
3 changed files with 13 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "rubick", "name": "rubick",
"version": "2.0.1-beta.16", "version": "2.0.1-beta.17",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",

View File

@ -1,7 +1,6 @@
import path from "path"; import path from "path";
import fs from "fs"; import fs from "fs";
import getLocalDataFile from "./getLocalDataFile"; import getLocalDataFile from "./getLocalDataFile";
import commonConst from "./commonConst";
import defaultConfigForAnyPlatform from "../constans/defaultConfig"; import defaultConfigForAnyPlatform from "../constans/defaultConfig";
const configPath = path.join(getLocalDataFile(), "./rubick-config.json"); const configPath = path.join(getLocalDataFile(), "./rubick-config.json");
@ -10,34 +9,34 @@ global.OP_CONFIG = {
config: null, config: null,
get() { get() {
try { try {
if (!global.config) { if (!global.OP_CONFIG.config) {
global.config = JSON.parse( global.OP_CONFIG.config = JSON.parse(
fs.readFileSync(configPath, "utf8") || fs.readFileSync(configPath, "utf8") ||
JSON.stringify(defaultConfigForAnyPlatform) JSON.stringify(defaultConfigForAnyPlatform)
); );
} }
// 重置 // 重置
if ( if (
!global.config.version || !global.OP_CONFIG.config.version ||
global.config.version < defaultConfigForAnyPlatform.version global.OP_CONFIG.config.version < defaultConfigForAnyPlatform.version
) { ) {
global.config = defaultConfigForAnyPlatform; global.OP_CONFIG.config = defaultConfigForAnyPlatform;
fs.writeFileSync( fs.writeFileSync(
configPath, configPath,
JSON.stringify(defaultConfigForAnyPlatform) JSON.stringify(defaultConfigForAnyPlatform)
); );
} }
return global.config; return global.OP_CONFIG.config;
} catch (e) { } catch (e) {
global.config = defaultConfigForAnyPlatform; global.OP_CONFIG.config = defaultConfigForAnyPlatform;
return global.config; return global.OP_CONFIG.config;
} }
}, },
set(value) { set(value) {
global.config = { global.OP_CONFIG.config = {
...global.config, ...global.OP_CONFIG.config,
...value, ...value,
}; };
fs.writeFileSync(configPath, JSON.stringify(global.config)); fs.writeFileSync(configPath, JSON.stringify(global.OP_CONFIG.config));
}, },
}; };

View File

@ -28,7 +28,7 @@ const createPluginManager = (): any => {
}; };
const openPlugin = (plugin) => { const openPlugin = (plugin) => {
if (plugin.pluginType === "ui") { if (plugin.pluginType === "ui" || plugin.pluginType === "system") {
if (state.currentPlugin && state.currentPlugin.name === plugin.name) { if (state.currentPlugin && state.currentPlugin.name === plugin.name) {
return; return;
} }