save
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
[
|
||||
{
|
||||
"title": "A private conversation!",
|
||||
"titleTranslate": "私人谈话!",
|
||||
"text": "Last week I went to the theatre. I had a very good seat. The play was very interesting. I did not enjoy it. A young man and a young woman were sitting behind me. They were talking loudly. I got very angry. I could not hear the actors. I turned round. I looked at the man and the woman angrily. They did not pay any attention. In the end, I could not bear it. I turned round again. 'I can't hear a word!' I said angrily.\n 'It's none of your business,' the young man said rudely. 'This is a private conversation!'",
|
||||
"textCustomTranslate": "上星期我去看戏。我的座位很好,戏很有意思,但我却无法欣赏。一青年男子与一青年女子坐在我的身后,大声地说着话。我非常生气,因为我听不见演员在说什么。我回过头去怒视着那一男一女,他们却毫不理会。最后,我忍不住了,又一次回过头去,生气地说:“我一个字也听不见了!”\n “不关你的事,”那男的毫不客气地说,“这是私人间的谈话!”",
|
||||
"textNetworkTranslate": "",
|
||||
"newWords": [],
|
||||
"textCustomTranslateIsFormat": false,
|
||||
"useTranslateType": "custom"
|
||||
},
|
||||
|
||||
{
|
||||
"title": "Breakfast or lunch?",
|
||||
"titleTranslate": "早餐还是午餐?",
|
||||
@@ -19,6 +10,16 @@
|
||||
"useTranslateType": "custom",
|
||||
"newWords": []
|
||||
},
|
||||
{
|
||||
"title": "A private conversation!",
|
||||
"titleTranslate": "私人谈话!",
|
||||
"text": "Last week I went to the theatre. I had a very good seat. The play was very interesting. I did not enjoy it. A young man and a young woman were sitting behind me. They were talking loudly. I got very angry. I could not hear the actors. I turned round. I looked at the man and the woman angrily. They did not pay any attention. In the end, I could not bear it. I turned round again. 'I can't hear a word!' I said angrily.\n 'It's none of your business,' the young man said rudely. 'This is a private conversation!'",
|
||||
"textCustomTranslate": "上星期我去看戏。我的座位很好,戏很有意思,但我却无法欣赏。一青年男子与一青年女子坐在我的身后,大声地说着话。我非常生气,因为我听不见演员在说什么。我回过头去怒视着那一男一女,他们却毫不理会。最后,我忍不住了,又一次回过头去,生气地说:“我一个字也听不见了!”\n “不关你的事,”那男的毫不客气地说,“这是私人间的谈话!”",
|
||||
"textNetworkTranslate": "",
|
||||
"newWords": [],
|
||||
"textCustomTranslateIsFormat": false,
|
||||
"useTranslateType": "custom"
|
||||
},
|
||||
{
|
||||
"title": "Please send me a card",
|
||||
"titleTranslate": "请给我寄一张明信片",
|
||||
|
||||
@@ -42,6 +42,9 @@ let maskRef = $ref<HTMLDivElement>(null)
|
||||
let modalRef = $ref<HTMLDivElement>(null)
|
||||
|
||||
function close() {
|
||||
if (!visible) {
|
||||
return
|
||||
}
|
||||
//记录停留时间,避免时间太短,弹框闪烁
|
||||
let stayTime = Date.now() - openTime;
|
||||
let closeTime = 300;
|
||||
|
||||
@@ -18,8 +18,8 @@ function format(val: number, suffix: string = '', check: number = -1) {
|
||||
|
||||
const progress = $computed(() => {
|
||||
if (!practiceStore.total) return 0
|
||||
if (practiceStore.inputNumber > practiceStore.total) return 100
|
||||
return ((practiceStore.inputNumber / practiceStore.total) * 100)
|
||||
if (practiceStore.inputWordNumber > practiceStore.total) return 100
|
||||
return ((practiceStore.inputWordNumber / practiceStore.total) * 100)
|
||||
})
|
||||
|
||||
let speedMinute = $ref(0)
|
||||
@@ -54,12 +54,12 @@ onUnmounted(() => {
|
||||
<div class="name">单词总数</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="num">{{ format(practiceStore.inputNumber, '', 0) }}</div>
|
||||
<div class="num">{{ format(practiceStore.inputWordNumber, '', 0) }}</div>
|
||||
<div class="line"></div>
|
||||
<div class="name">输入数</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="num">{{ format(practiceStore.wrongNumber, '', 0) }}</div>
|
||||
<div class="num">{{ format(practiceStore.wrongWordNumber, '', 0) }}</div>
|
||||
<div class="line"></div>
|
||||
<div class="name">错误数</div>
|
||||
</div>
|
||||
|
||||
@@ -29,13 +29,13 @@ let showEditArticle = $ref(false)
|
||||
let editArticle = $ref<Article>(cloneDeep(DefaultArticle))
|
||||
|
||||
watch(practiceStore, () => {
|
||||
if (practiceStore.inputNumber < 1) {
|
||||
if (practiceStore.inputWordNumber < 1) {
|
||||
return practiceStore.correctRate = -1
|
||||
}
|
||||
if (practiceStore.wrongNumber > practiceStore.inputNumber) {
|
||||
if (practiceStore.wrongWordNumber > practiceStore.inputWordNumber) {
|
||||
return practiceStore.correctRate = 0
|
||||
}
|
||||
practiceStore.correctRate = 100 - Math.trunc(((practiceStore.wrongNumber) / (practiceStore.inputNumber)) * 100)
|
||||
practiceStore.correctRate = 100 - Math.trunc(((practiceStore.wrongWordNumber) / (practiceStore.inputWordNumber)) * 100)
|
||||
})
|
||||
|
||||
let wordData = $ref({
|
||||
@@ -58,10 +58,11 @@ watch(() => store.load, n => {
|
||||
})
|
||||
|
||||
function getCurrentPractice() {
|
||||
console.log('store.currentDict',store.currentDict)
|
||||
// console.log('store.currentDict',store.currentDict)
|
||||
if (store.isArticle) {
|
||||
// return
|
||||
let tempArticle = {...DefaultArticle, ...store.currentDict.articles[store.currentDict.chapterIndex]}
|
||||
let currentArticle = store.currentDict.articles[store.currentDict.chapterIndex]
|
||||
let tempArticle = {...DefaultArticle, ...currentArticle}
|
||||
console.log('article', tempArticle)
|
||||
if (tempArticle.sections.length) {
|
||||
articleData.article = tempArticle
|
||||
@@ -87,7 +88,7 @@ function getCurrentPractice() {
|
||||
() => {
|
||||
updateSections(tempArticle)
|
||||
tempArticle.useTranslateType = TranslateType.none
|
||||
articleData.article = tempArticle
|
||||
store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle
|
||||
},
|
||||
{
|
||||
confirmButtonText: '去编辑',
|
||||
@@ -106,7 +107,7 @@ function getCurrentPractice() {
|
||||
() => {
|
||||
updateSections(tempArticle)
|
||||
tempArticle.useTranslateType = TranslateType.none
|
||||
articleData.article = tempArticle
|
||||
store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle
|
||||
},
|
||||
{
|
||||
confirmButtonText: '去编辑',
|
||||
@@ -118,7 +119,7 @@ function getCurrentPractice() {
|
||||
if (tempArticle.useTranslateType === TranslateType.network) {
|
||||
updateSections(tempArticle)
|
||||
updateLocalSentenceTranslate(tempArticle, tempArticle.textNetworkTranslate)
|
||||
articleData.article = tempArticle
|
||||
store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +133,6 @@ onMounted(() => {
|
||||
|
||||
})
|
||||
|
||||
|
||||
function write() {
|
||||
console.log('write')
|
||||
settingStore.dictation = true
|
||||
@@ -175,7 +175,7 @@ function test() {
|
||||
<template>
|
||||
<div class="practice">
|
||||
<Toolbar/>
|
||||
<!-- <BaseButton @click="test">test</BaseButton>-->
|
||||
<!-- <BaseButton @click="test">test</BaseButton>-->
|
||||
|
||||
<TypeArticle
|
||||
v-if="store.isArticle"
|
||||
|
||||
@@ -5,13 +5,12 @@ import Ring from "@/components/Ring.vue";
|
||||
import Tooltip from "@/components/Tooltip.vue";
|
||||
import Fireworks from "@/components/Fireworks.vue";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {DefaultDisplayStatistics, DisplayStatistics, Statistics} from "@/types.ts";
|
||||
import {DefaultDisplayStatistics, DisplayStatistics} from "@/types.ts";
|
||||
import {emitter, EventKey} from "@/utils/eventBus.ts";
|
||||
import {onMounted, reactive} from "vue";
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import {Icon} from '@iconify/vue';
|
||||
import {usePracticeStore} from "@/stores/practice.ts";
|
||||
import {useSettingStore} from "@/stores/setting.ts";
|
||||
import {$ref} from "vue/macros";
|
||||
|
||||
const store = useBaseStore()
|
||||
let statModalIsOpen = $ref(false)
|
||||
@@ -22,6 +21,7 @@ const emit = defineEmits([
|
||||
'next',
|
||||
'write'
|
||||
])
|
||||
|
||||
onMounted(() => {
|
||||
emitter.on(EventKey.openStatModal, (stat: DisplayStatistics) => {
|
||||
currentStat = {...DefaultDisplayStatistics, ...stat}
|
||||
@@ -29,18 +29,27 @@ onMounted(() => {
|
||||
})
|
||||
})
|
||||
|
||||
function options(emitType: string) {
|
||||
let optionType = $ref('')
|
||||
|
||||
function options(emitType: 'write' | 'repeat' | 'next') {
|
||||
statModalIsOpen = false
|
||||
optionType = emitType
|
||||
emit(emitType)
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
if (!optionType) {
|
||||
options('next')
|
||||
}
|
||||
optionType = ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
:header="false"
|
||||
v-model="statModalIsOpen"
|
||||
@close="options('next')">
|
||||
@close="onClose">
|
||||
<div class="statistics">
|
||||
<header>
|
||||
<div class="title">{{ store.currentDict.name }}</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import {computed, nextTick, watchEffect} from "vue"
|
||||
import {computed, nextTick, onMounted, watch, watchEffect} from "vue"
|
||||
import {$ref} from "vue/macros";
|
||||
import {Article, ArticleWord, DefaultArticle, ShortKeyMap, Word} from "@/types";
|
||||
import {Article, ArticleWord, DefaultArticle, DisplayStatistics, ShortKeyMap, Word} from "@/types";
|
||||
import {useBaseStore} from "@/stores/base";
|
||||
import {usePracticeStore} from "@/stores/practice.ts";
|
||||
import TypeWord from "@/components/Practice/TypeWord.vue";
|
||||
@@ -9,6 +9,7 @@ import {useSettingStore} from "@/stores/setting.ts";
|
||||
import {usePlayBeep, usePlayCorrect, usePlayKeyboardAudio, usePlayWordAudio} from "@/hooks/sound.ts";
|
||||
import {useOnKeyboardEventListener} from "@/hooks/event.ts";
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import {emitter, EventKey} from "@/utils/eventBus.ts";
|
||||
|
||||
interface IProps {
|
||||
article: Article,
|
||||
@@ -26,14 +27,6 @@ const props = withDefaults(defineProps<IProps>(), {
|
||||
stringIndex: 0,
|
||||
})
|
||||
|
||||
const playBeep = usePlayBeep()
|
||||
const playCorrect = usePlayCorrect()
|
||||
const playKeyboardAudio = usePlayKeyboardAudio()
|
||||
const playWordAudio = usePlayWordAudio()
|
||||
const store = useBaseStore()
|
||||
const practiceStore = usePracticeStore()
|
||||
const settingStore = useSettingStore()
|
||||
|
||||
let isPlay = $ref(false)
|
||||
let articleWrapperRef = $ref<HTMLInputElement>(null)
|
||||
let tabIndex = $ref(0)
|
||||
@@ -56,14 +49,23 @@ let wordData = $ref({
|
||||
index: -1
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
const playBeep = usePlayBeep()
|
||||
const playCorrect = usePlayCorrect()
|
||||
const playKeyboardAudio = usePlayKeyboardAudio()
|
||||
const playWordAudio = usePlayWordAudio()
|
||||
const store = useBaseStore()
|
||||
const practiceStore = usePracticeStore()
|
||||
const settingStore = useSettingStore()
|
||||
|
||||
watch(() => props.article, () => {
|
||||
sectionIndex = props.sectionIndex
|
||||
sentenceIndex = props.sentenceIndex
|
||||
wordIndex = props.wordIndex
|
||||
stringIndex = props.stringIndex
|
||||
|
||||
practiceStore.inputNumber = 0
|
||||
practiceStore.wrongNumber = 0
|
||||
tabIndex = 0
|
||||
practiceStore.inputWordNumber = 0
|
||||
practiceStore.wrongWordNumber = 0
|
||||
practiceStore.repeatNumber = 0
|
||||
practiceStore.total = 0
|
||||
props.article.sections.map((v, i) => {
|
||||
@@ -78,6 +80,12 @@ watchEffect(() => {
|
||||
practiceStore.wrongWords = []
|
||||
practiceStore.startDate = Date.now()
|
||||
calcTranslateLocation()
|
||||
}, {immediate: true})
|
||||
|
||||
onMounted(() => {
|
||||
emitter.on(EventKey.resetWord, () => {
|
||||
wrong = input = ''
|
||||
})
|
||||
})
|
||||
|
||||
function calcTranslateLocation() {
|
||||
@@ -136,7 +144,7 @@ function onKeyDown(e: KeyboardEvent) {
|
||||
wordIndex++
|
||||
|
||||
if (!store.skipWordNamesWithSimpleWords.includes(currentWord.name.toLowerCase()) && !currentWord.isSymbol) {
|
||||
practiceStore.inputNumber++
|
||||
practiceStore.inputWordNumber++
|
||||
}
|
||||
|
||||
if (!currentSentence.words[wordIndex]) {
|
||||
@@ -145,6 +153,10 @@ function onKeyDown(e: KeyboardEvent) {
|
||||
if (!currentSection[sentenceIndex]) {
|
||||
sentenceIndex = 0
|
||||
sectionIndex++
|
||||
|
||||
if (!props.article.sections[sectionIndex]) {
|
||||
console.log('打完了')
|
||||
}
|
||||
} else {
|
||||
if (settingStore.dictation) {
|
||||
calcTranslateLocation()
|
||||
@@ -155,9 +167,18 @@ function onKeyDown(e: KeyboardEvent) {
|
||||
}
|
||||
|
||||
const nextSentence = () => {
|
||||
tabIndex = 1
|
||||
// wordData.words = practiceStore.wrongWords
|
||||
wordData.words = [
|
||||
{"name": "pharmacy", "trans": ["药房;配药学,药剂学;制药业;一批备用药品"], "usphone": "'fɑrməsi", "ukphone": "'fɑːməsɪ"},
|
||||
// {"name": "foregone", "trans": ["过去的;先前的;预知的;预先决定的", "发生在…之前(forego的过去分词)"], "usphone": "'fɔrɡɔn", "ukphone": "fɔː'gɒn"}, {"name": "president", "trans": ["总统;董事长;校长;主席"], "usphone": "'prɛzɪdənt", "ukphone": "'prezɪd(ə)nt"}, {"name": "plastic", "trans": ["塑料的;(外科)造型的;可塑的", "塑料制品;整形;可塑体"], "usphone": "'plæstɪk", "ukphone": "'plæstɪk"}, {"name": "provisionally", "trans": ["临时地,暂时地"], "usphone": "", "ukphone": ""}, {"name": "incentive", "trans": ["动机;刺激", "激励的;刺激的"], "usphone": "ɪn'sɛntɪv", "ukphone": "ɪn'sentɪv"}, {"name": "calculate", "trans": ["计算;以为;作打算"], "usphone": "'kælkjulet", "ukphone": "'kælkjʊleɪt"}
|
||||
]
|
||||
|
||||
return
|
||||
isSpace = false
|
||||
stringIndex = 0
|
||||
wordIndex = 0
|
||||
input = wrong = ''
|
||||
|
||||
//todo 计得把略过的单词加上统计里面去
|
||||
// if (!store.skipWordNamesWithSimpleWords.includes(currentWord.name.toLowerCase()) && !currentWord.isSymbol) {
|
||||
@@ -168,6 +189,29 @@ function onKeyDown(e: KeyboardEvent) {
|
||||
if (!currentSection[sentenceIndex]) {
|
||||
sentenceIndex = 0
|
||||
sectionIndex++
|
||||
if (!props.article.sections[sectionIndex]) {
|
||||
console.log('打完了')
|
||||
// if (practiceStore.wrongWordNumber === 0) {
|
||||
if (false) {
|
||||
console.log('这章节完了')
|
||||
let now = Date.now()
|
||||
let stat: DisplayStatistics = {
|
||||
startDate: practiceStore.startDate,
|
||||
endDate: now,
|
||||
spend: now - practiceStore.startDate,
|
||||
total: practiceStore.total,
|
||||
correctRate: -1,
|
||||
wrongWordNumber: practiceStore.wrongWordNumber,
|
||||
wrongWords: practiceStore.wrongWords,
|
||||
}
|
||||
stat.correctRate = 100 - Math.trunc(((stat.wrongWordNumber) / (stat.total)) * 100)
|
||||
emitter.emit(EventKey.openStatModal, stat)
|
||||
} else {
|
||||
tabIndex = 1
|
||||
// wordData.words = practiceStore.wrongWords
|
||||
wordData.words = [{"name": "pharmacy", "trans": ["药房;配药学,药剂学;制药业;一批备用药品"], "usphone": "'fɑrməsi", "ukphone": "'fɑːməsɪ"}, {"name": "foregone", "trans": ["过去的;先前的;预知的;预先决定的", "发生在…之前(forego的过去分词)"], "usphone": "'fɔrɡɔn", "ukphone": "fɔː'gɒn"}, {"name": "president", "trans": ["总统;董事长;校长;主席"], "usphone": "'prɛzɪdənt", "ukphone": "'prezɪd(ə)nt"}, {"name": "plastic", "trans": ["塑料的;(外科)造型的;可塑的", "塑料制品;整形;可塑体"], "usphone": "'plæstɪk", "ukphone": "'plæstɪk"}, {"name": "provisionally", "trans": ["临时地,暂时地"], "usphone": "", "ukphone": ""}, {"name": "incentive", "trans": ["动机;刺激", "激励的;刺激的"], "usphone": "ɪn'sɛntɪv", "ukphone": "ɪn'sentɪv"}, {"name": "calculate", "trans": ["计算;以为;作打算"], "usphone": "'kælkjulet", "ukphone": "'kælkjʊleɪt"}]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (settingStore.dictation) {
|
||||
calcTranslateLocation()
|
||||
@@ -212,11 +256,11 @@ function onKeyDown(e: KeyboardEvent) {
|
||||
|
||||
let isWrong = false
|
||||
if (settingStore.ignoreCase) {
|
||||
isWrong = key.toLowerCase() === letter.toLowerCase()
|
||||
isWrong = key.toLowerCase() !== letter.toLowerCase()
|
||||
} else {
|
||||
isWrong = key === letter
|
||||
isWrong = key !== letter
|
||||
}
|
||||
if (isWrong) {
|
||||
if (!isWrong) {
|
||||
input += letter
|
||||
wrong = ''
|
||||
// console.log('匹配上了')
|
||||
@@ -243,7 +287,7 @@ function onKeyDown(e: KeyboardEvent) {
|
||||
if (!store.skipWordNamesWithSimpleWords.includes(currentWord.name.toLowerCase())) {
|
||||
if (!practiceStore.wrongWords.find((v) => v.name.toLowerCase() === currentWord.name.toLowerCase())) {
|
||||
practiceStore.wrongWords.push(currentWord)
|
||||
practiceStore.wrongNumber++
|
||||
practiceStore.wrongWordNumber++
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import {onMounted, watchEffect} from "vue"
|
||||
import {onMounted, watch, watchEffect} from "vue"
|
||||
import {$computed, $ref} from "vue/macros"
|
||||
import {useBaseStore} from "@/stores/base.ts"
|
||||
import {DictType, DisplayStatistics, ShortKeyMap, Statistics, Word} from "../../types";
|
||||
@@ -43,16 +43,18 @@ const playKeyboardAudio = usePlayKeyboardAudio()
|
||||
const playWordAudio = usePlayWordAudio()
|
||||
|
||||
|
||||
watchEffect(() => {
|
||||
watch(() => props.words, () => {
|
||||
data.words = props.words
|
||||
data.index = props.words.length ? 0 : -1
|
||||
practiceStore.inputNumber = 0
|
||||
practiceStore.wrongNumber = 0
|
||||
practiceStore.repeatNumber = 0
|
||||
practiceStore.total = props.words.length
|
||||
|
||||
practiceStore.wrongWords = []
|
||||
practiceStore.repeatNumber = 0
|
||||
practiceStore.startDate = Date.now()
|
||||
})
|
||||
practiceStore.correctRate = -1
|
||||
practiceStore.total = props.words.length
|
||||
practiceStore.inputWordNumber = 0
|
||||
practiceStore.wrongWordNumber = 0
|
||||
}, {immediate: true})
|
||||
|
||||
|
||||
let word = $computed(() => {
|
||||
@@ -68,10 +70,9 @@ let resetWord = $computed(() => {
|
||||
return word.name.slice(input.length + wrong.length)
|
||||
})
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
emitter.on(EventKey.resetWord, () => {
|
||||
input = ''
|
||||
wrong = input = ''
|
||||
})
|
||||
})
|
||||
|
||||
@@ -85,8 +86,8 @@ function next() {
|
||||
}
|
||||
data.index = 0
|
||||
practiceStore.total = data.words.length
|
||||
practiceStore.inputNumber = 0
|
||||
practiceStore.wrongNumber = 0
|
||||
practiceStore.inputWordNumber = 0
|
||||
practiceStore.wrongWordNumber = 0
|
||||
practiceStore.repeatNumber++
|
||||
data.wrongWords = []
|
||||
} else {
|
||||
@@ -106,7 +107,7 @@ function next() {
|
||||
}
|
||||
} else {
|
||||
data.index++
|
||||
practiceStore.inputNumber++
|
||||
practiceStore.inputWordNumber++
|
||||
console.log('这个词完了')
|
||||
if ([DictType.customDict, DictType.publicDict].includes(store.current.dictType)
|
||||
&& store.skipWordNames.includes(word.name.toLowerCase())) {
|
||||
@@ -126,11 +127,11 @@ async function onKeyDown(e: KeyboardEvent) {
|
||||
let letter = e.key
|
||||
let isWrong = false
|
||||
if (settingStore.ignoreCase) {
|
||||
isWrong = (input + letter).toLowerCase() === word.name.toLowerCase().slice(0, input.length + 1)
|
||||
isWrong = (input + letter).toLowerCase() !== word.name.toLowerCase().slice(0, input.length + 1)
|
||||
} else {
|
||||
isWrong = (input + letter) === word.name.slice(0, input.length + 1)
|
||||
isWrong = (input + letter) !== word.name.slice(0, input.length + 1)
|
||||
}
|
||||
if (isWrong) {
|
||||
if (!isWrong) {
|
||||
input += letter
|
||||
wrong = ''
|
||||
playKeyboardAudio()
|
||||
@@ -142,7 +143,7 @@ async function onKeyDown(e: KeyboardEvent) {
|
||||
}
|
||||
if (!data.wrongWords.find((v: Word) => v.name.toLowerCase() === word.name.toLowerCase())) {
|
||||
data.wrongWords.push(word)
|
||||
practiceStore.wrongNumber++
|
||||
practiceStore.wrongWordNumber++
|
||||
}
|
||||
wrong = letter
|
||||
playKeyboardAudio()
|
||||
@@ -200,8 +201,6 @@ async function onKeyDown(e: KeyboardEvent) {
|
||||
}
|
||||
|
||||
useOnKeyboardEventListener(onKeyDown, onKeyUp)
|
||||
// useEventListener('keydown', onKeyDown)
|
||||
// useEventListener('keyup', onKeyUp)
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -55,8 +55,15 @@ export function splitEnArticle(text: string, lang: string = 'en', keyboardMap: K
|
||||
//将缩写词的双引号替换回单引号
|
||||
text = text.replaceAll(`"t`, `'t`)
|
||||
text = text.replaceAll(`"s`, `'s`)
|
||||
text = text.replaceAll(`"m`, `'m`)
|
||||
text = text.replaceAll(`"d`, `'d`)
|
||||
text = text.replaceAll(`"ve`, `'ve`)
|
||||
text = text.replaceAll(`"clock`, `'clock`)
|
||||
// console.log('splitEnArticle', text)
|
||||
// console.log('splitEnArticle length', text.length)
|
||||
|
||||
text.split('').map((v, i, arr) => {
|
||||
// if (i > 355) debugger
|
||||
switch (v) {
|
||||
case ' ':
|
||||
if (word.name) {
|
||||
@@ -80,7 +87,7 @@ export function splitEnArticle(text: string, lang: string = 'en', keyboardMap: K
|
||||
word = cloneDeep(DefaultArticleWord)
|
||||
break
|
||||
case keyboardMap.QuoteLeft:
|
||||
let symbolPosition = null
|
||||
let nearSymbolPosition = null
|
||||
let indexs = {
|
||||
a: -1,
|
||||
b: -1,
|
||||
@@ -90,15 +97,15 @@ export function splitEnArticle(text: string, lang: string = 'en', keyboardMap: K
|
||||
sections.toReversed().map((sectionItem, a) => {
|
||||
sectionItem.toReversed().map((sentenceItem, b) => {
|
||||
sentenceItem.words.toReversed().map((wordItem, c) => {
|
||||
if (wordItem.symbolPosition !== '' && symbolPosition === null) {
|
||||
symbolPosition = wordItem.symbolPosition === 'end'
|
||||
if (wordItem.symbolPosition !== '' && nearSymbolPosition === null) {
|
||||
nearSymbolPosition = wordItem.symbolPosition
|
||||
indexs = {a, b, c}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
if (symbolPosition || symbolPosition === null) {
|
||||
if (nearSymbolPosition === 'end' || nearSymbolPosition === null) {
|
||||
sentence.words.push(cloneDeep({
|
||||
...DefaultArticleWord,
|
||||
name: v,
|
||||
|
||||
@@ -7,8 +7,8 @@ export interface PracticeState {
|
||||
repeatNumber: number,
|
||||
startDate: number,
|
||||
total: number,
|
||||
inputNumber: number,
|
||||
wrongNumber: number,
|
||||
inputWordNumber: number,
|
||||
wrongWordNumber: number,
|
||||
correctRate: number,
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ export const usePracticeStore = defineStore('practice', {
|
||||
startDate: Date.now(),
|
||||
correctRate: -1,
|
||||
total: 0,
|
||||
inputNumber: 0,
|
||||
wrongNumber: 0,
|
||||
inputWordNumber: 0,
|
||||
wrongWordNumber: 0,
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -52,7 +52,7 @@ export const useSettingStore = defineStore('setting', {
|
||||
effectSoundVolume: 100,
|
||||
repeatCount: 1,
|
||||
repeatCustomCount: null,
|
||||
dictation: true,
|
||||
dictation: false,
|
||||
translate: true,
|
||||
|
||||
showNearWord: true,
|
||||
|
||||
@@ -3,67 +3,67 @@ import Modal, {ModalProps} from "@/components/Modal/Modal.vue";
|
||||
import {AppContext, Component, ComponentPublicInstance, createVNode, getCurrentInstance, render, VNode} from 'vue';
|
||||
|
||||
export class MessageBox {
|
||||
static confirm(
|
||||
content: string,
|
||||
title: string,
|
||||
onOk: () => any = () => void 0,
|
||||
onCancel: () => any = () => void 0,
|
||||
config: ModalProps = {}
|
||||
) {
|
||||
let container = document.createElement('div')
|
||||
const close = () => {
|
||||
render(null, container);
|
||||
container.remove()
|
||||
}
|
||||
let tempOnCancel = () => {
|
||||
onCancel()
|
||||
close()
|
||||
}
|
||||
let tempOnOk = () => {
|
||||
onOk()
|
||||
close()
|
||||
}
|
||||
const vNode = createVNode(Modal, {
|
||||
title,
|
||||
content,
|
||||
onCancel: tempOnCancel,
|
||||
onOk: tempOnOk,
|
||||
footer: true,
|
||||
...config
|
||||
});
|
||||
// const appContext = getCurrentInstance()?.appContext;
|
||||
// // 补丁:Component中获取当前组件树的provides
|
||||
// if (appContext) {
|
||||
// const currentProvides = (getCurrentInstance() as any)?.provides;
|
||||
// Reflect.set(appContext, 'provides', {...appContext.provides, ...currentProvides});
|
||||
// }
|
||||
// vNode.appContext = appContext;
|
||||
render(vNode, container);
|
||||
document.body.append(container)
|
||||
static confirm(
|
||||
content: string,
|
||||
title: string,
|
||||
onOk: () => any = () => void 0,
|
||||
onCancel: () => any = () => void 0,
|
||||
config: ModalProps = {}
|
||||
) {
|
||||
let container = document.createElement('div')
|
||||
const close = () => {
|
||||
render(null, container);
|
||||
container.remove()
|
||||
}
|
||||
let tempOnCancel = () => {
|
||||
onCancel()
|
||||
close()
|
||||
}
|
||||
let tempOnOk = () => {
|
||||
onOk()
|
||||
close()
|
||||
}
|
||||
const vNode = createVNode(Modal, {
|
||||
title,
|
||||
content,
|
||||
onCancel: tempOnCancel,
|
||||
onOk: tempOnOk,
|
||||
footer: true,
|
||||
...config
|
||||
});
|
||||
// const appContext = getCurrentInstance()?.appContext;
|
||||
// // 补丁:Component中获取当前组件树的provides
|
||||
// if (appContext) {
|
||||
// const currentProvides = (getCurrentInstance() as any)?.provides;
|
||||
// Reflect.set(appContext, 'provides', {...appContext.provides, ...currentProvides});
|
||||
// }
|
||||
// vNode.appContext = appContext;
|
||||
render(vNode, container);
|
||||
document.body.append(container)
|
||||
}
|
||||
|
||||
static notice(
|
||||
content: string,
|
||||
title: string,
|
||||
) {
|
||||
let container = document.createElement('div')
|
||||
let tempOnCancel = () => {
|
||||
render(null, container);
|
||||
container.remove()
|
||||
}
|
||||
const vNode = createVNode(Modal, {
|
||||
title,
|
||||
content,
|
||||
onCancel: tempOnCancel,
|
||||
});
|
||||
// const appContext = getCurrentInstance()?.appContext;
|
||||
// // 补丁:Component中获取当前组件树的provides
|
||||
// if (appContext) {
|
||||
// const currentProvides = (getCurrentInstance() as any)?.provides;
|
||||
// Reflect.set(appContext, 'provides', {...appContext.provides, ...currentProvides});
|
||||
// }
|
||||
// vNode.appContext = appContext;
|
||||
render(vNode, container);
|
||||
document.body.append(container)
|
||||
static notice(
|
||||
content: string,
|
||||
title: string,
|
||||
) {
|
||||
let container = document.createElement('div')
|
||||
let tempOnCancel = () => {
|
||||
render(null, container);
|
||||
container.remove()
|
||||
}
|
||||
const vNode = createVNode(Modal, {
|
||||
title,
|
||||
content,
|
||||
onCancel: tempOnCancel,
|
||||
});
|
||||
// const appContext = getCurrentInstance()?.appContext;
|
||||
// // 补丁:Component中获取当前组件树的provides
|
||||
// if (appContext) {
|
||||
// const currentProvides = (getCurrentInstance() as any)?.provides;
|
||||
// Reflect.set(appContext, 'provides', {...appContext.provides, ...currentProvides});
|
||||
// }
|
||||
// vNode.appContext = appContext;
|
||||
render(vNode, container);
|
||||
document.body.append(container)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user