save
This commit is contained in:
30
src/App.vue
30
src/App.vue
@@ -15,6 +15,7 @@ import {isMobile, shakeCommonDict} from "@/utils";
|
||||
import router, {routes} from "@/router.ts";
|
||||
|
||||
import {useRoute} from "vue-router";
|
||||
|
||||
const store = useBaseStore()
|
||||
const runtimeStore = useRuntimeStore()
|
||||
const settingStore = useSettingStore()
|
||||
@@ -28,35 +29,6 @@ watch(settingStore.$state, (n) => {
|
||||
localStorage.setItem(SAVE_SETTING_KEY.key, JSON.stringify({val: n, version: SAVE_SETTING_KEY.version}))
|
||||
})
|
||||
|
||||
//检测几个特定词典
|
||||
watch(store.collect.originWords, (n) => {
|
||||
if (n.length === 0) {
|
||||
store.collect.words = []
|
||||
store.collect.chapterWords = []
|
||||
} else {
|
||||
store.collect.words = cloneDeep(n)
|
||||
store.collect.chapterWords = [store.collect.words]
|
||||
}
|
||||
})
|
||||
watch(store.simple.originWords, (n) => {
|
||||
if (n.length === 0) {
|
||||
store.simple.words = []
|
||||
store.simple.chapterWords = []
|
||||
} else {
|
||||
store.simple.words = cloneDeep(n)
|
||||
store.simple.chapterWords = [store.simple.words]
|
||||
}
|
||||
})
|
||||
watch(store.wrong.originWords, (n) => {
|
||||
if (n.length === 0) {
|
||||
store.wrong.words = []
|
||||
store.wrong.chapterWords = []
|
||||
} else {
|
||||
store.wrong.words = cloneDeep(n)
|
||||
store.wrong.chapterWords = [store.wrong.words]
|
||||
}
|
||||
})
|
||||
|
||||
async function init() {
|
||||
// console.time()
|
||||
store.init().then(() => {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import {Article, Dict, DictType, Word} from "@/types.ts";
|
||||
import {Article, Dict, Word} from "@/types.ts";
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {chunk, cloneDeep, shuffle} from "lodash-es";
|
||||
import {cloneDeep, shuffle} from "lodash-es";
|
||||
import {isArticle} from "@/hooks/article.ts";
|
||||
import {nanoid} from "nanoid";
|
||||
|
||||
|
||||
export function useWordOptions() {
|
||||
|
||||
@@ -20,8 +20,14 @@ import {cloneDeep} from "lodash-es";
|
||||
import WordList from "@/pages/pc/components/list/WordList.vue";
|
||||
import ArticleList from "@/pages/pc/components/list/ArticleList.vue";
|
||||
import Slide from "@/pages/pc/components/Slide.vue";
|
||||
import {useNav} from "@/utils";
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
type: DictType
|
||||
}>(), {
|
||||
type: DictType.word
|
||||
})
|
||||
|
||||
const router = useRouter()
|
||||
const store = useBaseStore()
|
||||
const runtimeStore = useRuntimeStore()
|
||||
const settingStore = useSettingStore()
|
||||
@@ -60,33 +66,21 @@ const {
|
||||
toggleArticleCollect
|
||||
} = useArticleOptions()
|
||||
|
||||
function addCollect() {
|
||||
runtimeStore.editDict = cloneDeep(store.collect)
|
||||
router.push({path: '/dict', query: {type: 'addWordOrArticle'}})
|
||||
}
|
||||
|
||||
function addSimple() {
|
||||
runtimeStore.editDict = cloneDeep(store.simple)
|
||||
router.push({path: '/dict', query: {type: 'addWordOrArticle'}})
|
||||
}
|
||||
const {nav} = useNav()
|
||||
|
||||
const showCollectToggleButton = $computed(() => {
|
||||
if (store.currentDict.type === DictType.collect) {
|
||||
if (store.current.practiceType !== practiceType) {
|
||||
return (practiceType === DictType.word && store.collect.words.length) ||
|
||||
(practiceType === DictType.article && store.collect.articles.length)
|
||||
}
|
||||
} else {
|
||||
return (practiceType === DictType.word && store.collect.words.length) ||
|
||||
(practiceType === DictType.article && store.collect.articles.length)
|
||||
}
|
||||
return false
|
||||
if (props.type === DictType.word) return !store.collectWord.length
|
||||
return !store.collectArticle.length
|
||||
})
|
||||
|
||||
function changeCollect(){
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<Transition name="fade">
|
||||
<div class="panel anim" v-show="settingStore.showPanel ">
|
||||
<div class="panel anim" v-show="settingStore.showPanel">
|
||||
<header>
|
||||
<div class="tabs">
|
||||
<div class="tab" :class="tabIndex === 0 && 'active'" @click="tabIndex = 0">当前</div>
|
||||
@@ -108,17 +102,13 @@ const showCollectToggleButton = $computed(() => {
|
||||
<div class="panel-page-item">
|
||||
<div class="list-header">
|
||||
<div class="left">
|
||||
<el-radio-group v-model="practiceType">
|
||||
<el-radio-button border :value="DictType.word">单词</el-radio-button>
|
||||
<el-radio-button border :value="DictType.article">文章</el-radio-button>
|
||||
</el-radio-group>
|
||||
<div class="dict-name" v-if="practiceType === DictType.word && store.collect.words.length">
|
||||
{{ store.collect.words.length }}个单词
|
||||
<div class="dict-name" v-if="props.type === DictType.word && store.collectWord.length">
|
||||
{{ store.collectWord.length }}个单词
|
||||
</div>
|
||||
<div class="dict-name" v-if="practiceType === DictType.article && store.collect.articles.length">
|
||||
{{ store.collect.articles.length }}篇文章
|
||||
<div class="dict-name" v-if="props.type === DictType.article">
|
||||
{{ store.collectArticle.length }}篇文章
|
||||
</div>
|
||||
<BaseIcon icon="fluent:add-12-regular" title="添加" @click="addCollect"/>
|
||||
<BaseIcon icon="fluent:add-12-regular" title="添加" @click="nav('edit-word-dict',{type:0})"/>
|
||||
</div>
|
||||
<template v-if="showCollectToggleButton">
|
||||
<PopConfirm
|
||||
@@ -129,7 +119,7 @@ const showCollectToggleButton = $computed(() => {
|
||||
</PopConfirm>
|
||||
</template>
|
||||
</div>
|
||||
<template v-if="practiceType === DictType.word">
|
||||
<template v-if="props.type === DictType.word">
|
||||
<WordList
|
||||
v-if="store.collectWord.length"
|
||||
class="word-list"
|
||||
@@ -165,9 +155,9 @@ const showCollectToggleButton = $computed(() => {
|
||||
<div class="list-header">
|
||||
<div class="left">
|
||||
<div class="dict-name">总词数:{{ store.simple2.length }}</div>
|
||||
<BaseIcon icon="fluent:add-12-regular" title="添加" @click="addSimple"/>
|
||||
<BaseIcon icon="fluent:add-12-regular" title="添加" @click="nav('edit-word-dict',{type:2})"/>
|
||||
</div>
|
||||
<template v-if="store.currentDict.type !== DictType.simple && store.simple2.length">
|
||||
<template v-if="store.simple2.length">
|
||||
<PopConfirm
|
||||
:title="`确认切换?`"
|
||||
@confirm="changeIndex( store.simple)"
|
||||
@@ -196,7 +186,7 @@ const showCollectToggleButton = $computed(() => {
|
||||
<div class="list-header">
|
||||
<div class="dict-name">总词数:{{ store.wrong2.length }}</div>
|
||||
<template
|
||||
v-if="store.currentDict.type !== DictType.wrong && store.wrong2.length">
|
||||
v-if="store.wrong2.length">
|
||||
<PopConfirm
|
||||
:title="`确认切换?`"
|
||||
@confirm="changeIndex( store.wrong)"
|
||||
@@ -244,7 +234,6 @@ $header-height: 3rem;
|
||||
border: 1px solid var(--color-item-border);
|
||||
box-shadow: var(--shadow);
|
||||
|
||||
|
||||
& > header {
|
||||
min-height: 3rem;
|
||||
box-sizing: border-box;
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import {useBaseStore} from "@/stores/base.ts"
|
||||
import {onMounted} from "vue"
|
||||
import {chunk} from "lodash-es";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {Icon} from '@iconify/vue';
|
||||
import "vue-activity-calendar/style.css";
|
||||
import WordListDialog from "@/pages/pc/components/dialog/WordListDialog.vue";
|
||||
import {isArticle} from "@/hooks/article.ts";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {useSettingStore} from "@/stores/setting.ts";
|
||||
import {emitter, EventKey} from "@/utils/eventBus.ts";
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
import Dialog from "@/pages/pc/components/dialog/Dialog.vue";
|
||||
import {useRouter} from "vue-router";
|
||||
|
||||
const store = useBaseStore()
|
||||
const runtimeStore = useRuntimeStore()
|
||||
|
||||
@@ -5,10 +5,9 @@ import Ring from "@/pages/pc/components/Ring.vue";
|
||||
import Tooltip from "@/pages/pc/components/Tooltip.vue";
|
||||
import Fireworks from "@/pages/pc/components/Fireworks.vue";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {DefaultDisplayStatistics, DisplayStatistics, ShortcutKey} from "@/types.ts";
|
||||
import {ShortcutKey} from "@/types.ts";
|
||||
import {emitter, EventKey} from "@/utils/eventBus.ts";
|
||||
import {onMounted, reactive} from "vue";
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import {onMounted} from "vue";
|
||||
import {Icon} from '@iconify/vue';
|
||||
import {useSettingStore} from "@/stores/setting.ts";
|
||||
import {usePracticeStore} from "@/stores/practice.ts";
|
||||
|
||||
@@ -24,6 +24,8 @@ export interface BaseState {
|
||||
wrong2?: Word[],
|
||||
master?: Word[],
|
||||
articleDictList?: Dict[]
|
||||
|
||||
commonDictList: any[],
|
||||
wordDictList?: Dict[],
|
||||
currentStudy?: {
|
||||
word: {
|
||||
@@ -102,6 +104,14 @@ export const DefaultBaseState = (): BaseState => ({
|
||||
simple2: [],
|
||||
wrong2: [],
|
||||
master: [],
|
||||
commonDictList: [
|
||||
{type: DictType.collectWord, words: [], statistics: []},
|
||||
{type: DictType.collectArticle, articles: [], statistics: []},
|
||||
{type: DictType.simple, words: [], statistics: []},
|
||||
{type: DictType.wrong, words: [], statistics: []},
|
||||
{type: DictType.master, words: [], statistics: []},
|
||||
],
|
||||
|
||||
articleDictList: [
|
||||
{
|
||||
...cloneDeep(DefaultDict),
|
||||
@@ -239,14 +249,24 @@ export const useBaseStore = defineStore('base', {
|
||||
collect(): Dict {
|
||||
return this.myDictList[0]
|
||||
},
|
||||
|
||||
collectWord(): Dict {
|
||||
return this.commonDictList[0]
|
||||
},
|
||||
collectArticle(): Dict {
|
||||
return this.commonDictList[1]
|
||||
},
|
||||
simple(): Dict {
|
||||
return this.myDictList[1]
|
||||
return this.commonDictList[2]
|
||||
},
|
||||
wrong(): Dict {
|
||||
return this.myDictList[2]
|
||||
return this.commonDictList[3]
|
||||
},
|
||||
master(): Dict {
|
||||
return this.commonDictList[4]
|
||||
},
|
||||
skipWordNames() {
|
||||
return this.simple.originWords.map(v => v.word.toLowerCase())
|
||||
return this.simple.words.map(v => v.word.toLowerCase())
|
||||
},
|
||||
skipWordNamesWithSimpleWords() {
|
||||
return this.simple.originWords.map(v => v.word.toLowerCase()).concat(this.simpleWords)
|
||||
|
||||
@@ -34,7 +34,7 @@ export const DefaultWord: Word = {
|
||||
|
||||
export function getDefaultWord(val?: any) {
|
||||
return {
|
||||
id:'',
|
||||
id: '',
|
||||
word: '',
|
||||
phonetic0: '',
|
||||
phonetic1: '',
|
||||
@@ -71,6 +71,9 @@ export enum DictType {
|
||||
collect = 'collect',
|
||||
simple = 'simple',
|
||||
wrong = 'wrong',
|
||||
master = 'master',
|
||||
collectWord = 'collect-word',
|
||||
collectArticle = 'collect-article',
|
||||
word = 'word',
|
||||
article = 'article',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user