From 3a6b78bc76c2d0b11aaf204c9fe05ef033c3243d Mon Sep 17 00:00:00 2001 From: zdg Date: Wed, 4 Sep 2024 20:43:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug-=E7=94=BB=E7=AC=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/components/pdf/index.vue | 22 +++++++++-------- src/renderer/src/plugins/shareStore.js | 4 ++-- src/renderer/src/views/tool/sphere.vue | 29 ++++++++++++++--------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/renderer/src/components/pdf/index.vue b/src/renderer/src/components/pdf/index.vue index b2e8aa7..2ac6582 100644 --- a/src/renderer/src/components/pdf/index.vue +++ b/src/renderer/src/components/pdf/index.vue @@ -100,14 +100,14 @@ const renderPage = async (canvasobj) => { }) } // 保存数据 -const savaDataStore = (type) => { +const savaDataStore = async (type) => { if(!toolState.isToolWin){ toolState.isPdfWin = false - nextTick(() => { + await sleep(20) // 延时 toolState.showBoardAll = true //恢复默认值 - }) + await sleep(50) // 延时 if(type=='rest'){ - ipcRenderer.invoke('tool-sphere:reset') //重置tool状态 + // ipcRenderer.invoke('tool-sphere:reset') //重置tool状态-废弃 ipcRenderer.send('open-PDF:close') }else{ ipcRenderer.invoke('open-PDF:minimize') @@ -143,22 +143,24 @@ const savaDataStore = (type) => { } }) - Promise.all(promises).then(res=>{ + Promise.all(promises).then(async res=>{ toolState.isPdfWin=false - nextTick(() => { - toolState.showBoardAll=true //恢复默认值 - }) + await sleep(20) // 延时 + toolState.showBoardAll=true //恢复默认值 + await sleep(50) // 延时 // ipcRenderer.send('open-PDF:minimize') if(type=='rest'){ - ipcRenderer.invoke('tool-sphere:reset') //重置tool状态 + // ipcRenderer.invoke('tool-sphere:reset') //重置tool状态-废弃 ipcRenderer.send('open-PDF:close') }else{ - ipcRenderer.send('open-PDF:minimize') + ipcRenderer.invoke('open-PDF:minimize') } // ipcRenderer.send('open-PDF:close') }) } +// 延时 +const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) const updatePage = (canvasobj) => { renderPage(canvasobj) } diff --git a/src/renderer/src/plugins/shareStore.js b/src/renderer/src/plugins/shareStore.js index 05e071f..4f6c6e9 100644 --- a/src/renderer/src/plugins/shareStore.js +++ b/src/renderer/src/plugins/shareStore.js @@ -38,7 +38,7 @@ export function shareStorePlugin({store}) { // 同步数据-发送给主线程-单独 function stateSync(storeName, key, value, state) { - // console.log('state-change', storeName, key, value) + console.log('state-change', storeName, key, value) try { const { data, keystr } = filterByKey(state, key, value) const jsonStr = JSON.stringify(data) // 从新组装-json数据 @@ -85,7 +85,7 @@ function stateChange(store) { const storeName = store.$id ipcRenderer?.on('pinia-state-set', (e, sName, jsonStr) => { if (sName == storeName) { // 更新对应数据 - // console.log('state-set', jsonStr, sName) + console.log('state-set', jsonStr, sName) const curJson = circularSafeStringify(store.$state) // 当前数据 const isUp = curJson != jsonStr // 不同的时候才写入,不然会导致触发数据变化监听,导致死循环 if (!isUp) return diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index 1418969..3d7277f 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -39,7 +39,7 @@ -- 2.44.0.windows.1 From e31858a3fe8ce1583a6c4af0d59d2e46e0b620f8 Mon Sep 17 00:00:00 2001 From: zhangxuelin <959231531@qq.com> Date: Wed, 4 Sep 2024 21:06:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9pdf=E7=94=BB=E7=AC=94bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/utils/tool.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/utils/tool.js b/src/renderer/src/utils/tool.js index c42f2c8..76c0d5a 100644 --- a/src/renderer/src/utils/tool.js +++ b/src/renderer/src/utils/tool.js @@ -31,7 +31,8 @@ export const localStore = store.localStore // 暴露Store存储对象 export const Store = store - +// 延时 +const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) /** * 获取静态资源,开发和生产环境 * @param {*} url @@ -270,6 +271,15 @@ const eventHandles = (type, win) => { winPdf=null win&&win.destroy() }) + + // 监听窗口的激活事件 + win.on('focus', async () => { + toolState.isPdfWin=true + await sleep(20) // 延时 + toolState.showBoardAll=false //恢复默认值 + await sleep(50) // 延时 + + }); const on = { onClosed: () => { Remote.ipcMain.removeHandler('open-PDF:minimize') -- 2.44.0.windows.1