mirror of
https://github.com/rubickCenter/rubick
synced 2025-12-26 04:19:27 +08:00
♻️ 修改系统设置存储方式
This commit is contained in:
@@ -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
22
src/renderer/confOp.ts
Normal 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;
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user