♻️ 修改系统设置存储方式

This commit is contained in:
muwoo
2023-08-22 17:41:51 +08:00
parent d2d94c13b7
commit f4f91e1639
24 changed files with 202 additions and 110 deletions

View File

@@ -57,10 +57,10 @@ import { ipcRenderer } from 'electron';
import { LoadingOutlined, MoreOutlined } from '@ant-design/icons-vue';
const remote = window.require('@electron/remote');
const opConfig = remote.getGlobal('OP_CONFIG');
import localConfig from '../confOp';
const { Menu } = remote;
const config = ref(opConfig.get());
const config: any = ref(localConfig.getConfig());
const props: any = defineProps({
searchValue: {
@@ -120,7 +120,7 @@ const keydownEvent = (e, key: string) => {
emit('choosePlugin');
break;
case 'space':
if (runPluginDisable || !opConfig.get().perf.common.space) return;
if (runPluginDisable || !config.value.perf.common.space) return;
emit('choosePlugin');
break;
default:
@@ -217,14 +217,14 @@ const showSeparate = () => {
const changeLang = (lang) => {
let cfg = { ...config.value };
cfg.perf.common.lang = lang;
opConfig.set(cfg);
localConfig.setConfig(JSON.parse(JSON.stringify(cfg)));
config.value = cfg;
};
const changeHideOnBlur = () => {
let cfg = { ...config.value };
cfg.perf.common.hideOnBlur = !cfg.perf.common.hideOnBlur;
opConfig.set(cfg);
localConfig.setConfig(JSON.parse(JSON.stringify(cfg)));
config.value = cfg;
};

22
src/renderer/confOp.ts Normal file
View File

@@ -0,0 +1,22 @@
const LOCAL_CONFIG_KEY = 'rubick-local-config';
const localConfig = {
getConfig(): Promise<any> {
const data: any = window.rubick.db.get(LOCAL_CONFIG_KEY) || {};
return data.data;
},
setConfig(data) {
const localConfig: any = window.rubick.db.get(LOCAL_CONFIG_KEY) || {};
window.rubick.db.put({
_id: LOCAL_CONFIG_KEY,
_rev: localConfig._rev,
data: {
...localConfig.data,
...data,
},
});
},
};
export default localConfig;

View File

@@ -9,15 +9,14 @@ import {
ConfigProvider,
} from 'ant-design-vue';
import App from './App.vue';
import localConfig from './confOp';
import 'ant-design-vue/dist/antd.variable.min.css';
const { getGlobal } = window.require('@electron/remote');
const { perf } = getGlobal('OP_CONFIG').get();
const config: any = localConfig.getConfig();
ConfigProvider.config({
theme: perf.custom || {},
theme: config.perf.custom || {},
});
createApp(App)

View File

@@ -3,12 +3,13 @@ import { clipboard, nativeImage, ipcRenderer } from 'electron';
import { getGlobal } from '@electron/remote';
import path from 'path';
import pluginClickEvent from './pluginClickEvent';
import localConfig from '../confOp';
import { ref } from 'vue';
export default ({ currentPlugin, optionsRef, openPlugin, setOptionsRef }) => {
const clipboardFile: any = ref([]);
const searchFocus = () => {
const config = getGlobal('OP_CONFIG').get();
const config: any = localConfig.getConfig();
// 未开启自动粘贴
if (!config.perf.common.autoPast) return;