feat:修改数据结构
This commit is contained in:
@@ -36,7 +36,7 @@ const activeId = $computed(() => {
|
||||
return runtimeStore.editDict.articles?.[chapterIndex]?.id ?? ''
|
||||
})
|
||||
|
||||
function addMyBookList() {
|
||||
function addMyStudyList() {
|
||||
let rIndex = base.article.bookList.findIndex(v => v.name === runtimeStore.editDict.name)
|
||||
if (rIndex > -1) {
|
||||
base.article.studyIndex = rIndex
|
||||
@@ -76,7 +76,7 @@ function formClose() {
|
||||
<div class="flex gap-2">
|
||||
<BaseButton type="info" @click="isEdit = true">编辑</BaseButton>
|
||||
<BaseButton type="info" @click="router.push('batch-edit-article')">文章管理</BaseButton>
|
||||
<BaseButton @click="addMyBookList">学习</BaseButton>
|
||||
<BaseButton @click="addMyStudyList">学习</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-lg ">介绍:{{ runtimeStore.editDict.description }}</div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import {Sort} from "@/types.ts";
|
||||
import MiniDialog from "@/pages/pc/components/dialog/MiniDialog.vue";
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {cloneDeep, reverse, shuffle} from "lodash-es";
|
||||
import {cloneDeep, debounce, reverse, shuffle} from "lodash-es";
|
||||
import Input from "@/pages/pc/components/Input.vue";
|
||||
import PopConfirm from "@/pages/pc/components/PopConfirm.vue";
|
||||
import Empty from "@/components/Empty.vue";
|
||||
@@ -132,7 +132,8 @@ defineRender(
|
||||
>
|
||||
<Input
|
||||
modelValue={searchKey}
|
||||
onUpdate:model-value={e => searchKey = e}
|
||||
onUpdate:modelValue=
|
||||
{debounce(e => searchKey = e)}
|
||||
class="flex-1"/>
|
||||
<BaseButton onClick={() => (showSearchInput = false, searchKey = '')}>取消</BaseButton>
|
||||
</div>
|
||||
|
||||
@@ -25,9 +25,9 @@ watch(() => props.groupByTag, () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div >
|
||||
<div>
|
||||
<div class="flex items-center">
|
||||
<div class="category">{{ category }}:</div>
|
||||
<div class="category shrink-0">{{ category }}:</div>
|
||||
<div class="tags">
|
||||
<div class="tag" :class="i === currentTag &&'active'"
|
||||
@click="currentTag = i"
|
||||
|
||||
@@ -57,6 +57,11 @@ const DefaultFormWord = {
|
||||
phonetic0: '',
|
||||
phonetic1: '',
|
||||
trans: '',
|
||||
sentences: '',
|
||||
phrases: '',
|
||||
synos: '',
|
||||
relWords: '',
|
||||
etymology: '',
|
||||
}
|
||||
let wordForm = $ref(cloneDeep(DefaultFormWord))
|
||||
const wordFormRef = $ref<FormInstance>()
|
||||
@@ -114,13 +119,17 @@ function batchDel(ids: string[]) {
|
||||
ids.map(v => delWord(v))
|
||||
}
|
||||
|
||||
function editWord(word: Word,) {
|
||||
function editWord(word: Word) {
|
||||
wordFormData.type = FormMode.Edit
|
||||
wordFormData.id = word.id
|
||||
wordForm.word = word.word
|
||||
wordForm.phonetic1 = word.phonetic1
|
||||
wordForm.phonetic0 = word.phonetic0
|
||||
wordForm.trans = word.trans.map(v => JSON.stringify(v)).join('\n')
|
||||
wordForm.trans = word.trans.map(v => (v.pos + v.cn).replaceAll('"', '')).join('\n')
|
||||
wordForm.sentences = word.sentences.map(v => (v.c + "\n" + v.cn).replaceAll('"', '')).join('\n\n')
|
||||
wordForm.phrases = word.phrases.map(v => (v.c + "\n" + v.cn).replaceAll('"', '')).join('\n\n')
|
||||
wordForm.synos = word.synos.map(v => (v.pos + v.cn + "\n" + v.ws.join('/')).replaceAll('"', '')).join('\n\n')
|
||||
wordForm.relWords = word.relWords.rels.map(v => (v.pos + "\n" + v.words.map(v => (v.c + "\n" + v.cn))).replaceAll('"', '')).join('\n\n')
|
||||
}
|
||||
|
||||
function addWord() {
|
||||
@@ -152,8 +161,15 @@ function formClose() {
|
||||
else router.back()
|
||||
}
|
||||
|
||||
function addMyBookList() {
|
||||
|
||||
function addMyStudyList() {
|
||||
let rIndex = base.word.bookList.findIndex(v => v.name === runtimeStore.editDict.name)
|
||||
if (rIndex > -1) {
|
||||
base.word.studyIndex = rIndex
|
||||
} else {
|
||||
base.word.bookList.push(runtimeStore.editDict)
|
||||
base.word.studyIndex = base.word.bookList.length - 1
|
||||
}
|
||||
router.back()
|
||||
}
|
||||
|
||||
defineRender(() => {
|
||||
@@ -166,7 +182,7 @@ defineRender(() => {
|
||||
<div class="absolute text-2xl text-align-center w-full">{runtimeStore.editDict.name}</div>
|
||||
<div class="flex gap-2">
|
||||
<BaseButton type="info" onClick={() => isEdit = true}>编辑</BaseButton>
|
||||
<BaseButton onClick={addMyBookList}>学习</BaseButton>
|
||||
<BaseButton onClick={addMyStudyList}>学习</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-lg ">介绍:{runtimeStore.editDict.description}</div>
|
||||
@@ -215,7 +231,7 @@ defineRender(() => {
|
||||
</div>
|
||||
{
|
||||
wordFormData.type ? (
|
||||
<div class="flex-1 ml-4">
|
||||
<div class="flex-1 ml-4 overflow-auto">
|
||||
<div class="common-title">
|
||||
{wordFormData.type === FormMode.Add ? '添加' : '修改'}单词
|
||||
</div>
|
||||
@@ -228,27 +244,67 @@ defineRender(() => {
|
||||
<el-form-item label="单词" prop="word">
|
||||
<el-input
|
||||
modelValue={wordForm.word}
|
||||
onUpdate:model-value={e => wordForm.word = e}
|
||||
onUpdate:modelValue={e => wordForm.word = e}
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="翻译">
|
||||
<el-input
|
||||
modelValue={wordForm.trans}
|
||||
onUpdate:model-value={e => wordForm.trans = e}
|
||||
placeholder="多个翻译请换行"
|
||||
autosize={{minRows: 6, maxRows: 10}}
|
||||
type="textarea"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="音标/发音①">
|
||||
<el-input
|
||||
modelValue={wordForm.phonetic0}
|
||||
onUpdate:model-value={e => wordForm.phonetic0 = e}
|
||||
onUpdate:modelValue={e => wordForm.phonetic0 = e}
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="音标/发音②">
|
||||
<el-input
|
||||
modelValue={wordForm.phonetic1}
|
||||
onUpdate:model-value={e => wordForm.phonetic1 = e}/>
|
||||
onUpdate:modelValue={e => wordForm.phonetic1 = e}/>
|
||||
</el-form-item>
|
||||
<el-form-item label="翻译">
|
||||
<el-input
|
||||
modelValue={wordForm.trans}
|
||||
onUpdate:modelValue={e => wordForm.trans = e}
|
||||
placeholder="一行一个翻译,前面词性,后面内容(n.取消);多个翻译请换行"
|
||||
autosize={{minRows: 6, maxRows: 10}}
|
||||
type="textarea"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="例句">
|
||||
<el-input
|
||||
modelValue={wordForm.sentences}
|
||||
onUpdate:modelValue={e => wordForm.sentences = e}
|
||||
placeholder="一行原文,一行译文;多个请换两行"
|
||||
autosize={{minRows: 6, maxRows: 10}}
|
||||
type="textarea"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="短语">
|
||||
<el-input
|
||||
modelValue={wordForm.phrases}
|
||||
onUpdate:modelValue={e => wordForm.phrases = e}
|
||||
placeholder="一行原文,一行译文;多个请换两行"
|
||||
autosize={{minRows: 6, maxRows: 10}}
|
||||
type="textarea"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="同义词">
|
||||
<el-input
|
||||
modelValue={wordForm.synos}
|
||||
onUpdate:modelValue={e => wordForm.synos = e}
|
||||
placeholder="一行原文,一行译文;多个请换两行"
|
||||
autosize={{minRows: 6, maxRows: 10}}
|
||||
type="textarea"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="同根词">
|
||||
<el-input
|
||||
modelValue={wordForm.relWords}
|
||||
onUpdate:modelValue={e => wordForm.relWords = e}
|
||||
placeholder="一行原文,一行译文;多个请换两行"
|
||||
autosize={{minRows: 6, maxRows: 10}}
|
||||
type="textarea"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="词源">
|
||||
<el-input
|
||||
modelValue={wordForm.etymology}
|
||||
onUpdate:modelValue={e => wordForm.etymology = e}
|
||||
placeholder="一行原文,一行译文;多个请换两行"
|
||||
autosize={{minRows: 6, maxRows: 10}}
|
||||
type="textarea"/>
|
||||
</el-form-item>
|
||||
<div class="center">
|
||||
<el-button
|
||||
|
||||
@@ -6,7 +6,7 @@ import "vue-activity-calendar/style.css";
|
||||
import {useRouter} from "vue-router";
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
import Dialog from "@/pages/pc/components/dialog/Dialog.vue";
|
||||
import {_getAccomplishDate, _getAccomplishDays, useNav} from "@/utils";
|
||||
import {_getAccomplishDate, _getAccomplishDays, _getDictDataByUrl, useNav} from "@/utils";
|
||||
import BasePage from "@/pages/pc/components/BasePage.vue";
|
||||
import {Dict, DictResource, getDefaultDict} from "@/types.ts";
|
||||
import {onMounted} from "vue";
|
||||
@@ -18,6 +18,7 @@ import DictGroup from "@/pages/pc/components/list/DictGroup.vue";
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {getArticleBookDataByUrl} from "@/utils/article.ts";
|
||||
import Typing from "@/pages/pc/word/components/Typing.vue";
|
||||
|
||||
const store = useBaseStore()
|
||||
const router = useRouter()
|
||||
@@ -57,18 +58,19 @@ function changePerDayStudyNumber() {
|
||||
}
|
||||
|
||||
function selectDict(e) {
|
||||
console.log(e)
|
||||
console.log(e.dict)
|
||||
getDictDetail(e.dict)
|
||||
}
|
||||
|
||||
async function goDictDetail2(val: Dict) {
|
||||
runtimeStore.editDict = cloneDeep(val)
|
||||
nav('edit-word-dict', {})
|
||||
nav('dict-detail', {})
|
||||
}
|
||||
|
||||
async function getBookDetail(val: DictResource) {
|
||||
let r = await getArticleBookDataByUrl(val)
|
||||
async function getDictDetail(val: DictResource) {
|
||||
let r = await _getDictDataByUrl(val)
|
||||
runtimeStore.editDict = cloneDeep(r)
|
||||
nav('book-detail', {})
|
||||
nav('dict-detail', {})
|
||||
}
|
||||
|
||||
let dictListRef = $ref<any>()
|
||||
@@ -81,7 +83,7 @@ function addDict() {
|
||||
|
||||
<template>
|
||||
<BasePage>
|
||||
<div class="card flex gap-10">
|
||||
<div class="card flex gap-10" v-loading="!store.load">
|
||||
<div class="flex-1 flex flex-col gap-2">
|
||||
<div class="flex">
|
||||
<div class="bg-slate-200 px-3 h-14 rounded-md flex items-center">
|
||||
|
||||
Reference in New Issue
Block a user