🐛 #77, 修复偏好设置不生效问题

This commit is contained in:
muwoo
2021-12-28 14:20:18 +08:00
parent f94c52f490
commit 56faae0e35
15 changed files with 687 additions and 363 deletions

View File

@@ -0,0 +1,23 @@
import commonConst from "@/common/utils/commonConst";
export default {
version: 2,
perf: {
shortCut: {
showAndHidden: "Option+R",
separate: "Ctrl+D",
quit: "Shift+Escape",
},
common: {
start: true,
space: true,
// 是否失焦隐藏。默认在dev环境不隐藏在打包后隐藏。
hideOnBlur: commonConst.production(),
autoPast: false,
},
local: {
search: true,
},
},
global: [],
}

View File

@@ -2,31 +2,10 @@ import path from "path";
import fs from "fs";
import getLocalDataFile from "./getLocalDataFile";
import commonConst from "./commonConst";
import defaultConfigForAnyPlatform from "../constans/defaultConfig";
const configPath = path.join(getLocalDataFile(), "./rubick-config.json");
const defaultConfigForAnyPlatform = {
version: 2,
perf: {
shortCut: {
showAndHidden: "Option+R",
separate: "Ctrl+D",
quit: "Shift+Escape",
},
common: {
start: true,
space: true,
// 是否失焦隐藏。默认在dev环境不隐藏在打包后隐藏。
hideOnBlur: commonConst.production(),
autoPast: false,
},
local: {
search: true,
},
},
global: [],
};
global.OP_CONFIG = {
config: null,
get() {
@@ -54,8 +33,11 @@ global.OP_CONFIG = {
return global.config;
}
},
set(key, value) {
global.config[key] = value;
set(value) {
global.config = {
...global.config,
...value,
};
fs.writeFileSync(configPath, JSON.stringify(global.config));
},
};