Merge pull request 'zdg' (#106) from zdg into main

Reviewed-on: #106
This commit is contained in:
zhengdegang 2024-08-07 17:06:15 +08:00
commit b8f2eb24e2
4 changed files with 60 additions and 24 deletions

View File

@ -58,6 +58,12 @@ export function ipcMsgSend(key, data, type) {
return ipcRenderer?.invoke(key, data) return ipcRenderer?.invoke(key, data)
} }
} }
export function ipcMsgSend2(key, ...args) {
return ipcRenderer?.send(key, ...args)
}
export function ipcMsgInvoke(key, ...args) {
return ipcRenderer?.invoke(key, ...args)
}
/** /**
* @description 封装ipcRenderer事件监听 * @description 封装ipcRenderer事件监听
* @param {*} fn on once handle invoke * @param {*} fn on once handle invoke
@ -197,9 +203,9 @@ const eventHandles = (type, win) => {
const setIgnore = (_, ignore) => {win.setIgnoreMouseEvents(ignore, {forward: true})} const setIgnore = (_, ignore) => {win.setIgnoreMouseEvents(ignore, {forward: true})}
Remote.ipcMain.handle('tool-sphere:set:ignore', setIgnore) // 异步 Remote.ipcMain.handle('tool-sphere:set:ignore', setIgnore) // 异步
// 关闭窗口 // 关闭窗口
Remote.ipcMain.once('tool-sphere:close', () => { win&&win.destroy() }) Remote.ipcMain.handleOnce('tool-sphere:close', () => {win&&win.destroy()})
// 放大监听-测试 // // 放大监听-测试
Remote.ipcMain.once('maximize-window', () => {win&&win.destroy()}) // Remote.ipcMain.once('maximize-window', () => {win&&win.destroy()})
const on = { const on = {
onClosed: () => { onClosed: () => {
Remote.ipcMain.removeHandler('tool-sphere:set:ignore', setIgnore) Remote.ipcMain.removeHandler('tool-sphere:set:ignore', setIgnore)

View File

@ -38,7 +38,7 @@ const props = defineProps({
{ label: '资源', prop: 'resource', icon: 'icon-hudong' }, { label: '资源', prop: 'resource', icon: 'icon-hudong' },
{ label: '互动', prop: 'interact', icon: 'icon-hudong' }, { label: '互动', prop: 'interact', icon: 'icon-hudong' },
{ label: '窗口', prop: 'win', icon: 'icon-hudong' }, { label: '窗口', prop: 'win', icon: 'icon-hudong' },
{ label: '下课', prop: 'over', icon: 'icon-hudong' }, { label: '下课', prop: 'over', isExtra: true, icon: 'icon-hudong' },
] ]
} }
}) })
@ -71,12 +71,14 @@ const getStyle = (style,index) => {
} }
// //
const clickHandel = (o, e) => { const clickHandel = (o, e) => {
if (!o.isExtra) { // :
const node = e.target.parentNode.getBoundingClientRect() const node = e.target.parentNode.getBoundingClientRect()
const isColse = activeObj.value && activeObj.value.prop === o.prop && isVisible.value const isColse = activeObj.value && activeObj.value.prop === o.prop && isVisible.value
isVisible.value = !isColse // isVisible.value = !isColse //
activeObj.value = o activeObj.value = o
const nodeH = parseInt(node.height / 2) // const nodeH = parseInt(node.height / 2) //
topPos.value = parseInt(node.top) - posBtnAll.top + nodeH topPos.value = parseInt(node.top) - posBtnAll.top + nodeH
}
emit('change', o) emit('change', o)
} }
</script> </script>

View File

@ -29,7 +29,8 @@ class Ignore {
}) })
} }
changeHandle(e) { changeHandle(e) {
const customEvent = new CustomEvent('ignore-mounted', {detail:{ignore: this, e}}) const data = {detail:{ignore: this, e, type: e.type}}
const customEvent = new CustomEvent('ignore-mounted', data)
this.el.dispatchEvent(customEvent) this.el.dispatchEvent(customEvent)
} }
} }

View File

@ -3,7 +3,7 @@
<!-- 画板 --> <!-- 画板 -->
<board-vue v-model="tabActive" v-show="isShow" ref="boardVueRef"></board-vue> <board-vue v-model="tabActive" v-show="isShow" ref="boardVueRef"></board-vue>
<!-- 侧边工具栏 --> <!-- 侧边工具栏 -->
<side-vue v-ignore></side-vue> <side-vue v-ignore @ignore-mounted="sideMouse" @change="sideChange"></side-vue>
<!-- 底部工具栏 :style="dataPos.style"--> <!-- 底部工具栏 :style="dataPos.style"-->
<div class="tool-bottom-all" @mouseenter="mouseChange(0)" @mouseleave="mouseChange(1)"> <div class="tool-bottom-all" @mouseenter="mouseChange(0)" @mouseleave="mouseChange(1)">
<div v-drag="{handle:'.tool-bottom-all', dragtime}" <div v-drag="{handle:'.tool-bottom-all', dragtime}"
@ -36,7 +36,7 @@ import sideVue from './components/side.vue' // 画板-子组件
import vDrag from './directive/drag' // - import vDrag from './directive/drag' // -
import vIgnore from './directive/ignore' // -穿 import vIgnore from './directive/ignore' // -穿
import { useToolState } from '@/store/modules/tool' import { useToolState } from '@/store/modules/tool'
import { ipcMsgSend, ipcHandle, ipcMain } from '@/utils/tool' // import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' //
const tabActive = ref('select') // const tabActive = ref('select') //
const isFold = ref(false) // const isFold = ref(false) //
const isDrag = ref(false) // const isDrag = ref(false) //
@ -53,33 +53,38 @@ const btnList = [ // 工具栏按钮列表
// { label: '', value: 'focus', icon: 'icon-jujiao' }, // { label: '', value: 'focus', icon: 'icon-jujiao' },
// { label: '', value: 'more', icon: 'icon-xiazai9' }, // { label: '', value: 'more', icon: 'icon-xiazai9' },
] ]
// // === ===
onMounted(async() => { onMounted(async() => {
resetStatus() // - resetStatus() // -
}) })
// const test = (e) => { console.log('test', e) }
// ==== === // ==== ===
const tabChange = (val) => { // tab-change // const test = (e) => { console.log('test', e) }
// tab-change
const tabChange = (val) => {
const bool = !toolStore.isPdfWin && !toolStore.showBoardAll const bool = !toolStore.isPdfWin && !toolStore.showBoardAll
if(bool) toolStore.showBoardAll = true if(bool) toolStore.showBoardAll = true
// ipcMsgSend('tool-sphere:close') // ipcMsgSend('tool-sphere:close')
toolStore.model = val // tab toolStore.model = val // tab
} }
const logoHandle = (e,t) => { // logo - | // logo - |
const logoHandle = (e,t) => {
if (Date.now() - dragtime.value < 200) { if (Date.now() - dragtime.value < 200) {
isFold.value = !isFold.value isFold.value = !isFold.value
} }
} }
const mouseChange = (bool) => { // 穿 // -穿
const mouseChange = (bool) => {
let resBool = false let resBool = false
if (tabActive.value == 'select') resBool = !!bool if (tabActive.value == 'select') resBool = !!bool
if (!isShow.value) resBool = !!bool if (!isShow.value) resBool = !!bool
setIgnore(resBool) setIgnore(resBool)
} }
const setIgnore = (bool) => { // 穿 // 穿
ipcMsgSend('tool-sphere:set:ignore', bool) const setIgnore = (bool) => {ipcMsgSend('tool-sphere:set:ignore', bool)}
} // : |
const resetStatus = () => { // const resetStatus = () => {
if (toolStore.isToolWin) return // - if (toolStore.isToolWin) return // -
ipcMain?.handle?.('tool-sphere:reset', () => { ipcMain?.handle?.('tool-sphere:reset', () => {
setTimeout(() => { setTimeout(() => {
@ -89,8 +94,30 @@ const resetStatus = () => { // 重置状态
}) })
toolStore.isToolWin = true // toolStore.isToolWin = true //
} }
// :
const sideMouse = e => {
const {type} = e.detail
mouseChange(type == 'mouseleave')
}
// :
const sideChange = o => {
// console.log(o)
switch(o.prop) {
case 'resource': //
break
case 'interact': //
break
case 'win': //
break
case 'over': //
toolStore.isToolWin = false
ipcMsgSend('tool-sphere:close')
break
}
}
watchEffect(() => { // // === ===
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