From b7d6e4e09cc596ad6da78665ec2405c8b211cf13 Mon Sep 17 00:00:00 2001 From: Zyronon Date: Sat, 13 Dec 2025 16:54:25 +0800 Subject: [PATCH] wip --- components.d.ts | 1 + src/components/BaseTable.vue | 271 +++++++++++++++-------------- src/components/BaseTable2.vue | 313 ++++++++++++++++++++++++++++++++++ src/config/env.ts | 2 +- src/pages/word/DictDetail.vue | 49 +++--- src/pages/word/WordsPage.vue | 3 +- 6 files changed, 486 insertions(+), 153 deletions(-) create mode 100644 src/components/BaseTable2.vue diff --git a/components.d.ts b/components.d.ts index 80da93f6..74f16838 100644 --- a/components.d.ts +++ b/components.d.ts @@ -18,6 +18,7 @@ declare module 'vue' { BaseList: typeof import('./src/components/list/BaseList.vue')['default'] BasePage: typeof import('./src/components/BasePage.vue')['default'] BaseTable: typeof import('./src/components/BaseTable.vue')['default'] + BaseTable2: typeof import('./src/components/BaseTable2.vue')['default'] Book: typeof import('./src/components/Book.vue')['default'] ChannelIcons: typeof import('./src/components/ChannelIcons/ChannelIcons.vue')['default'] Checkbox: typeof import('./src/components/base/checkbox/Checkbox.vue')['default'] diff --git a/src/components/BaseTable.vue b/src/components/BaseTable.vue index 65137fb2..e62688e7 100644 --- a/src/components/BaseTable.vue +++ b/src/components/BaseTable.vue @@ -1,11 +1,11 @@ diff --git a/src/config/env.ts b/src/config/env.ts index ec9a3863..5ed48642 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -19,7 +19,7 @@ export const ENV = Object.assign(map['DEV'], common) export let AppEnv = { TOKEN: localStorage.getItem('token') ?? '', - IS_OFFICIAL: true, + IS_OFFICIAL: false, IS_LOGIN: false, CAN_REQUEST: false } diff --git a/src/pages/word/DictDetail.vue b/src/pages/word/DictDetail.vue index 5c5aa40c..a6eca9c9 100644 --- a/src/pages/word/DictDetail.vue +++ b/src/pages/word/DictDetail.vue @@ -34,7 +34,6 @@ const base = useBaseStore() const router = useRouter() const route = useRoute() const isMob = isMobile() - let loading = $ref(false) let list = $computed({ @@ -65,8 +64,8 @@ let wordForm = $ref(getDefaultFormWord()) let wordFormRef = $ref() const wordRules = reactive({ word: [ - {required: true, message: '请输入单词', trigger: 'blur'}, - {max: 100, message: '名称不能超过100个字符', trigger: 'blur'}, + { required: true, message: '请输入单词', trigger: 'blur' }, + { max: 100, message: '名称不能超过100个字符', trigger: 'blur' }, ], }) let studyLoading = $ref(false) @@ -201,10 +200,9 @@ onMounted(async () => { let r = await _getDictDataByUrl(runtimeStore.editDict) runtimeStore.editDict = r } - if (base.word.bookList.find(book => book.id === runtimeStore.editDict.id)) { if (AppEnv.CAN_REQUEST) { - let res = await detail({id: runtimeStore.editDict.id}) + let res = await detail({ id: runtimeStore.editDict.id }) if (res.success) { runtimeStore.editDict.statistics = res.data.statistics if (res.data.words.length) { @@ -213,6 +211,7 @@ onMounted(async () => { } } } + list2 = runtimeStore.editDict.words loading = false } } @@ -227,7 +226,7 @@ let showPracticeSettingDialog = $ref(false) const store = useBaseStore() const settingStore = useSettingStore() -const {nav} = useNav() +const { nav } = useNav() //todo 可以和首页合并 async function startPractice(query = {}) { @@ -244,7 +243,7 @@ async function startPractice(query = {}) { wordPracticeMode: settingStore.wordPracticeMode }) let currentStudy = getCurrentStudyWord() - nav('practice-words/' + store.sdict.id, query, {taskWords: currentStudy}) + nav('practice-words/' + store.sdict.id, query, { taskWords: currentStudy }) } async function addMyStudyList() { @@ -263,7 +262,6 @@ async function startTest() { await base.changeDict(runtimeStore.editDict) loading = false nav('word-test/' + store.sdict.id) - } let exportLoading = $ref(false) @@ -279,7 +277,7 @@ function importData(e) { let data = s.target.result; importLoading = true const XLSX = await loadJsLib('XLSX', LIB_JS_URL.XLSX); - let workbook = XLSX.read(data, {type: 'binary'}); + let workbook = XLSX.read(data, { type: 'binary' }); let res: any[] = XLSX.utils.sheet_to_json(workbook.Sheets['Sheet1']); if (res.length) { let words = res.map(v => { @@ -386,7 +384,6 @@ function searchWord() { console.log('wordForm.word', wordForm.word) } - watch(() => loading, (val) => { if (!val) return _nextTick(async () => { @@ -398,7 +395,7 @@ watch(() => loading, (val) => { tour.addStep({ id: 'step3', text: '点击这里开始学习', - attachTo: {element: '#study', on: 'bottom'}, + attachTo: { element: '#study', on: 'bottom' }, buttons: [ { text: `下一步(3/${TourConfig.total})`, @@ -413,7 +410,7 @@ watch(() => loading, (val) => { tour.addStep({ id: 'step4', text: '这里可以选择学习模式、设置学习数量、修改学习进度', - attachTo: {element: '#mode', on: 'bottom'}, + attachTo: { element: '#mode', on: 'bottom' }, beforeShowPromise() { return new Promise((resolve) => { const timer = setInterval(() => { @@ -429,7 +426,7 @@ watch(() => loading, (val) => { text: `下一步(4/${TourConfig.total})`, action() { tour.next() - startPractice({guide: 1}) + startPractice({ guide: 1 }) } } ] @@ -442,6 +439,18 @@ watch(() => loading, (val) => { }, 500) }) +let pageNo = $ref(1) +let pageSize = $ref(50) +let list2 = $ref([]) + +async function requestList({ pageNo, pageSize }) { + if (AppEnv.CAN_REQUEST) { + + } else { + return list2.slice((pageNo - 1) * pageSize, (pageNo - 1) * pageSize + pageSize) + } +} + defineRender(() => { return ( @@ -484,7 +493,9 @@ defineRender(() => { list = e} del={delWord} @@ -564,42 +575,42 @@ defineRender(() => { modelValue={wordForm.trans} onUpdate:modelValue={e => wordForm.trans = e} placeholder="一行一个翻译,前面词性,后面内容(如n.取消);多个翻译请换行" - autosize={{minRows: 6, maxRows: 10}}/> + autosize={{ minRows: 6, maxRows: 10 }}/>