save
This commit is contained in:
@@ -27,7 +27,7 @@ const settingStore = useSettingStore()
|
||||
|
||||
<template>
|
||||
<div class="options">
|
||||
<Tooltip v-if="showEdit" :title="`编辑(快捷键:${settingStore.shortcutKeyMap[ShortcutKey.Edit]})`">
|
||||
<Tooltip v-if="showEdit" :title="`编辑(快捷键:${settingStore.shortcutKeyMap[ShortcutKey.EditArticle]})`">
|
||||
<IconWrapper>
|
||||
<Icon icon="tabler:edit" class="menu"
|
||||
@click="emit('edit')"/>
|
||||
|
||||
@@ -185,7 +185,7 @@ function play() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
emitter.on(ShortcutKey.Show, show)
|
||||
emitter.on(ShortcutKey.ShowWord, show)
|
||||
emitter.on(ShortcutKey.Skip, skip)
|
||||
emitter.on(ShortcutKey.ToggleCollect, collect)
|
||||
emitter.on(ShortcutKey.ToggleSimple, toggleWordSimpleWrapper)
|
||||
@@ -193,7 +193,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
emitter.off(ShortcutKey.Show, show)
|
||||
emitter.off(ShortcutKey.ShowWord, show)
|
||||
emitter.off(ShortcutKey.Skip, skip)
|
||||
emitter.off(ShortcutKey.ToggleCollect, collect)
|
||||
emitter.off(ShortcutKey.ToggleSimple, toggleWordSimpleWrapper)
|
||||
|
||||
@@ -25,7 +25,7 @@ useWatchAllSound()
|
||||
|
||||
let editShortcutKey = $ref('')
|
||||
|
||||
const disabledDefaultKeyboardEvent = $computed(()=>{
|
||||
const disabledDefaultKeyboardEvent = $computed(() => {
|
||||
return editShortcutKey && tabIndex === 2
|
||||
})
|
||||
|
||||
@@ -53,6 +53,11 @@ useEventListener('keydown', (e: KeyboardEvent) => {
|
||||
}
|
||||
})
|
||||
|
||||
function resetShortcutKeyMap() {
|
||||
settingStore.shortcutKeyMap = cloneDeep(DefaultShortcutKeyMap)
|
||||
ElMessage.success('恢复成功')
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -288,7 +293,7 @@ useEventListener('keydown', (e: KeyboardEvent) => {
|
||||
<div class="row">
|
||||
<label class="item-title"></label>
|
||||
<div class="wrapper">
|
||||
<BaseButton @click="settingStore.shortcutKeyMap = cloneDeep(DefaultShortcutKeyMap)">恢复默认</BaseButton>
|
||||
<BaseButton @click="resetShortcutKeyMap">恢复默认</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -98,11 +98,16 @@ export const useSettingStore = defineStore('setting', {
|
||||
setDefaultConfig()
|
||||
} else {
|
||||
if (obj.version !== SaveConfig.version) {
|
||||
debugger
|
||||
for (const [key, value] of Object.entries(this.shortcutKeyMap)) {
|
||||
if (obj.val.shortcutKeyMap[key]) this.shortcutKeyMap[key] = obj.val.shortcutKeyMap[key]
|
||||
}
|
||||
delete obj.val.shortcutKeyMap
|
||||
|
||||
for (const [key, value] of Object.entries(this.fontSize)) {
|
||||
if (obj.val.fontSize[key]) this.fontSize[key] = obj.val.fontSize[key]
|
||||
}
|
||||
delete obj.val.fontSize
|
||||
|
||||
this.setState(obj.val)
|
||||
} else {
|
||||
this.setState(obj.val)
|
||||
|
||||
25
src/types.ts
25
src/types.ts
@@ -18,14 +18,6 @@ export const DefaultWord: Word = {
|
||||
trans: []
|
||||
}
|
||||
|
||||
export const SaveDict = {
|
||||
key: 'typing-word-dict',
|
||||
version: 1
|
||||
}
|
||||
export const SaveConfig = {
|
||||
key: 'typing-word-config',
|
||||
version: 6
|
||||
}
|
||||
|
||||
export const PronunciationApi = 'https://dict.youdao.com/dictvoice?audio='
|
||||
|
||||
@@ -171,9 +163,18 @@ export const ShortcutKeyMap = {
|
||||
Collect: 'Enter',
|
||||
}
|
||||
|
||||
export const SaveDict = {
|
||||
key: 'typing-word-dict',
|
||||
version: 1
|
||||
}
|
||||
export const SaveConfig = {
|
||||
key: 'typing-word-config',
|
||||
version: 5
|
||||
}
|
||||
|
||||
export enum ShortcutKey {
|
||||
Show = 'Show',
|
||||
Edit = 'Edit',
|
||||
ShowWord = 'ShowWord',
|
||||
EditArticle = 'EditArticle',
|
||||
Skip = 'Skip',
|
||||
ToggleSimple = 'ToggleSimple',
|
||||
ToggleCollect = 'ToggleCollect',
|
||||
@@ -190,8 +191,8 @@ export enum ShortcutKey {
|
||||
}
|
||||
|
||||
export const DefaultShortcutKeyMap = {
|
||||
[ShortcutKey.Edit]: 'Ctrl+E',
|
||||
[ShortcutKey.Show]: 'Escape',
|
||||
[ShortcutKey.EditArticle]: 'Ctrl+E',
|
||||
[ShortcutKey.ShowWord]: 'Escape',
|
||||
[ShortcutKey.Skip]: 'Tab',
|
||||
[ShortcutKey.ToggleSimple]: '`',
|
||||
[ShortcutKey.ToggleCollect]: 'Enter',
|
||||
|
||||
Reference in New Issue
Block a user