feat:save
This commit is contained in:
@@ -18,7 +18,6 @@ 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}))
|
||||
})
|
||||
|
||||
|
||||
21
src/global.d.ts
vendored
21
src/global.d.ts
vendored
@@ -3,16 +3,25 @@ import {cloneDeep} from "@/utils"
|
||||
export {}
|
||||
|
||||
declare global {
|
||||
interface Console {
|
||||
json(v: any): void
|
||||
}
|
||||
|
||||
interface Console {
|
||||
parse(v: any): void
|
||||
|
||||
json(v: any, space: number): void
|
||||
}
|
||||
}
|
||||
console.json = function (v: any) {
|
||||
console.log(cloneDeep(v))
|
||||
console.json = function (v: any, space = 0) {
|
||||
const json = JSON.stringify(
|
||||
v,
|
||||
(key, value) => {
|
||||
if (Array.isArray(value)) {
|
||||
return `__ARRAY__${JSON.stringify(value)}`;
|
||||
}
|
||||
return value;
|
||||
},
|
||||
space
|
||||
).replace(/"__ARRAY__(\[.*?\])"/g, (_, arr) => arr);
|
||||
console.log(json);
|
||||
return json;
|
||||
}
|
||||
console.parse = function (v: any) {
|
||||
console.log(JSON.parse(v))
|
||||
|
||||
@@ -546,8 +546,11 @@ export function usePlaySentenceAudio() {
|
||||
ref.currentTime = start
|
||||
ref.play()
|
||||
let end = sentence.audioPosition?.[1]
|
||||
console.log(sentence.audioPosition,(end - start) * 1000)
|
||||
|
||||
if (end && end !== -1) {
|
||||
timer = setTimeout(() => {
|
||||
console.log('停')
|
||||
ref.pause()
|
||||
}, (end - start) * 1000)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import {isReactive, onMounted, onUnmounted, watchEffect} from "vue";
|
||||
import {onMounted, onUnmounted} from "vue";
|
||||
import {Article, DictId} from "@/types/types.ts";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {cloneDeep} from "@/utils";
|
||||
import {_nextTick, cloneDeep} from "@/utils";
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
|
||||
import List from "@/pages/pc/components/list/List.vue";
|
||||
@@ -11,10 +11,8 @@ import {useDisableEventListener, useWindowClick} from "@/hooks/event.ts";
|
||||
import {MessageBox} from "@/utils/MessageBox.tsx";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {nanoid} from "nanoid";
|
||||
import MiniDialog from "@/pages/pc/components/dialog/MiniDialog.vue";
|
||||
import EditArticle2 from "@/pages/pc/article/components/EditArticle2.vue";
|
||||
import EditArticle from "@/pages/pc/article/components/EditArticle.vue";
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
import {_nextTick} from "@/utils";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {getDefaultArticle} from "@/types/func.ts";
|
||||
|
||||
@@ -105,7 +103,6 @@ async function add() {
|
||||
|
||||
|
||||
function saveArticle(val: Article): boolean {
|
||||
console.log('saveArticle', val)
|
||||
if (val.id) {
|
||||
let rIndex = runtimeStore.editDict.articles.findIndex(v => v.id === val.id)
|
||||
if (rIndex > -1) {
|
||||
@@ -135,7 +132,6 @@ function syncBookInMyStudyList(study = false) {
|
||||
_nextTick(() => {
|
||||
let rIndex = base.article.bookList.findIndex(v => v.id === runtimeStore.editDict.id)
|
||||
let temp = cloneDeep(runtimeStore.editDict);
|
||||
console.log(temp)
|
||||
if (!temp.custom && temp.id !== DictId.articleCollect) {
|
||||
temp.custom = true
|
||||
}
|
||||
@@ -215,7 +211,7 @@ useWindowClick(() => showExport = false)
|
||||
<BaseButton @click="add">新增</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
<EditArticle2
|
||||
<EditArticle
|
||||
ref="editArticleRef"
|
||||
type="batch"
|
||||
@save="saveArticle"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import EditArticle2 from "@/pages/pc/article/components/EditArticle2.vue";
|
||||
import EditArticle from "@/pages/pc/article/components/EditArticle.vue";
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
</script>
|
||||
|
||||
@@ -10,7 +10,7 @@ import BaseIcon from "@/components/BaseIcon.vue";
|
||||
title="返回"
|
||||
@click="$router.back"
|
||||
icon="formkit:left"/>
|
||||
<EditArticle2 class="vue"></EditArticle2>
|
||||
<EditArticle class="vue"></EditArticle>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
@@ -14,6 +14,7 @@ import * as Comparison from "string-comparison"
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
import Dialog from "@/pages/pc/components/dialog/Dialog.vue";
|
||||
import {getDefaultArticle} from "@/types/func.ts";
|
||||
import copy from "copy-to-clipboard";
|
||||
|
||||
interface IProps {
|
||||
article?: Article,
|
||||
@@ -45,7 +46,7 @@ watch(() => props.article, val => {
|
||||
editArticle = cloneDeep(val)
|
||||
progress = 0
|
||||
failCount = 0
|
||||
apply(false)
|
||||
// apply(false)
|
||||
}, {immediate: true})
|
||||
|
||||
watch(() => editArticle.text, (s) => {
|
||||
@@ -139,6 +140,9 @@ function save(option: 'save' | 'saveAndNext') {
|
||||
return resolve(false)
|
||||
}
|
||||
|
||||
let d = cloneDeep(editArticle)
|
||||
delete d.sections
|
||||
copy(console.json(d, 2))
|
||||
const saveTemp = () => {
|
||||
emit(option as any, editArticle)
|
||||
return resolve(true)
|
||||
@@ -389,7 +393,7 @@ function setStartTime(val: Sentence, i: number, j: number) {
|
||||
</ElUpload>
|
||||
<audio ref="audioRef" :src="editArticle.audioSrc" controls></audio>
|
||||
</div>
|
||||
<template v-if="editArticle.sections.length">
|
||||
<template v-if="editArticle?.sections?.length">
|
||||
<div class="flex-1 overflow-auto flex flex-col">
|
||||
<div class="flex justify-between bg-black/10 py-2">
|
||||
<div class="center flex-[7]">内容</div>
|
||||
|
||||
Reference in New Issue
Block a user