This commit is contained in:
zyronon
2023-12-03 03:25:03 +08:00
parent 8510d3733d
commit 8b224c145a
6 changed files with 18 additions and 6 deletions

View File

@@ -12,6 +12,7 @@ import useTheme from "@/hooks/theme.ts";
import * as localforage from "localforage";
import SettingDialog from "@/components/dialog/SettingDialog.vue";
import ArticleContentDialog from "@/components/dialog/ArticleContentDialog.vue";
import {useStartKeyboardEventListener} from "@/hooks/event.ts";
const store = useBaseStore()
const runtimeStore = useRuntimeStore()
@@ -61,7 +62,6 @@ onMounted(() => {
init()
})
// useStartKeyboardEventListener()
</script>

View File

@@ -25,6 +25,8 @@ export function useWordOptions() {
}
store.collect.originWords.push(val)
}
store.collect.length = store.collect.originWords.length
}
function isWordSimple(val: Word) {
@@ -42,6 +44,8 @@ export function useWordOptions() {
}
store.simple.originWords.push(val)
}
store.simple.length = store.simple.originWords.length
}
function delWrongWord(val: Word) {

View File

@@ -58,6 +58,7 @@ let chapterWordList: Word[] = $computed({
},
set(newValue) {
runtimeStore.editDict.chapterWords[chapterIndex] = newValue
syncMyDictList(runtimeStore.editDict)
}
})
@@ -67,6 +68,7 @@ let residueWordList: Word[] = $computed({
},
set(newValue) {
runtimeStore.editDict.residueWords = newValue
syncMyDictList(runtimeStore.editDict)
}
})
@@ -413,7 +415,7 @@ function changeSort(v: Sort) {
resetChapterList()
}
function resetChapterList(num?: number) {
function resetChapterList(num?: number, sync?: boolean) {
if (num !== undefined) {
runtimeStore.editDict.chapterWordNumber = num
}
@@ -423,6 +425,9 @@ function resetChapterList(num?: number) {
runtimeStore.editDict.chapterWords = chunk(runtimeStore.editDict.words, runtimeStore.editDict.chapterWordNumber)
runtimeStore.editDict.length = runtimeStore.editDict.words.length
chapterList2 = runtimeStore.editDict.chapterWords.map((v, i) => ({id: i}))
if (sync!==undefined){
syncMyDictList(runtimeStore.editDict)
}
}
async function resetDict() {
@@ -711,7 +716,7 @@ defineExpose({getDictDetail, add: addWord, editDict})
<Dialog
title="智能分配单词"
:footer="true"
@ok="resetChapterList(chapterWordNumber)"
@ok="resetChapterList(chapterWordNumber,true)"
@cancel="chapterWordNumber = settingStore.chapterWordNumber"
v-model="showAllocationChapterDialog">
<div class="allocation-chapter">
@@ -733,7 +738,7 @@ defineExpose({getDictDetail, add: addWord, editDict})
<div class="notice">
<span class="text">最小:10</span>
<span class="text">最大:{{ runtimeStore.editDict.words.length}}</span>
<span class="text">最大:{{ runtimeStore.editDict.words.length }}</span>
</div>
<div class="row">

View File

@@ -17,6 +17,7 @@ import {ShortcutKey} from "@/types.ts";
import useTheme from "@/hooks/theme.ts";
import SettingDialog from "@/components/dialog/SettingDialog.vue";
import DictModal from "@/components/dialog/DictDiglog.vue";
import {useStartKeyboardEventListener} from "@/hooks/event.ts";
const practiceStore = usePracticeStore()
const store = useBaseStore()
@@ -154,6 +155,8 @@ onUnmounted(() => {
emitter.off(ShortcutKey.TogglePanel, togglePanel)
})
useStartKeyboardEventListener()
</script>
<template>
<div class="practice-wrapper">

View File

@@ -193,7 +193,7 @@ export const useBaseStore = defineStore('base', {
let configStr: string = await localforage.getItem(SaveDict.key)
// console.log(configStr)
// console.log('s', new Blob([configStr]).size)
configStr = ''
// configStr = ''
if (configStr) {
let data = JSON.parse(configStr)
let state: BaseState = data.val

View File

@@ -148,7 +148,7 @@ export const ShortcutKeyMap = {
export const SaveDict = {
key: 'typing-word-dict',
version: 1
version: 2
}
export const SaveConfig = {
key: 'typing-word-config',