Add shortcuts and update translations

This commit is contained in:
zyronon
2023-11-08 18:45:52 +08:00
parent bccd939414
commit 30a4c49009
7 changed files with 68 additions and 15 deletions

View File

@@ -61,7 +61,7 @@ const settingStore = useSettingStore()
icon="ph:star-fill"/>
<Tooltip
:title="`跳过(快捷键:${settingStore.shortcutKeyMap[ShortcutKey.Skip]})`"
:title="`跳过(快捷键:${settingStore.shortcutKeyMap[ShortcutKey.Next]})`"
>
<IconWrapper>
<Icon icon="icon-park-outline:go-ahead" class="menu"

View File

@@ -77,6 +77,16 @@ function next() {
repeat()
}
function prev() {
// console.log('next')
if (store.currentDict.chapterIndex === 0) {
ElMessage.warning('已经在第一章了~')
} else {
store.currentDict.chapterIndex--
repeat()
}
}
function toggleShowTranslate() {
settingStore.translate = !settingStore.translate
}
@@ -93,7 +103,7 @@ function openDictDetail() {
runtimeStore.showDictModal = true
}
function toggleConciseMode(){
function toggleConciseMode() {
settingStore.showToolbar = !settingStore.showToolbar
settingStore.showPanel = !settingStore.showPanel
}
@@ -104,6 +114,7 @@ onMounted(() => {
emitter.on(EventKey.repeat, repeat)
emitter.on(ShortcutKey.NextChapter, next)
emitter.on(ShortcutKey.PreviousChapter, prev)
emitter.on(ShortcutKey.RepeatChapter, repeat)
emitter.on(ShortcutKey.DictationChapter, write)
emitter.on(ShortcutKey.ToggleShowTranslate, toggleShowTranslate)
@@ -121,6 +132,7 @@ onUnmounted(() => {
emitter.off(EventKey.repeat, repeat)
emitter.off(ShortcutKey.NextChapter, next)
emitter.off(ShortcutKey.PreviousChapter, prev)
emitter.off(ShortcutKey.RepeatChapter, repeat)
emitter.off(ShortcutKey.DictationChapter, write)
emitter.off(ShortcutKey.ToggleShowTranslate, toggleShowTranslate)

View File

@@ -145,10 +145,6 @@ function next(isTyping: boolean = true) {
}
}
function prev() {
data.index--
}
function onKeyUp(e: KeyboardEvent) {
typingRef.hideWord()
}
@@ -174,6 +170,11 @@ async function onKeyDown(e: KeyboardEvent) {
useOnKeyboardEventListener(onKeyDown, onKeyUp)
//TODO 略过忽略的单词上
function prev() {
data.index--
}
function skip(e: KeyboardEvent) {
next(false)
// e.preventDefault()
@@ -203,7 +204,8 @@ function play() {
onMounted(() => {
emitter.on(ShortcutKey.ShowWord, show)
emitter.on(ShortcutKey.Skip, skip)
emitter.on(ShortcutKey.Previous, prev)
emitter.on(ShortcutKey.Next, skip)
emitter.on(ShortcutKey.ToggleCollect, collect)
emitter.on(ShortcutKey.ToggleSimple, toggleWordSimpleWrapper)
emitter.on(ShortcutKey.PlayWordPronunciation, play)
@@ -211,7 +213,8 @@ onMounted(() => {
onUnmounted(() => {
emitter.off(ShortcutKey.ShowWord, show)
emitter.off(ShortcutKey.Skip, skip)
emitter.off(ShortcutKey.Previous, prev)
emitter.off(ShortcutKey.Next, skip)
emitter.off(ShortcutKey.ToggleCollect, collect)
emitter.off(ShortcutKey.ToggleSimple, toggleWordSimpleWrapper)
emitter.off(ShortcutKey.PlayWordPronunciation, play)
@@ -232,7 +235,7 @@ onUnmounted(() => {
@click="next(false)"
v-if="nextWord">
<Tooltip
:title="`下一个(快捷键:${settingStore.shortcutKeyMap[ShortcutKey.Skip]})`"
:title="`下一个(快捷键:${settingStore.shortcutKeyMap[ShortcutKey.Next]})`"
>
<div class="word" :class="settingStore.dictation && 'text-shadow'">{{ nextWord.name }}</div>
</Tooltip>