From 75635ec22c7551af8533008ef9e6190f7771e7fc Mon Sep 17 00:00:00 2001 From: zyronon Date: Wed, 13 Sep 2023 14:01:28 +0800 Subject: [PATCH] feat(settingmodal): perfect setting --- components.d.ts | 1 + src/components/BaseButton.vue | 14 +++- src/components/Practice/TypeArticle.vue | 23 ++++-- src/components/Practice/TypeWord.vue | 28 +++++-- src/components/Toolbar/SettingModal.vue | 87 +++++++++++++++------ src/components/Toolbar/TrabslateSetting.vue | 17 ++-- src/components/Toolbar/VolumeSetting.vue | 16 +++- src/stores/base.ts | 18 ++++- src/types.ts | 17 +++- 9 files changed, 169 insertions(+), 52 deletions(-) diff --git a/components.d.ts b/components.d.ts index c2373e9f..7a7b6962 100644 --- a/components.d.ts +++ b/components.d.ts @@ -13,6 +13,7 @@ declare module 'vue' { ChapterList: typeof import('./src/components/ChapterList.vue')['default'] DictList: typeof import('./src/components/DictList.vue')['default'] DictModal: typeof import('./src/components/Toolbar/DictModal.vue')['default'] + ElInput: typeof import('element-plus/es')['ElInput'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElOption: typeof import('element-plus/es')['ElOption'] ElProgress: typeof import('element-plus/es')['ElProgress'] diff --git a/src/components/BaseButton.vue b/src/components/BaseButton.vue index c33a9a1b..91f0274c 100644 --- a/src/components/BaseButton.vue +++ b/src/components/BaseButton.vue @@ -5,6 +5,7 @@ import {Icon} from "@iconify/vue"; defineProps<{ keyboard?: string, active?: boolean + size?: string }>() defineEmits(['click']) @@ -15,7 +16,10 @@ defineEmits(['click'])
+ :class="[ + active && 'active', + size, + ]">
@@ -43,6 +47,14 @@ defineEmits(['click']) height: 40rem; line-height: 1; + &.small { + height: 30rem; + + & > span { + font-size: 13rem; + } + } + & > span { font-size: 16rem; color: white; diff --git a/src/components/Practice/TypeArticle.vue b/src/components/Practice/TypeArticle.vue index 16ba09f2..d891f140 100644 --- a/src/components/Practice/TypeArticle.vue +++ b/src/components/Practice/TypeArticle.vue @@ -240,7 +240,14 @@ function onKeyDown(e: KeyboardEvent) { let key = currentWord.name[stringIndex] console.log('key', key,) - if (key === letter) { + + let isWrong = false + if (store.setting.ignoreCase) { + isWrong = key.toLowerCase() === letter.toLowerCase() + } else { + isWrong = key === letter + } + if (isWrong) { input += letter wrong = '' // console.log('匹配上了') @@ -299,9 +306,11 @@ function onKeyDown(e: KeyboardEvent) { break case ShortKeyMap.Show: - hoverIndex = { - sectionIndex: sectionIndex, - sentenceIndex: sentenceIndex, + if (store.setting.allowWordTip) { + hoverIndex = { + sectionIndex: sectionIndex, + sentenceIndex: sentenceIndex, + } } break } @@ -396,7 +405,7 @@ function otherWord(word: ArticleWord, i: number, i2: number, i3: number) { sectionIndex === indexI && sentenceIndex === indexJ && store.setting.dictation ?'dictation':'' ]" - @mouseenter="hoverIndex = {sectionIndex : indexI,sentenceIndex :indexJ}" + @mouseenter="store.setting.allowWordTip && (hoverIndex = {sectionIndex : indexI,sentenceIndex :indexJ})" @mouseleave="hoverIndex = {sectionIndex : -1,sentenceIndex :-1}" @click="playAudio(sentence.sentence)" v-for="(sentence,indexJ) in section"> @@ -494,13 +503,13 @@ function otherWord(word: ArticleWord, i: number, i2: number, i3: number) { font-size: 36rem; font-weight: 500; word-spacing: 3rem; - //opacity: 0; + opacity: 0; } } .article-content { position: relative; - //opacity: 0; + opacity: 0; } article { diff --git a/src/components/Practice/TypeWord.vue b/src/components/Practice/TypeWord.vue index 3cb85e92..9df95d7d 100644 --- a/src/components/Practice/TypeWord.vue +++ b/src/components/Practice/TypeWord.vue @@ -129,7 +129,13 @@ async function onKeyDown(e: KeyboardEvent) { //TODO 还有横杠 if ((e.keyCode >= 65 && e.keyCode <= 90) || e.code === 'Space') { let letter = e.key - if ((input + letter).toLowerCase() === word.name.toLowerCase().slice(0, input.length + 1)) { + let isWrong = false + if (store.setting.ignoreCase) { + isWrong = (input + letter).toLowerCase() === word.name.toLowerCase().slice(0, input.length + 1) + } else { + isWrong = (input + letter) === word.name.slice(0, input.length + 1) + } + if (isWrong) { input += letter wrong = '' playKeySound() @@ -152,7 +158,7 @@ async function onKeyDown(e: KeyboardEvent) { } if (input.toLowerCase() === word.name.toLowerCase()) { playCorrect() - setTimeout(next, 300) + setTimeout(next, store.setting.waitTimeForChangeWord) } } else { // console.log('e', e) @@ -187,7 +193,9 @@ async function onKeyDown(e: KeyboardEvent) { next() break case ShortKeyMap.Show: - showFullWord = true + if (store.setting.allowWordTip) { + showFullWord = true + } break } setTimeout(() => { @@ -199,14 +207,22 @@ async function onKeyDown(e: KeyboardEvent) {