From 7e18f2e9d9fe440be662f64b26bd3fc1a7cec678 Mon Sep 17 00:00:00 2001 From: zdg Date: Mon, 4 Nov 2024 16:29:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?ppt=E4=B8=8A=E8=AF=BE-=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/store.js | 4 +- .../src/components/set-homework/index.vue | 2 +- src/renderer/src/plugins/shareStore.js | 6 +- src/renderer/src/store/modules/tool.js | 2 +- .../src/views/fullScreenPdf/index.vue | 6 +- src/renderer/src/views/prepare/index.vue | 4 + .../src/views/tool/components/side.vue | 88 +++++++++++++++++-- src/renderer/src/views/tool/sphere.vue | 11 +-- 8 files changed, 101 insertions(+), 22 deletions(-) diff --git a/src/main/store.js b/src/main/store.js index a34bd90..22e61dd 100644 --- a/src/main/store.js +++ b/src/main/store.js @@ -23,7 +23,9 @@ const defaultData = { curNode: null, // 当前选中的节点 defaultExpandedKeys: [], //展开的节点 subjectTree: [] // "树结构" 章节 - } + }, + env: {}, // 不走同步 Pinia - 变量 + curr: {} // 不走同步 Pinia - 当前信息 }, local: { // 本地(永久localStorage) }, diff --git a/src/renderer/src/components/set-homework/index.vue b/src/renderer/src/components/set-homework/index.vue index b890ff3..a237a80 100644 --- a/src/renderer/src/components/set-homework/index.vue +++ b/src/renderer/src/components/set-homework/index.vue @@ -213,7 +213,7 @@ const delStudent = (index) => { const onSubmit = (formEl) => { if (!formEl) return // 课堂id - const classRoomId = sessionStore.get('curClassRoom.id') + const classRoomId = sessionStore.get('curr.curClassRoom.id') formEl.validate((valid) => { if (valid) { /** diff --git a/src/renderer/src/plugins/shareStore.js b/src/renderer/src/plugins/shareStore.js index 3b3c819..b2d75df 100644 --- a/src/renderer/src/plugins/shareStore.js +++ b/src/renderer/src/plugins/shareStore.js @@ -10,7 +10,7 @@ import _ from 'lodash' // import { diff } from 'jsondiffpatch' // const Remote = isNode?require('@electron/remote'):{} // 远程模块 -const exArrs = ['subject'] // 不需要同步key-排除 +const exArrs = ['subject','env','curr'] // 不需要同步key-排除 export function shareStorePlugin({store}) { store.$subscribe((mutation, state) => { // 自动同步 @@ -60,7 +60,7 @@ function stateSyncWatch(storeName, newState) { const diffData = findDifferences(oldState, newState) if(!_.keys(diffData).length) return // 没有变化就终止执行 // 数据处理: 找出差异 - // console.log('state-change-diffData', diffData) + console.log('state-change-diffData', diffData, newState) try { let pinaValue = {} // store pina状态管理需要的数据格式 // 数据转换处理 @@ -83,7 +83,7 @@ function stateSyncWatch(storeName, newState) { // 没变化也终止执行 if (_.isEqual(oldValAll, newValAll)) return // 更新本地数据-session - sessionStore.set(key, newValAll) + sessionStore.set(key, newValAll || null) // 数据处理: pina-store const jsonStr = JSON.stringify(pinaValue) // 从新组装-json数据 diff --git a/src/renderer/src/store/modules/tool.js b/src/renderer/src/store/modules/tool.js index f2ff2b0..b8a6fa6 100644 --- a/src/renderer/src/store/modules/tool.js +++ b/src/renderer/src/store/modules/tool.js @@ -6,7 +6,7 @@ import { sessionStore } from '@/utils/store' // 默认数据 const defData = sessionStore.store || {} -const exArrs = ['subject'] +const exArrs = ['subject','env','curr'] exArrs.forEach(k => Object.keys(defData).includes(k) && (delete defData[k])) // 延时 diff --git a/src/renderer/src/views/fullScreenPdf/index.vue b/src/renderer/src/views/fullScreenPdf/index.vue index cb404c8..910961c 100644 --- a/src/renderer/src/views/fullScreenPdf/index.vue +++ b/src/renderer/src/views/fullScreenPdf/index.vue @@ -18,7 +18,9 @@ const loadPdfAnimation = (path) => { },2000) } onMounted(() => { - const bookpath = localStorage.getItem('PDF-LOCAL-PATH') + console.log('路由参数====',route); + const { pdfUrl } = route.query + const bookpath = !!pdfUrl ? pdfUrl : localStorage.getItem('PDF-LOCAL-PATH') // const filepath = import.meta.env.VITE_APP_RES_FILE_PATH + bookpath // const isDev = process.env.NODE_ENV == 'development' // if (isDev) @@ -28,7 +30,7 @@ onMounted(() => { // const newpath = getStaticUrl(bookpath, 'user', 'selfFile', true) loadPdfAnimation(bookpath) // pdfUrl.value = filepath - // console.log('课件路径',newpath); + // console.log('课件路径',bookpath); }) diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index 99b935b..2a6f520 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -103,7 +103,7 @@ onMounted(async() => { const getClassInfo = async () => { const { data } = await classManageApi.getClassInfo(classObj.id) classObj.data = data - sessionStore.set('curClassRoom', classObj) // 课堂信息-缓存 + sessionStore.set('curr.curClassRoom', classObj) // 课堂信息-缓存 // 群id let timGroupId = data?.ex3 || '' console.log('获取群ID:', timGroupId) @@ -208,14 +208,7 @@ const sideChange = async o => { // console.log(o) switch(o.prop) { case 'book': - if(isOpenBook.value) { - isOpenBook.value = false - ElMessage.info('已经打开课本了哦') - }else { - // createWindow('fullScreen-PDF',{url: '/fullscreenpdf'}) - toRoter(`${process.env['ELECTRON_RENDERER_URL']}/#/fullscreenpdf`) - isOpenBook.value = true - } + isMask.value = !isMask.value break case 'close': // 关闭 maskChange(false) From f1cdb7b4002932a77d7a49ec2dddb27ee9c24e53 Mon Sep 17 00:00:00 2001 From: zdg Date: Mon, 4 Nov 2024 21:53:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/main/index.js | 1 + src/renderer/src/plugins/shareStore.js | 2 +- src/renderer/src/utils/tool.js | 31 +++++++++++++++++++ .../src/views/fullScreenPdf/index.vue | 7 +++-- .../src/views/tool/components/side.vue | 18 +++++++---- src/renderer/src/views/tool/sphere.vue | 10 ++++++ 7 files changed, 60 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index ada67fe..31aa157 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aix-win", - "version": "2.1.21", + "version": "2.1.27", "description": "", "main": "./out/main/index.js", "author": "上海交大重庆人工智能研究院", diff --git a/src/main/index.js b/src/main/index.js index f874b6b..c28c144 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -175,6 +175,7 @@ async function createLinkWin(data) { data.fullPath += '?urlSource=smarttalk&t' + Date.now() } linkWin[data.key].loadURL(data.fullPath) + if (import.meta.env.VITE_SHOW_DEV_TOOLS === 'true') linkWin[data.key].webContents.openDevTools() linkWin[data.key].once('ready-to-show', () => { linkWin[data.key].show() diff --git a/src/renderer/src/plugins/shareStore.js b/src/renderer/src/plugins/shareStore.js index b2d75df..64531b8 100644 --- a/src/renderer/src/plugins/shareStore.js +++ b/src/renderer/src/plugins/shareStore.js @@ -60,7 +60,7 @@ function stateSyncWatch(storeName, newState) { const diffData = findDifferences(oldState, newState) if(!_.keys(diffData).length) return // 没有变化就终止执行 // 数据处理: 找出差异 - console.log('state-change-diffData', diffData, newState) + // console.log('state-change-diffData', diffData, newState) try { let pinaValue = {} // store pina状态管理需要的数据格式 // 数据转换处理 diff --git a/src/renderer/src/utils/tool.js b/src/renderer/src/utils/tool.js index 84fc77b..82b52cb 100644 --- a/src/renderer/src/utils/tool.js +++ b/src/renderer/src/utils/tool.js @@ -200,6 +200,25 @@ export const createWindow = async (type, data) => { eventHandles(type, winChild) // 事件监听处理 return winChild } + case 'open-win': { // 创建-新窗口 + const option = data.option||{} + const defOption = { + show: false, + frame: true, // 无边框 + autoHideMenuBar: true, + maximizable: false, + } + data.isConsole = true // 是否开启控制台 + data.option = {...defOption, ...option} + const win = await toolWindow(type, data) + win.type = type // 唯一标识 + win.show() + win.maximize(); + // win.setFullScreen(true) // 设置窗口为全屏 + if (import.meta.env.VITE_SHOW_DEV_TOOLS === 'true') win.webContents.openDevTools() // 打开调试工具 + eventHandles(type, win) // 事件监听处理 + break + } default: break } @@ -360,6 +379,18 @@ const eventHandles = (type, win) => { publicMethods(on) // 加载公共方法 break; } + case 'open-win': { // 打开新窗口 + // 监听窗口关闭事件 + win.on('closed', function () { + win&&win.destroy() + }); + const on = { + onClosed: () => { + } + } + publicMethods(on) // 加载公共方法 + break + } default: break } diff --git a/src/renderer/src/views/fullScreenPdf/index.vue b/src/renderer/src/views/fullScreenPdf/index.vue index 910961c..2f85aa9 100644 --- a/src/renderer/src/views/fullScreenPdf/index.vue +++ b/src/renderer/src/views/fullScreenPdf/index.vue @@ -18,9 +18,10 @@ const loadPdfAnimation = (path) => { },2000) } onMounted(() => { - console.log('路由参数====',route); - const { pdfUrl } = route.query - const bookpath = !!pdfUrl ? pdfUrl : localStorage.getItem('PDF-LOCAL-PATH') + const pdfUrl1 = localStorage.getItem('PDF-TOOL-PATH') + const pdfUrl2 = localStorage.getItem('PDF-LOCAL-PATH') + console.log('tool-pdf 地址: ',pdfUrl1, pdfUrl2) + const bookpath = pdfUrl1 || pdfUrl2 // const filepath = import.meta.env.VITE_APP_RES_FILE_PATH + bookpath // const isDev = process.env.NODE_ENV == 'development' // if (isDev) diff --git a/src/renderer/src/views/tool/components/side.vue b/src/renderer/src/views/tool/components/side.vue index f6ce4e2..71f3848 100644 --- a/src/renderer/src/views/tool/components/side.vue +++ b/src/renderer/src/views/tool/components/side.vue @@ -36,7 +36,7 @@
{{ item.tag }} - {{ curNode.bookName }} + {{ item.name }} 打开
@@ -55,7 +55,7 @@ import { computed, defineProps, ref, reactive, watchEffect, onMounted} from 'vue import { sessionStore } from '@/utils/store' import homework from './homework.vue'; import { ElMessage } from 'element-plus'; -import { toRoter } from '@/utils/tool' // 相关工具 +import { toRoter, createWindow } from '@/utils/tool' // 相关工具 // 功能说明:侧边-工具栏 const colors = ['#409EFF','#00f389', '#ff7f00', '#ffff00', '#00baff', '#13b189', '#F56C6C'] @@ -112,9 +112,9 @@ const getStyle = (style,index) => { // 获取内容数据 const getContent = o => { loading.value = true - const { bookName } = curNode - const textbook = { type: 'book', tag: '教材', name: bookName } - const course = { type: 'course', tag: '课标', name: bookName } + const { roottitle, edustage, edusubject } = curNode + const textbook = { type: 'book', tag: '教材', name: roottitle } + const course = { type: 'course', tag: '课标', name: `${edustage}-${edusubject}-课标` } cData.value = [textbook, course] loading.value = false } @@ -145,8 +145,14 @@ const openFile = item => { if (item.type == 'book') path = (textBook.curBookPath||'').replace('.txt', '.pdf') else path = textBook.curBookPath.replace(/([^-]*)$/, '课标.pdf') const url = pdfBasePath + encodeURIComponent(`${fileBasePath}${path}`) + console.log(url) + localStorage.setItem('PDF-TOOL-PATH', url) // 打开新窗口 - toRoter(`${process.env['ELECTRON_RENDERER_URL']}/#/fullscreenpdf?pdfUrl=${url}`) + // toRoter(`${process.env['ELECTRON_RENDERER_URL']}/#/fullscreenpdf`) + console.log('pdf_old:' + localStorage.getItem('PDF-LOCAL-PATH')) + console.log('pdf_new:' + localStorage.getItem('PDF-TOOL-PATH')) + // emit('change', { prop: 'bookOpen' }) + createWindow('open-win', {url: '/fullscreenpdf'}) } } // 回调: 关闭事件 diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index 2a6f520..cf204d5 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -207,6 +207,16 @@ const sideMouse = e => { const sideChange = async o => { // console.log(o) switch(o.prop) { + case 'bookOpen': + if(isOpenBook.value) { + isOpenBook.value = false + ElMessage.info('已经打开课本了哦') + }else { + // createWindow('fullScreen-PDF',{url: '/fullscreenpdf'}) + toRoter(`${process.env['ELECTRON_RENDERER_URL']}/#/fullscreenpdf`) + isOpenBook.value = true + } + break case 'book': isMask.value = !isMask.value break