From a90365e6a6b861228ecbc5a38837b4cbf7bfd7a7 Mon Sep 17 00:00:00 2001 From: zyronon Date: Sun, 20 Jul 2025 23:16:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/article.ts | 34 +++++------ src/pages/pc/article/BookDetail.vue | 3 +- src/pages/pc/word/EditWordDict.vue | 2 +- src/pages/pc/word/components/Typing.vue | 6 +- src/types.ts | 77 ++++++------------------- 5 files changed, 37 insertions(+), 85 deletions(-) diff --git a/src/hooks/article.ts b/src/hooks/article.ts index c388f3a5..3e379cc0 100644 --- a/src/hooks/article.ts +++ b/src/hooks/article.ts @@ -1,4 +1,4 @@ -import {Article, ArticleWord, DefaultArticleWord, DictType, Sentence} from "@/types.ts"; +import {Article, ArticleWord, DictType, getDefaultArticleWord, Sentence} from "@/types.ts"; import {cloneDeep} from "lodash-es"; import nlp from "compromise/one"; import {usePlayWordAudio} from "@/hooks/sound.ts"; @@ -82,13 +82,12 @@ export function genArticleSectionData(article: Article): number { }) } - let word3: ArticleWord = { - ...DefaultArticleWord, + let word3: ArticleWord = getDefaultArticleWord({ word: pre, nextSpace: false, isSymbol: true, symbolPosition: '' - }; + }); // console.log('rrr', item) // console.log('nearSymbolPosition', nearSymbolPosition) if (nearSymbolPosition === 'end' || nearSymbolPosition === null) { @@ -126,8 +125,7 @@ export function genArticleSectionData(article: Article): number { case keyboardMap.Slash: case keyboardMap.Exclamation: sentence.words[sentence.words.length - 1].nextSpace = false - let word2 = cloneDeep({ - ...DefaultArticleWord, + let word2 = getDefaultArticleWord({ word: post, isSymbol: true, nextSpace @@ -155,8 +153,7 @@ export function genArticleSectionData(article: Article): number { //所以需要检测一下 if (sentence.words.length) { sentence.words[sentence.words.length - 1].nextSpace = true - let word3 = cloneDeep({ - ...DefaultArticleWord, + let word3 = getDefaultArticleWord({ word: 'placeholder', isSymbol: true, nextSpace: false, @@ -173,8 +170,7 @@ export function genArticleSectionData(article: Article): number { }) } else { sentence.words[sentence.words.length - 1].nextSpace = false - let word3 = cloneDeep({ - ...DefaultArticleWord, + let word3 = getDefaultArticleWord({ word: post, isSymbol: true, nextSpace: false, @@ -193,7 +189,7 @@ export function genArticleSectionData(article: Article): number { checkQuote(pre, index) } - let word = cloneDeep({...DefaultArticleWord, word: v.text, nextSpace: true}); + let word = getDefaultArticleWord({word: v.text, nextSpace: true}); sentence.words.push(word) let post: string = v.post @@ -346,13 +342,12 @@ Its none of your business, the young man said rudely. This is a private conversa }) } - let word3: ArticleWord = { - ...DefaultArticleWord, + let word3: ArticleWord = getDefaultArticleWord({ word: pre, nextSpace: false, isSymbol: true, symbolPosition: '' - }; + }); // console.log('rrr', item) // console.log('nearSymbolPosition', nearSymbolPosition) if (nearSymbolPosition === 'end' || nearSymbolPosition === null) { @@ -390,8 +385,7 @@ Its none of your business, the young man said rudely. This is a private conversa case keyboardMap.Slash: case keyboardMap.Exclamation: sentence.words[sentence.words.length - 1].nextSpace = false - let word2 = cloneDeep({ - ...DefaultArticleWord, + let word2 = getDefaultArticleWord({ word: post, isSymbol: true, nextSpace @@ -419,8 +413,7 @@ Its none of your business, the young man said rudely. This is a private conversa //所以需要检测一下 if (sentence.words.length) { sentence.words[sentence.words.length - 1].nextSpace = true - let word3 = cloneDeep({ - ...DefaultArticleWord, + let word3 = getDefaultArticleWord({ word: 'placeholder', isSymbol: true, nextSpace: false, @@ -437,8 +430,7 @@ Its none of your business, the young man said rudely. This is a private conversa }) } else { sentence.words[sentence.words.length - 1].nextSpace = false - let word3 = cloneDeep({ - ...DefaultArticleWord, + let word3 = getDefaultArticleWord({ word: post, isSymbol: true, nextSpace: false, @@ -457,7 +449,7 @@ Its none of your business, the young man said rudely. This is a private conversa checkQuote(pre, index) } - let word = cloneDeep({...DefaultArticleWord, word: v.text, nextSpace: true}); + let word = getDefaultArticleWord({word: v.text, nextSpace: true}); sentence.words.push(word) let post: string = v.post diff --git a/src/pages/pc/article/BookDetail.vue b/src/pages/pc/article/BookDetail.vue index 52eb2444..6f06f590 100644 --- a/src/pages/pc/article/BookDetail.vue +++ b/src/pages/pc/article/BookDetail.vue @@ -56,10 +56,9 @@ onMounted(() => { isAdd = true }else { if (!runtimeStore.editDict.id) { - router.push("/") + router.push("/article") } } - }) function formClose() { diff --git a/src/pages/pc/word/EditWordDict.vue b/src/pages/pc/word/EditWordDict.vue index d309a033..ea0441db 100644 --- a/src/pages/pc/word/EditWordDict.vue +++ b/src/pages/pc/word/EditWordDict.vue @@ -35,7 +35,7 @@ let list = $computed({ onMounted(() => { if (!runtimeStore.editDict.id) { - router.push("/") + router.push("/word") } }) diff --git a/src/pages/pc/word/components/Typing.vue b/src/pages/pc/word/components/Typing.vue index 3bd17c43..deda6821 100644 --- a/src/pages/pc/word/components/Typing.vue +++ b/src/pages/pc/word/components/Typing.vue @@ -1,5 +1,5 @@