feat:save
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user