Merge pull request '修复bug-画笔' (#174) from zdg into main

Reviewed-on: #174
This commit is contained in:
zhangxuelin 2024-09-04 21:12:24 +08:00
commit 30f7b9d5b3
4 changed files with 43 additions and 24 deletions

View File

@ -100,14 +100,14 @@ const renderPage = async (canvasobj) => {
}) })
} }
// //
const savaDataStore = (type) => { const savaDataStore = async (type) => {
if(!toolState.isToolWin){ if(!toolState.isToolWin){
toolState.isPdfWin = false toolState.isPdfWin = false
nextTick(() => { await sleep(20) //
toolState.showBoardAll = true // toolState.showBoardAll = true //
}) await sleep(50) //
if(type=='rest'){ if(type=='rest'){
ipcRenderer.invoke('tool-sphere:reset') //tool // ipcRenderer.invoke('tool-sphere:reset') //tool-
ipcRenderer.send('open-PDF:close') ipcRenderer.send('open-PDF:close')
}else{ }else{
ipcRenderer.invoke('open-PDF:minimize') 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 toolState.isPdfWin=false
nextTick(() => { await sleep(20) //
toolState.showBoardAll=true // toolState.showBoardAll=true //
}) await sleep(50) //
// ipcRenderer.send('open-PDF:minimize') // ipcRenderer.send('open-PDF:minimize')
if(type=='rest'){ if(type=='rest'){
ipcRenderer.invoke('tool-sphere:reset') //tool // ipcRenderer.invoke('tool-sphere:reset') //tool-
ipcRenderer.send('open-PDF:close') ipcRenderer.send('open-PDF:close')
}else{ }else{
ipcRenderer.send('open-PDF:minimize') ipcRenderer.invoke('open-PDF:minimize')
} }
// ipcRenderer.send('open-PDF:close') // ipcRenderer.send('open-PDF:close')
}) })
} }
//
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
const updatePage = (canvasobj) => { const updatePage = (canvasobj) => {
renderPage(canvasobj) renderPage(canvasobj)
} }

View File

@ -38,7 +38,7 @@ export function shareStorePlugin({store}) {
// 同步数据-发送给主线程-单独 // 同步数据-发送给主线程-单独
function stateSync(storeName, key, value, state) { function stateSync(storeName, key, value, state) {
// console.log('state-change', storeName, key, value) console.log('state-change', storeName, key, value)
try { try {
const { data, keystr } = filterByKey(state, key, value) const { data, keystr } = filterByKey(state, key, value)
const jsonStr = JSON.stringify(data) // 从新组装-json数据 const jsonStr = JSON.stringify(data) // 从新组装-json数据
@ -85,7 +85,7 @@ function stateChange(store) {
const storeName = store.$id const storeName = store.$id
ipcRenderer?.on('pinia-state-set', (e, sName, jsonStr) => { ipcRenderer?.on('pinia-state-set', (e, sName, jsonStr) => {
if (sName == storeName) { // 更新对应数据 if (sName == storeName) { // 更新对应数据
// console.log('state-set', jsonStr, sName) console.log('state-set', jsonStr, sName)
const curJson = circularSafeStringify(store.$state) // 当前数据 const curJson = circularSafeStringify(store.$state) // 当前数据
const isUp = curJson != jsonStr // 不同的时候才写入,不然会导致触发数据变化监听,导致死循环 const isUp = curJson != jsonStr // 不同的时候才写入,不然会导致触发数据变化监听,导致死循环
if (!isUp) return if (!isUp) return

View File

@ -31,7 +31,8 @@ export const localStore = store.localStore
// 暴露Store存储对象 // 暴露Store存储对象
export const Store = store export const Store = store
// 延时
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
/** /**
* 获取静态资源开发和生产环境 * 获取静态资源开发和生产环境
* @param {*} url * @param {*} url
@ -270,6 +271,15 @@ const eventHandles = (type, win) => {
winPdf=null winPdf=null
win&&win.destroy() win&&win.destroy()
}) })
// 监听窗口的激活事件
win.on('focus', async () => {
toolState.isPdfWin=true
await sleep(20) // 延时
toolState.showBoardAll=false //恢复默认值
await sleep(50) // 延时
});
const on = { const on = {
onClosed: () => { onClosed: () => {
Remote.ipcMain.removeHandler('open-PDF:minimize') Remote.ipcMain.removeHandler('open-PDF:minimize')

View File

@ -39,7 +39,7 @@
<script setup> <script setup>
// electron // electron
import { onMounted, ref, reactive, watchEffect } from 'vue' import { onMounted, ref, reactive, watchEffect, nextTick } from 'vue'
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus' import { ElMessageBox, ElMessage, ElLoading } from 'element-plus'
import * as classManageApi from '@/api/classManage' import * as classManageApi from '@/api/classManage'
@ -83,8 +83,8 @@ const btnList = [ // 工具栏按钮列表
// === === // === ===
onMounted(async() => { onMounted(async() => {
if (!electron) return // if (!electron) return //
// window.test = sessionStore window.test = sessionStore
// window.test1 = toolStore window.test1 = toolStore
getClassInfo() // ex3 getClassInfo() // ex3
resetStatus() // - resetStatus() // -
}) })
@ -135,6 +135,7 @@ const logoHandle = (e,t) => {
// -穿 // -穿
const mouseChange = (bool) => { const mouseChange = (bool) => {
let resBool = false let resBool = false
if (bool == 0) return setIgnore(resBool) // 穿
if (tabActive.value == 'select') resBool = !!bool if (tabActive.value == 'select') resBool = !!bool
else { else {
if (!isShow.value) resBool = !!bool if (!isShow.value) resBool = !!bool
@ -176,15 +177,15 @@ const setIgnore = (bool) => {ipcMsgSend('tool-sphere:set:ignore', bool)}
// : | // : |
const resetStatus = () => { const resetStatus = () => {
if (toolStore.isToolWin) return // - if (toolStore.isToolWin) return // -
ipcMain?.removeHandler('tool-sphere:reset') // // -
ipcMain?.handle?.('tool-sphere:reset', () => { // ipcMain?.removeHandler('tool-sphere:reset') //
setTimeout(() => { // ipcMain?.handle?.('tool-sphere:reset', () => {
boardVueRef.value.handleMode(tabActive.value) // setTimeout(() => {
mouseChange(1) // boardVueRef.value.handleMode(tabActive.value)
}, 500) // mouseChange(1)
}) // }, 500)
// })
toolStore.isToolWin = true // toolStore.isToolWin = true //
} }
// : // :
const sideMouse = e => { const sideMouse = e => {
@ -240,6 +241,12 @@ watchEffect(() => {
// , : - // , : -
const show = !toolStore.isPdfWin && toolStore.showBoardAll const show = !toolStore.isPdfWin && toolStore.showBoardAll
if (show != isShow.value) isShow.value = show if (show != isShow.value) isShow.value = show
if (isShow.value) {
nextTick(() => {
mouseChange(1) //
boardVueRef.value.handleMode(tabActive.value)
})
}
}) })
</script> </script>