-
+
{{ item }}
- +
+ +
唤醒窗口
diff --git a/src/stores/settings.ts b/src/stores/settings.ts
index 84de320..27d3f1e 100644
--- a/src/stores/settings.ts
+++ b/src/stores/settings.ts
@@ -23,7 +23,7 @@ export const useSettingsStore = defineStore(
const apiKey = ref('')
// 全局快捷键
- const shortcutKey = ref
([])
+ const shortcutKeys = ref([])
const isBinding = ref(false)
// 开机自启动
@@ -39,7 +39,7 @@ export const useSettingsStore = defineStore(
const registerKey = async () => {
await unregisterAll()
- register(shortcutKey.value.join('+'), () => {
+ register(shortcutKeys.value.join('+'), () => {
appWindow.setFocus()
})
}
@@ -56,18 +56,19 @@ export const useSettingsStore = defineStore(
uuid.value = crypto.randomUUID()
})
- // 监听快捷键更换
+ // 监听快捷键
watchEffect(() => {
- if (isBinding.value || shortcutKey.value.length) return
+ if (isBinding.value) {
+ shortcutKeys.value = []
- shortcutKey.value = DEFAULT_SHORTCUT_KEY
- })
-
- // 注册全局快捷键
- watchEffect(() => {
- if (isBinding.value) return
+ unregisterAll()
+ } else {
+ if (!shortcutKeys.value.length) {
+ shortcutKeys.value = DEFAULT_SHORTCUT_KEY
+ }
- registerKey()
+ registerKey()
+ }
})
// 监听开机自启动
@@ -85,7 +86,7 @@ export const useSettingsStore = defineStore(
uuid,
isFix,
apiKey,
- shortcutKey,
+ shortcutKeys,
isBinding,
autoStart,
toggleTheme
@@ -93,7 +94,7 @@ export const useSettingsStore = defineStore(
},
{
persist: {
- paths: ['themeMode', 'uuid', 'apiKey', 'shortcutKey', 'autoStart']
+ paths: ['themeMode', 'uuid', 'apiKey', 'shortcutKeys', 'autoStart']
}
}
)
diff --git a/src/utils/keyMap.ts b/src/utils/keyMap.ts
index 398ee1a..a7ef619 100644
--- a/src/utils/keyMap.ts
+++ b/src/utils/keyMap.ts
@@ -1,52 +1,58 @@
-// 热键列表
+// 热键
export const hotkeys = [
{
- code: 'Shift'
+ key: 'Shift',
+ symbol: '⇧'
},
{
- code: 'Alt'
+ key: 'Alt',
+ symbol: '⌥'
},
{
- code: 'Control'
+ key: 'Control',
+ symbol: '⌃'
},
{
- code: 'Meta'
+ key: 'Command',
+ symbol: '⌘'
}
-].map(({ code }) => ({
- code,
- icon: `icon-${code.toLowerCase()}`
-}))
+]
-// 有图标的按键
-export const hasIconKeys = [
+// 特殊按键
+export const specialKeys = [
{
- code: 'Escape'
+ code: 'Escape',
+ symbol: '⎋'
},
{
- code: 'Tab'
+ code: 'Tab',
+ symbol: '⇥'
},
{
- code: 'Backspace'
+ code: 'Backspace',
+ symbol: '⌫'
},
{
- code: 'Enter'
+ code: 'Enter',
+ symbol: '↩︎'
},
{
- code: 'ArrowUp'
+ code: 'ArrowUp',
+ symbol: '⇡'
},
{
- code: 'ArrowRight'
+ code: 'ArrowRight',
+ symbol: '⇢'
},
{
- code: 'ArrowDown'
+ code: 'ArrowDown',
+ symbol: '⇣'
},
{
- code: 'ArrowLeft'
+ code: 'ArrowLeft',
+ symbol: '⇠'
}
-].map(({ code }) => ({
- code,
- icon: `icon-${code.toLowerCase()}`
-}))
+]
// 普通按键
export const generalKeys = [
@@ -266,15 +272,15 @@ export const generalKeys = [
* @param key 按键 key 值
*/
export const isHotKey = (key: string) => {
- return !!hotkeys.find((item) => item.code === key)
+ return hotkeys.some((item) => item.key === key)
}
/**
- * 获取按键 icon
+ * 判断是否为特殊键
* @param key 按键 code 值
*/
-export const getKeyIcon = (code: string) => {
- return hasIconKeys.find((item) => item.code === code)?.icon
+export const isSpecialKey = (code: string) => {
+ return specialKeys.some((item) => item.code === code)
}
/**
@@ -282,5 +288,7 @@ export const getKeyIcon = (code: string) => {
* @param key 按键 code 值
*/
export const getKeySymbol = (code: string) => {
- return generalKeys.find((item) => item.code === code)?.symbol
+ const keys = [...specialKeys, ...generalKeys]
+
+ return keys.find((item) => item.code === code)?.symbol
}
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts
index ff604e9..316327d 100644
--- a/src/vite-env.d.ts
+++ b/src/vite-env.d.ts
@@ -5,7 +5,6 @@ interface ImportMetaEnv {
readonly VITE_APP_NAME: string
readonly VITE_OPEN_AI_URL: string
readonly VITE_OPEN_AI_API_KEY: string
- readonly VITE_ICON_FONT_URL: string
}
// eslint-disable-next-line no-unused-vars