Fixed a bug where the toggle dictionary could not load words

This commit is contained in:
zyronon
2023-12-02 22:00:19 +08:00
parent d602d5459a
commit d7d8c3782c
5 changed files with 17 additions and 15 deletions

View File

@@ -133,7 +133,6 @@ onMounted(() => {
emitter.on(ShortcutKey.ToggleTheme, toggleTheme)
emitter.on(ShortcutKey.ToggleConciseMode, toggleConciseMode)
emitter.on(ShortcutKey.TogglePanel, togglePanel)
practiceRef.getCurrentPractice()
})
onUnmounted(() => {

View File

@@ -44,13 +44,10 @@ watch([
// () => store.load,
() => store.currentDict.articles,
], n => {
console.log('n', n)
getCurrentPractice()
})
onMounted(() => {
getCurrentPractice()
})
onMounted(getCurrentPractice)
function setArticle(val: Article) {
store.currentDict.articles[store.currentDict.chapterIndex] = cloneDeep(val)
@@ -218,13 +215,15 @@ function changePracticeArticle(val: {
}
}
defineExpose({getCurrentPractice})
const settingStore = useSettingStore()
const {
isArticleCollect,
toggleArticleCollect
} = useArticleOptions()
defineExpose({getCurrentPractice})
</script>
<template>

View File

@@ -20,25 +20,27 @@ let wordData = $ref({
})
watch([
() => store.load,
() => store.currentDict.words,
], n => {
getCurrentPractice()
})
function getCurrentPractice() {
// console.log('store.currentDict',store.currentDict)
if (store.currentDict.translateLanguage === 'common') {
if (store.chapter.length) {
wordData.words = store.chapter
wordData.index = 0
store.chapter.map((w: Word) => {
let res = runtimeStore.translateWordList.find(a => a.name === w.name)
if (res) w = Object.assign(w, res)
if (!w.trans.length){
let res = runtimeStore.translateWordList.find(a => a.name === w.name)
if (res) w = Object.assign(w, res)
}
})
}
wordData.words = cloneDeep(store.chapter)
wordData.index = 0
// console.log('wordData', wordData)
}
onMounted(getCurrentPractice)
defineExpose({getCurrentPractice})
</script>