Develop dictionary management function
This commit is contained in:
@@ -16,9 +16,7 @@ import {$ref} from "vue/macros";
|
||||
import {MessageBox} from "@/utils/MessageBox.tsx";
|
||||
import {getSplitTranslateText} from "@/hooks/article.ts";
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {h, watch} from "vue";
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
import {watch} from "vue";
|
||||
import Empty from "@/components/Empty.vue";
|
||||
|
||||
interface IProps {
|
||||
|
||||
@@ -6,15 +6,15 @@ import BaseButton from "@/components/BaseButton.vue";
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
import {$computed, $ref} from "vue/macros";
|
||||
import {$ref} from "vue/macros";
|
||||
import List from "@/components/list/List.vue";
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
import Dialog from "@/components/dialog/Dialog.vue";
|
||||
import EditArticle from "@/components/article/EditArticle.vue";
|
||||
import {emitter, EventKey} from "@/utils/eventBus.ts";
|
||||
import {useDisableEventListener} from "@/hooks/event.ts";
|
||||
import {MessageBox} from "@/utils/MessageBox.tsx";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {nanoid} from "nanoid";
|
||||
|
||||
const base = useBaseStore()
|
||||
const runtimeStore = useRuntimeStore()
|
||||
@@ -154,7 +154,7 @@ function importData(e: Event) {
|
||||
if (!obj.articles[i]?.useTranslateType) obj.articles[i].useTranslateType = 'none'
|
||||
if (!obj.articles[i]?.textAllWords) obj.articles[i].textAllWords = []
|
||||
if (!obj.articles[i]?.sections) obj.articles[i].sections = []
|
||||
obj.articles[i].id = uuidv4()
|
||||
obj.articles[i].id = nanoid(6)
|
||||
}
|
||||
obj.sort = Sort.normal
|
||||
obj.type = DictType.customArticle
|
||||
@@ -210,9 +210,9 @@ function saveArticle(val: Article): boolean {
|
||||
ElMessage.error('已存在同名文章!')
|
||||
return false
|
||||
}
|
||||
val.id = uuidv4()
|
||||
val.id = nanoid(6)
|
||||
runtimeStore.editDict.articles.push(val)
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
listEl.scrollBottom()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,17 +4,16 @@ import {onMounted, onUnmounted} from "vue";
|
||||
import {Article, DefaultArticle, DictType, Sort} from "@/types.ts";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
import {$computed, $ref} from "vue/macros";
|
||||
import {$ref} from "vue/macros";
|
||||
import List from "@/components/list/List.vue";
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
import Dialog from "@/components/dialog/Dialog.vue";
|
||||
import EditArticle from "@/components/article/EditArticle.vue";
|
||||
import {emitter, EventKey} from "@/utils/eventBus.ts";
|
||||
import {useDisableEventListener} from "@/hooks/event.ts";
|
||||
import {MessageBox} from "@/utils/MessageBox.tsx";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {nanoid} from "nanoid";
|
||||
|
||||
const base = useBaseStore()
|
||||
const runtimeStore = useRuntimeStore()
|
||||
@@ -154,7 +153,7 @@ function importData(e: Event) {
|
||||
if (!obj.articles[i]?.useTranslateType) obj.articles[i].useTranslateType = 'none'
|
||||
if (!obj.articles[i]?.textAllWords) obj.articles[i].textAllWords = []
|
||||
if (!obj.articles[i]?.sections) obj.articles[i].sections = []
|
||||
obj.articles[i].id = uuidv4()
|
||||
obj.articles[i].id = nanoid(6)
|
||||
}
|
||||
obj.sort = Sort.normal
|
||||
obj.type = DictType.customArticle
|
||||
@@ -210,7 +209,7 @@ function saveArticle(val: Article): boolean {
|
||||
ElMessage.error('已存在同名文章!')
|
||||
return false
|
||||
}
|
||||
val.id = uuidv4()
|
||||
val.id = nanoid(6)
|
||||
runtimeStore.editDict.articles.push(val)
|
||||
setTimeout(()=>{
|
||||
listEl.scrollBottom()
|
||||
|
||||
@@ -8,7 +8,6 @@ import {$computed, $ref} from "vue/macros";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {Icon} from '@iconify/vue';
|
||||
import DictGroup from "@/components/toolbar/DictGroup.vue";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {ActivityCalendar} from "vue-activity-calendar";
|
||||
import "vue-activity-calendar/style.css";
|
||||
import ChapterList from "@/components/list/ChapterList.vue";
|
||||
@@ -88,7 +87,7 @@ async function selectDict(val: { dict: DictResource | Dict, index: number }) {
|
||||
let r = await fetch(url)
|
||||
let v = await r.json()
|
||||
runtimeStore.editDict.articles = cloneDeep(v.map(s => {
|
||||
s.id = uuidv4()
|
||||
s.id = nanoid(6)
|
||||
return s
|
||||
}))
|
||||
}
|
||||
@@ -643,7 +642,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">{{dictIsArticle?'句子':'单词'}}发音</div>
|
||||
<div class="label">{{ dictIsArticle ? '句子' : '单词' }}发音</div>
|
||||
<div class="option">
|
||||
<el-radio-group v-model="settingStore.wordSoundType">
|
||||
<el-radio label="us" size="large">美音</el-radio>
|
||||
@@ -652,7 +651,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">{{dictIsArticle?'句子':'单词'}}自动发音</div>
|
||||
<div class="label">{{ dictIsArticle ? '句子' : '单词' }}自动发音</div>
|
||||
<div class="option">
|
||||
<el-switch v-model="settingStore.wordSound"
|
||||
inline-prompt
|
||||
|
||||
Reference in New Issue
Block a user