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 @@ 选择目录