From 3b84a340aa3e658d433d29ad074e9eb5bea64c87 Mon Sep 17 00:00:00 2001 From: lyc Date: Thu, 26 Sep 2024 16:38:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E8=AF=BE=E9=87=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E7=AB=A0=E8=8A=82=EF=BC=8C=E6=95=99=E6=9D=90edit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/store.js | 4 +- .../src/components/choose-textbook/index.vue | 2 + src/renderer/src/store/modules/tool.js | 4 +- src/renderer/src/views/prepare/index.vue | 6 +- .../src/views/tool/components/homework.vue | 29 ++-- .../src/views/tool/components/lesson.vue | 141 +++++------------- 6 files changed, 61 insertions(+), 125 deletions(-) diff --git a/src/main/store.js b/src/main/store.js index 0607e19..5cc0f1c 100644 --- a/src/main/store.js +++ b/src/main/store.js @@ -14,14 +14,14 @@ const defaultData = { isPdfWin: false, // pdf窗口是否打开 isToolWin: false, // 工具窗口是否打开 curSubjectNode: { - data: {}, // 当前教材节点 (包含当前教材 单元) querySearch: {} // 查询资源所需参数 }, - subject: { + subject: { // 不走同步 Pinia bookList: null, // 教材列表 curBook: null, // 当前选中的教材 curNode: null, // 当前选中的节点 defaultExpandedKeys: [], //展开的节点 + subjectTree: [] // "树结构" 章节 } }, local: { // 本地(永久localStorage) diff --git a/src/renderer/src/components/choose-textbook/index.vue b/src/renderer/src/components/choose-textbook/index.vue index 007bcf1..028cd02 100644 --- a/src/renderer/src/components/choose-textbook/index.vue +++ b/src/renderer/src/components/choose-textbook/index.vue @@ -181,6 +181,8 @@ onMounted( async () => { // 章节"树" treeData.value = useSubject.getTreeData(curBook.data.id) + sessionStore.set('subject.subjectTree',useSubject.getTreeData(curBook.data.id)) + nextTick(() =>{ // 默认展开 选中 if(sessionStore.get('subject.curNode')){ diff --git a/src/renderer/src/store/modules/tool.js b/src/renderer/src/store/modules/tool.js index 8c818cd..1facd80 100644 --- a/src/renderer/src/store/modules/tool.js +++ b/src/renderer/src/store/modules/tool.js @@ -6,6 +6,9 @@ import { sessionStore } from '@/utils/store' // 默认数据 const defData = sessionStore.store || {} +const exArrs = ['subject'] +exArrs.forEach(k => Object.keys(defData).includes(k) && (delete defData[k])) + // 延时 const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) @@ -16,7 +19,6 @@ export const useToolState = defineStore('tool', { isPdfWin: false, // pdf窗口是否打开 isToolWin: false, // 工具窗口是否打开 curSubjectNode: { - data: {}, // 当前教材节点 (包含当前教材 单元) querySearch: {} // 查询资源所需参数 }, ...defData // 默认数据-覆盖上面的配置(不要删除, 会导致新窗口-获取状态失败) diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index a5575a9..a872138 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -583,11 +583,7 @@ export default { this.uploadData.levelSecondId = cata[1] this.uploadData.levelThirdId = cata[2] this.uploadData.textbookId = data.textBook.curBookId - toolStore.curSubjectNode.data = data - // 不要同时修改共享数据,这样只会触发一次 - this.$nextTick(() => { - toolStore.curSubjectNode.querySearch = this.uploadData - }) + toolStore.curSubjectNode.querySearch = this.uploadData this.initHomeWork() await this.asyncAllFile() }, diff --git a/src/renderer/src/views/tool/components/homework.vue b/src/renderer/src/views/tool/components/homework.vue index f9287cc..2599315 100644 --- a/src/renderer/src/views/tool/components/homework.vue +++ b/src/renderer/src/views/tool/components/homework.vue @@ -62,7 +62,7 @@ 选择目录
- +
@@ -70,19 +70,20 @@ diff --git a/src/renderer/src/views/tool/components/lesson.vue b/src/renderer/src/views/tool/components/lesson.vue index a111467..687693c 100644 --- a/src/renderer/src/views/tool/components/lesson.vue +++ b/src/renderer/src/views/tool/components/lesson.vue @@ -2,7 +2,7 @@ -- 2.44.0.windows.1