From e52d3bbbc90cde923ba556e1a581eeaf9699df3e Mon Sep 17 00:00:00 2001
From: layyback <505187749@qq.com>
Date: Tue, 30 May 2023 19:07:13 +0800
Subject: [PATCH] :checkered_flag: fix #180
---
feature/src/views/settings/index.vue | 100 ++++++++++++++++++---------
package.json | 2 +-
2 files changed, 70 insertions(+), 32 deletions(-)
diff --git a/feature/src/views/settings/index.vue b/feature/src/views/settings/index.vue
index c295292..86f81b9 100644
--- a/feature/src/views/settings/index.vue
+++ b/feature/src/views/settings/index.vue
@@ -36,12 +36,31 @@
显示/隐藏快捷键
- {{ tipText }}
+ {{ tipText }}
+
+
+
+ Alt+Space
+
+
+ Ctrl+Space
+
+
changeShortCut(e, 'showAndHidden')"
+ @keyup="(e) => changeShortCut(e, 'showAndHidden')"
>
{{ shortCut.showAndHidden }}
@@ -51,12 +70,12 @@
截屏
- {{ tipText }}
+ {{ tipText }}
changeShortCut(e, 'capture')"
+ @keyup="(e) => changeShortCut(e, 'capture')"
>
{{ shortCut.capture }}
@@ -129,12 +148,12 @@
- {{ tipText }}或按 F1-F12 单键
+ {{ tipText }}或按 F1-F12 单键
changeGlobalKey(e, index)"
+ @keyup="(e) => changeGlobalKey(e, index)"
>
{{ item.key }}
changeGlobalValue(index, e.target.value)"
+ @change="(e) => changeGlobalValue(index, e.target.value)"
/>
@@ -176,41 +195,42 @@ import {
MinusCircleOutlined,
PlusCircleOutlined,
FileAddOutlined,
-} from "@ant-design/icons-vue";
-import debounce from "lodash.debounce";
-import { ref, reactive, watch, toRefs, computed, toRaw } from "vue";
-import keycodes from "./keycode";
-import Localhost from "./localhost.vue";
-import SuperPanel from "./super-panel.vue";
+} from '@ant-design/icons-vue';
+import debounce from 'lodash.debounce';
+import { ref, reactive, watch, toRefs, computed, toRaw } from 'vue';
+import keycodes from './keycode';
+import Localhost from './localhost.vue';
+import SuperPanel from './super-panel.vue';
-const { remote, ipcRenderer } = window.require("electron");
+const { remote, ipcRenderer } = window.require('electron');
const examples = [
{
- title: "快捷键 「 Alt + W」 关键字 「 微信」",
- desc: "按下Alt + W 直接打开本地微信应用"
+ title: '快捷键 「 Alt + W」 关键字 「 微信」',
+ desc: '按下Alt + W 直接打开本地微信应用',
},
{
- title: "快捷键 「 Alt + Q」 关键字 「 取色」",
- desc: "按下Alt + Q 直接打开屏幕取色功能"
- }
+ title: '快捷键 「 Alt + Q」 关键字 「 取色」',
+ desc: '按下Alt + Q 直接打开屏幕取色功能',
+ },
];
const state = reactive({
shortCut: {},
common: {},
local: {},
- global: []
+ global: [],
});
+const isWindows = window?.rubick?.isWindows();
const tipText = computed(() => {
- const optionKeyName = window.rubick.isMacOs() ? "Option、Command" : "Alt";
+ const optionKeyName = isWindows ? 'Alt' : 'Option、Command';
return `先按功能键(Ctrl、Shift、${optionKeyName}),再按其他普通键。`;
});
-const currentSelect = ref(["normal"]);
+const currentSelect = ref(['normal']);
-const { perf, global: defaultGlobal } = remote.getGlobal("OP_CONFIG").get();
+const { perf, global: defaultGlobal } = remote.getGlobal('OP_CONFIG').get();
state.shortCut = perf.shortCut;
state.common = perf.common;
@@ -218,19 +238,19 @@ state.local = perf.local;
state.global = defaultGlobal;
const setConfig = debounce(() => {
- remote.getGlobal("OP_CONFIG").set(
+ remote.getGlobal('OP_CONFIG').set(
JSON.parse(
JSON.stringify({
perf: {
shortCut: state.shortCut,
common: state.common,
- local: state.local
+ local: state.local,
},
- global: state.global
+ global: state.global,
})
)
);
- ipcRenderer.send("re-register");
+ ipcRenderer.send('re-register');
}, 500);
watch(state, setConfig);
@@ -280,6 +300,22 @@ const changeGlobalKey = (e, index) => {
}
};
+const resetDefault = (key) => {
+ switch (key) {
+ case 'Alt':
+ state.shortCut['showAndHidden'] = 'Option+SPACE';
+ // copyValue.value = "Option+SPACE";
+ break;
+ case 'Ctrl':
+ state.shortCut['showAndHidden'] = 'Ctrl+SPACE';
+ // copyValue.value = "Ctrl+SPACE";
+ break;
+ default:
+ break;
+ }
+ setConfig();
+};
+
const changeGlobalValue = (index, value) => {
state.global[index].value = value;
};
@@ -291,8 +327,8 @@ const deleteGlobalKey = (e, index) => {
const addConfig = () => {
state.global.push({
- key: "",
- value: ""
+ key: '',
+ value: '',
});
};
@@ -300,13 +336,13 @@ const { shortCut, common, local, global } = toRefs(state);