feat:remove unuse components
This commit is contained in:
@@ -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() {
|
||||
我的
|
||||
</div>
|
||||
<div class="grid grid-cols-6 gap-4 mt-4">
|
||||
<div class="book"
|
||||
v-for="dict in store.article.bookList"
|
||||
@click="getBookDetail2(dict)">
|
||||
<div>
|
||||
<div class="name">{{ dict.name }}</div>
|
||||
<div class="desc">{{ dict.description }}</div>
|
||||
</div>
|
||||
<div class="absolute bottom-4 right-4">{{ dict.length }}篇</div>
|
||||
</div>
|
||||
<div class="book" @click="showAddChooseDialog = true">
|
||||
<div class="center h-full">
|
||||
<Icon
|
||||
width="40px"
|
||||
icon="fluent:add-20-filled"/>
|
||||
</div>
|
||||
</div>
|
||||
<Book :is-add="false"
|
||||
quantifier="篇"
|
||||
:item="item"
|
||||
v-for="item in store.article.bookList"
|
||||
@click="getBookDetail2(item)"/>
|
||||
<Book :is-add="true"
|
||||
@click="showAddChooseDialog = true"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -117,15 +110,11 @@ function startStudy() {
|
||||
<BaseIcon @click="showSearchDialog = true" icon="fluent:search-24-regular"/>
|
||||
</div>
|
||||
<div class="grid grid-cols-6 gap-4 mt-4">
|
||||
<div class="book"
|
||||
v-for="dict in enArticle"
|
||||
@click="getBookDetail(dict)">
|
||||
<div class="top">
|
||||
<div class="name">{{ dict.name }}</div>
|
||||
<div class="desc">{{ dict.description }}</div>
|
||||
</div>
|
||||
<div class="absolute bottom-4 right-4">{{ dict.length }}篇</div>
|
||||
</div>
|
||||
<Book :is-add="false"
|
||||
quantifier="篇"
|
||||
:item="item as Dict"
|
||||
v-for="item in enArticle"
|
||||
@click="getBookDetail(item)"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ function formClose() {
|
||||
<div class="flex justify-between items-center relative">
|
||||
<BackIcon class="z-2" @click="isAdd ? $router.back():(isEdit = false)"/>
|
||||
<div class="absolute text-2xl text-align-center w-full">{{
|
||||
runtimeStore.editDict.id ? '修改' : '添加'
|
||||
runtimeStore.editDict.id ? '修改' : '创建'
|
||||
}}书籍
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,34 +41,32 @@ const dictRules = reactive<FormRules>({
|
||||
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)
|
||||
|
||||
@@ -17,7 +17,7 @@ defineProps<{
|
||||
<div>{{ item?.name }}</div>
|
||||
<div class="text-sm line-clamp-3" v-opacity="item.name !== item.description">{{ item?.description }}</div>
|
||||
</div>
|
||||
<div class="absolute bottom-4 right-4">{{ item?.words?.length }}{{ quantifier }}</div>
|
||||
<div class="absolute bottom-4 right-4">{{ item?.length }}{{ quantifier }}</div>
|
||||
</template>
|
||||
<div v-else class="center h-full">
|
||||
<Icon
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script setup lang="tsx">
|
||||
|
||||
|
||||
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(() => {
|
||||
<div class="flex justify-between items-center relative">
|
||||
<BackIcon class="z-2" onClick={() => isAdd ? router.back() : (isEdit = false)}/>
|
||||
<div class="absolute text-2xl text-align-center w-full">
|
||||
{runtimeStore.editDict.id ? '修改' : '添加'}词典
|
||||
{runtimeStore.editDict.id ? '修改' : '创建'}词典
|
||||
</div>
|
||||
</div>
|
||||
<div class="center">
|
||||
@@ -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<any>()
|
||||
|
||||
function addDict() {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -152,7 +152,10 @@ function addDict() {
|
||||
<div class="card flex flex-col">
|
||||
<div class="flex justify-between">
|
||||
<div class="title">我的词典</div>
|
||||
<div class="color-blue cursor-pointer" @click="addDict">创建个人词典</div>
|
||||
<div class="flex gap-4">
|
||||
<div class="color-blue cursor-pointer" v-if="store.word.bookList.length > 3">管理词典</div>
|
||||
<div class="color-blue cursor-pointer" @click="nav('dict-detail', {isAdd: true})">创建个人词典</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-6 gap-4 mt-4">
|
||||
<Book :is-add="false"
|
||||
|
||||
@@ -7,7 +7,7 @@ import PC from "@/pages/pc/index.vue";
|
||||
import ArticleHomePage from "@/pages/pc/article/ArticleHomePage.vue";
|
||||
import HomeIndex from "@/pages/pc/home/HomeIndex.vue";
|
||||
import StudyArticle from "@/pages/pc/article/StudyArticle.vue";
|
||||
import EditWordDict from "@/pages/pc/word/EditWordDict.vue";
|
||||
import DictDetail from "@/pages/pc/word/DictDetail.vue";
|
||||
import StudyWord from "@/pages/pc/word/StudyWord.vue";
|
||||
import EditArticlePage from "@/pages/pc/article/EditArticlePage.vue";
|
||||
import BookDetail from "@/pages/pc/article/BookDetail.vue";
|
||||
@@ -21,7 +21,7 @@ export const routes: RouteRecordRaw[] = [
|
||||
{path: 'home', component: HomeIndex},
|
||||
{path: 'word', component: WordHomePage},
|
||||
{path: 'study-word', component: StudyWord},
|
||||
{path: 'dict-detail', component: EditWordDict},
|
||||
{path: 'dict-detail', component: DictDetail},
|
||||
{path: 'article', component: ArticleHomePage},
|
||||
{path: 'study-article', component: StudyArticle},
|
||||
{path: 'edit-article', component: EditArticlePage},
|
||||
|
||||
@@ -288,7 +288,7 @@ export function _parseLRC(lrc: string): { start: number, end: number, text: stri
|
||||
return parsed;
|
||||
}
|
||||
|
||||
export async function _getDictDataByUrl(val: Dict) {
|
||||
export async function _getDictDataByUrl(val: DictResource) {
|
||||
let dictResourceUrl = `./dicts/${val.language}/word/${val.url}`.replace('.json', '_v2.json');
|
||||
let s = await getDictFile(dictResourceUrl)
|
||||
let words = cloneDeep(s.map(v => {
|
||||
|
||||
Reference in New Issue
Block a user