diff --git a/src/pages/pc/article/ArticleHomePage.vue b/src/pages/pc/article/ArticleHomePage.vue
index 738c3fb2..0d5802e7 100644
--- a/src/pages/pc/article/ArticleHomePage.vue
+++ b/src/pages/pc/article/ArticleHomePage.vue
@@ -14,6 +14,7 @@ import BaseIcon from "@/components/BaseIcon.vue";
import Dialog from "@/pages/pc/components/dialog/Dialog.vue";
import Input from "@/pages/pc/components/Input.vue";
import {computed} from "vue";
+import Book from "@/pages/pc/components/Book.vue";
const {nav} = useNav()
const base = useBaseStore()
@@ -59,6 +60,7 @@ function addBook() {
function startStudy() {
if (!base.currentBook.name) {
showSearchDialog = true
+ ElMessage.warning('请先选择一本书籍')
return
}
router.push('/study-article')
@@ -92,22 +94,13 @@ function startStudy() {
我的
-
-
-
{{ dict.name }}
-
{{ dict.description }}
-
-
{{ dict.length }}篇
-
-
+
+
@@ -117,15 +110,11 @@ function startStudy() {
-
-
-
{{ dict.name }}
-
{{ dict.description }}
-
-
{{ dict.length }}篇
-
+
diff --git a/src/pages/pc/article/BookDetail.vue b/src/pages/pc/article/BookDetail.vue
index e3f345bc..bea1e262 100644
--- a/src/pages/pc/article/BookDetail.vue
+++ b/src/pages/pc/article/BookDetail.vue
@@ -118,7 +118,7 @@ function formClose() {
{{
- runtimeStore.editDict.id ? '修改' : '添加'
+ runtimeStore.editDict.id ? '修改' : '创建'
}}书籍
diff --git a/src/pages/pc/article/components/EditBook.vue b/src/pages/pc/article/components/EditBook.vue
index 7728f46d..76d4dc80 100644
--- a/src/pages/pc/article/components/EditBook.vue
+++ b/src/pages/pc/article/components/EditBook.vue
@@ -41,34 +41,32 @@ const dictRules = reactive({
async function onSubmit() {
await dictFormRef.validate((valid) => {
if (valid) {
- let data: Dict = cloneDeep({
- ...getDefaultDict(),
- ...dictForm,
- })
+ let data: Dict = getDefaultDict(dictForm)
let source = [store.article, store.word][props.isBook ? 0 : 1]
//任意修改,都将其变为自定义词典
+ //todo 可以检查的更准确些,比如json对比
data.custom = true
-
if (props.isAdd) {
data.id = 'custom-dict-' + Date.now()
- //TODO 允许同名?
if (source.bookList.find(v => v.name === data.name)) {
- return ElMessage.warning('已有相同名称书籍!')
+ ElMessage.warning('已有相同名称!')
+ return
} else {
- source.bookList.push(data)
+ source.bookList.push(cloneDeep(data))
runtimeStore.editDict = data
emit('submit')
ElMessage.success('添加成功')
}
} else {
let rIndex = source.bookList.findIndex(v => v.id === data.id)
+ runtimeStore.editDict = data
if (rIndex > -1) {
source.bookList[rIndex] = cloneDeep(data)
- runtimeStore.editDict = cloneDeep(data)
emit('submit')
ElMessage.success('修改成功')
} else {
- ElMessage.warning('修改失败')
+ source.bookList.push(cloneDeep(data))
+ ElMessage.success('修改成功并加入我的词典')
}
}
console.log('submit!', data)
diff --git a/src/pages/pc/components/Book.vue b/src/pages/pc/components/Book.vue
index ea7a3ef0..af617d72 100644
--- a/src/pages/pc/components/Book.vue
+++ b/src/pages/pc/components/Book.vue
@@ -17,7 +17,7 @@ defineProps<{
{{ item?.name }}
{{ item?.description }}
- {{ item?.words?.length }}{{ quantifier }}
+ {{ item?.length }}{{ quantifier }}
-
-
import {getDefaultWord} from "@/types";
import type {Word} from "@/types";
@@ -37,13 +35,6 @@ let list = $computed({
}
})
-onMounted(() => {
- if (!runtimeStore.editDict.id) {
- router.push("/word")
- }
-})
-
-
const getDefaultFormWord = () => {
return {
id: '',
@@ -181,9 +172,11 @@ function syncDictInMyStudyList(study = false) {
_nextTick(() => {
let rIndex = base.word.bookList.findIndex(v => v.id === runtimeStore.editDict.id)
let temp = cloneDeep(runtimeStore.editDict);
+ console.log(temp)
temp.custom = true
+ temp.length = temp.words.length
if (rIndex > -1) {
- base.word.bookList[base.word.studyIndex] = temp
+ base.word.bookList[rIndex] = temp
if (study) base.word.studyIndex = rIndex
} else {
base.word.bookList.push(temp)
@@ -197,6 +190,7 @@ async function onSubmitWord() {
await wordFormRef.validate((valid) => {
if (valid) {
let data: any = convertToWord(wordForm)
+ //todo 可以检查的更准确些,比如json对比
if (data.id) {
let r = list.find(v => v.id === data.id)
if (r) {
@@ -227,6 +221,9 @@ async function onSubmitWord() {
function delWord(id: string, isBatch = false) {
let rIndex2 = list.findIndex(v => v.id === id)
if (rIndex2 > -1) {
+ if (id === wordForm.id) {
+ wordForm = getDefaultFormWord()
+ }
list.splice(rIndex2, 1)
}
if (!isBatch) syncDictInMyStudyList()
@@ -273,6 +270,10 @@ const showBookDetail = computed(() => {
onMounted(() => {
if (route.query?.isAdd) {
isAdd = true
+ } else {
+ if (!runtimeStore.editDict.id) {
+ router.push("/word")
+ }
}
})
@@ -444,7 +445,7 @@ defineRender(() => {
isAdd ? router.back() : (isEdit = false)}/>
- {runtimeStore.editDict.id ? '修改' : '添加'}词典
+ {runtimeStore.editDict.id ? '修改' : '创建'}词典
diff --git a/src/pages/pc/word/WordHomePage.vue b/src/pages/pc/word/WordHomePage.vue
index 2e71d872..0851da6d 100644
--- a/src/pages/pc/word/WordHomePage.vue
+++ b/src/pages/pc/word/WordHomePage.vue
@@ -45,6 +45,9 @@ useEvent(EventKey.changeDict, () => {
function study() {
if (store.sdict.name) {
nav('study-word', {}, currentStudy)
+ } else {
+ ElMessage.warning('请先选择一本词典')
+ dictListRef.startSearch()
}
}
@@ -74,9 +77,6 @@ async function getDictDetail(val: DictResource) {
let dictListRef = $ref
()
-function addDict() {
-
-}
@@ -152,7 +152,10 @@ function addDict() {