feat:save
This commit is contained in:
@@ -68881,5 +68881,50 @@
|
||||
"rels": []
|
||||
},
|
||||
"etymology": []
|
||||
},
|
||||
{
|
||||
"word": "begin with",
|
||||
"phonetic0": "bɪˈɡɪn wɪð",
|
||||
"phonetic1": "",
|
||||
"trans": [
|
||||
{
|
||||
"pos": "",
|
||||
"cn": "以…开始"
|
||||
},
|
||||
{
|
||||
"pos": "",
|
||||
"cn": "以……开始;开始于……"
|
||||
}
|
||||
],
|
||||
"sentences": [
|
||||
{
|
||||
"c": "To begin with he was Prince Charming.",
|
||||
"cn": "刚开始他就像是白马王子。"
|
||||
},
|
||||
{
|
||||
"c": "He spoke well to begin with, but then started rambling and repeating himself.",
|
||||
"cn": "开始他说得很好,但是后来开始闲扯,一句话翻来覆去地讲。"
|
||||
},
|
||||
{
|
||||
"c": "We'll go slowly to begin with.",
|
||||
"cn": "我们开始时会慢慢来的。"
|
||||
}
|
||||
],
|
||||
"phrases": [],
|
||||
"synos": [
|
||||
{
|
||||
"pos": "",
|
||||
"cn": "以…开始;开始于…",
|
||||
"ws": [
|
||||
"start at",
|
||||
"open with"
|
||||
]
|
||||
}
|
||||
],
|
||||
"relWords": {
|
||||
"root": "",
|
||||
"rels": []
|
||||
},
|
||||
"etymology": []
|
||||
}
|
||||
]
|
||||
@@ -18,6 +18,7 @@ const settingStore = useSettingStore()
|
||||
const {setTheme} = useTheme()
|
||||
|
||||
watch(store.$state, (n: BaseState) => {
|
||||
console.log('watch(store.$state,')
|
||||
localforage.setItem(SAVE_DICT_KEY.key, JSON.stringify({val: shakeCommonDict(n), version: SAVE_DICT_KEY.version}))
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import {onMounted, onUnmounted} from "vue";
|
||||
import {Article} from "@/types/types.ts";
|
||||
import {isReactive, onMounted, onUnmounted, watchEffect} from "vue";
|
||||
import {Article, DictId} from "@/types/types.ts";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {cloneDeep} from "@/utils";
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
@@ -103,6 +103,7 @@ async function add() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function saveArticle(val: Article): boolean {
|
||||
console.log('saveArticle', val)
|
||||
if (val.id) {
|
||||
@@ -135,7 +136,9 @@ function syncBookInMyStudyList(study = false) {
|
||||
let rIndex = base.article.bookList.findIndex(v => v.id === runtimeStore.editDict.id)
|
||||
let temp = cloneDeep(runtimeStore.editDict);
|
||||
console.log(temp)
|
||||
temp.custom = true
|
||||
if (!temp.custom && temp.id !== DictId.articleCollect) {
|
||||
temp.custom = true
|
||||
}
|
||||
temp.length = temp.articles.length
|
||||
if (rIndex > -1) {
|
||||
base.article.bookList[rIndex] = temp
|
||||
@@ -184,31 +187,31 @@ useWindowClick(() => showExport = false)
|
||||
正在添加新文章...
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="import">
|
||||
<BaseButton>导入</BaseButton>
|
||||
<input type="file"
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
@change="e => emit('importData',e)">
|
||||
</div>
|
||||
<div class="export"
|
||||
style="position: relative"
|
||||
@click.stop="null">
|
||||
<BaseButton @click="showExport = true">导出</BaseButton>
|
||||
<MiniDialog
|
||||
v-model="showExport"
|
||||
style="width: 80rem;bottom: calc(100% + 10rem);top:unset;"
|
||||
>
|
||||
<div class="mini-row-title">
|
||||
导出选项
|
||||
</div>
|
||||
<div class="mini-row">
|
||||
<BaseButton @click="emit('exportData',{type:'all',data:[]})">全部文章</BaseButton>
|
||||
</div>
|
||||
<div class="mini-row">
|
||||
<BaseButton @click="emit('exportData',{type:'chapter',data:article})">当前章节</BaseButton>
|
||||
</div>
|
||||
</MiniDialog>
|
||||
</div>
|
||||
<!-- <div class="import">-->
|
||||
<!-- <BaseButton>导入</BaseButton>-->
|
||||
<!-- <input type="file"-->
|
||||
<!-- accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"-->
|
||||
<!-- @change="e => emit('importData',e)">-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="export"-->
|
||||
<!-- style="position: relative"-->
|
||||
<!-- @click.stop="null">-->
|
||||
<!-- <BaseButton @click="showExport = true">导出</BaseButton>-->
|
||||
<!-- <MiniDialog-->
|
||||
<!-- v-model="showExport"-->
|
||||
<!-- style="width: 80rem;bottom: calc(100% + 10rem);top:unset;"-->
|
||||
<!-- >-->
|
||||
<!-- <div class="mini-row-title">-->
|
||||
<!-- 导出选项-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="mini-row">-->
|
||||
<!-- <BaseButton @click="emit('exportData',{type:'all',data:[]})">全部文章</BaseButton>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="mini-row">-->
|
||||
<!-- <BaseButton @click="emit('exportData',{type:'chapter',data:article})">当前章节</BaseButton>-->
|
||||
<!-- </div>-->
|
||||
<!-- </MiniDialog>-->
|
||||
<!-- </div>-->
|
||||
<BaseButton @click="add">新增</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -125,7 +125,7 @@ const {
|
||||
<div class="right flex-[4] shrink-0 pl-4 overflow-auto">
|
||||
<div v-if="selectArticle.id">
|
||||
<div class="en-article-family title text-xl">
|
||||
<div class="text-center text-2xl">
|
||||
<div class="text-center text-2xl" v-if="selectArticle.audioSrc">
|
||||
<audio :src="selectArticle.audioSrc" controls></audio>
|
||||
</div>
|
||||
<div class="text-center text-2xl">{{ selectArticle.title }}</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import {Dict, DictType} from "@/types/types.ts";
|
||||
import {Dict, DictId, DictType} from "@/types/types.ts";
|
||||
import {cloneDeep} from "@/utils";
|
||||
|
||||
import {ElForm, ElFormItem, ElInput, ElSelect, ElOption, FormInstance, FormRules, ElMessage} from "element-plus";
|
||||
@@ -45,8 +45,12 @@ async function onSubmit() {
|
||||
let data: Dict = getDefaultDict(dictForm)
|
||||
let source = [store.article, store.word][props.isBook ? 0 : 1]
|
||||
//任意修改,都将其变为自定义词典
|
||||
if (!data.custom && ![DictId.wordKnown, DictId.wordWrong, DictId.wordCollect, DictId.articleCollect].includes(data.id)) {
|
||||
data.custom = true
|
||||
data.id += '_custom'
|
||||
}
|
||||
|
||||
//todo 可以检查的更准确些,比如json对比
|
||||
data.custom = true
|
||||
if (props.isAdd) {
|
||||
data.id = 'custom-dict-' + Date.now()
|
||||
if (source.bookList.find(v => v.name === data.name)) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {Article} from "@/types/types.ts";
|
||||
import Dialog from "@/pages/pc/components/dialog/Dialog.vue";
|
||||
import {useDisableEventListener} from "@/hooks/event.ts";
|
||||
import EditArticle2 from "@/pages/pc/article/components/EditArticle2.vue";
|
||||
import EditArticle from "@/pages/pc/article/components/EditArticle.vue";
|
||||
import {getDefaultArticle} from "@/types/func.ts";
|
||||
|
||||
interface IProps {
|
||||
@@ -32,7 +32,7 @@ useDisableEventListener(() => props.modelValue)
|
||||
:full-screen="true"
|
||||
>
|
||||
<div class="wrapper">
|
||||
<EditArticle2
|
||||
<EditArticle
|
||||
:article="article"
|
||||
@save="val => emit('save',val)"
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="tsx">
|
||||
import {DictId, Word} from "@/types/types.ts";
|
||||
import {DictId} from "@/types/types.ts";
|
||||
|
||||
import BasePage from "@/pages/pc/components/BasePage.vue";
|
||||
import {computed, onMounted, reactive, shallowReactive} from "vue";
|
||||
@@ -127,7 +127,7 @@ function batchDel(ids: string[]) {
|
||||
syncDictInMyStudyList()
|
||||
}
|
||||
|
||||
function editWord(word: Word) {
|
||||
function editWord(word) {
|
||||
isOperate = true
|
||||
wordForm.id = word.id
|
||||
wordForm.word = word.word
|
||||
|
||||
@@ -213,3 +213,10 @@ export class DictId {
|
||||
static wordKnown = 'wordKnown'
|
||||
static articleCollect = 'articleCollect'
|
||||
}
|
||||
|
||||
export enum DictId2 {
|
||||
wordCollect = 'wordCollect',
|
||||
wordWrong = 'wordWrong',
|
||||
wordKnown = 'wordKnown',
|
||||
articleCollect = 'articleCollect'
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {SAVE_DICT_KEY, SAVE_SETTING_KEY} from "@/utils/const.ts";
|
||||
import {BaseState, DefaultBaseState} from "@/stores/base.ts";
|
||||
import {getDefaultSettingState} from "@/stores/setting.ts";
|
||||
import {Dict, DictResource, DictType} from "@/types/types.ts";
|
||||
import {Dict, DictId, DictResource, DictType} from "@/types/types.ts";
|
||||
import {useRouter} from "vue-router";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {nanoid} from "nanoid";
|
||||
@@ -223,10 +223,10 @@ export function checkAndUpgradeSaveSetting(val: any) {
|
||||
export function shakeCommonDict(n: BaseState): BaseState {
|
||||
let data: BaseState = cloneDeep(n)
|
||||
data.word.bookList.map((v: Dict) => {
|
||||
if (!v.custom) v.words = []
|
||||
if (!v.custom && ![DictId.wordKnown, DictId.wordWrong, DictId.wordCollect].includes(v.id)) v.words = []
|
||||
})
|
||||
data.article.bookList.map((v: Dict) => {
|
||||
if (!v.custom) v.articles = []
|
||||
if (!v.custom && ![DictId.articleCollect].includes(v.id)) v.articles = []
|
||||
})
|
||||
return data
|
||||
}
|
||||
@@ -411,7 +411,7 @@ export async function _getDictDataByUrl(val: DictResource, type: DictType = Dict
|
||||
v.id = nanoid(6)
|
||||
return v
|
||||
}))
|
||||
console.log('articles',articles)
|
||||
console.log('articles', articles)
|
||||
return getDefaultDict({...val, articles})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user