dargHandle(e,'down')"
- @mousemove="e => dargHandle(e,'move')"
- @mouseup="e => dargHandle(e,'up')">
+
@@ -16,7 +15,7 @@
@change="tabChange">
-
+
{{item.label}}
@@ -31,27 +30,27 @@
import { onMounted, ref, reactive } from 'vue'
import logo from '@root/resources/icon.png' // logo
import boardVue from './components/board.vue' // 画板
-import vDrag from '@/directive/drag'
-import { tryOnUnmounted } from '@vueuse/core'
+import vDrag from './directive/drag'
// const Remote = require('@electron/remote') // remote对象
-const { ipcRenderer } = require('electron')
+const { ipcRenderer } = require('electron') // app使用
+// const ipcRenderer = { send: () => {} } // 网页测试使用
-const tool = ref()
const tabActive = ref('select') // 工具栏当前选中项
const isFold = ref(false) // 折叠工具栏
const isDrag = ref(false) // 开始拖拽
-const dataPos = reactive({style:{}}) // 对象属性
+const dragtime = ref(0)
const btnList = [ // 工具栏按钮列表
{ label: '选择', value: 'select', icon: 'icon-mouse' },
{ label: '画笔', value: 'brush', icon: 'icon-huabi' },
{ label: '板擦', value: 'eraser', icon: 'icon-xiangpica' },
- { label: '互动', value: 'interact', icon: 'icon-hudong' },
- { label: '聚焦', value: 'focus', icon: 'icon-jujiao' },
- { label: '更多', value: 'more', icon: 'icon-xiazai9' },
+ { label: '清除', value: 'clear', icon: 'icon-xiangpica', style: 'color: #ccc' },
+ // { label: '互动', value: 'interact', icon: 'icon-hudong' },
+ // { label: '聚焦', value: 'focus', icon: 'icon-jujiao' },
+ // { label: '更多', value: 'more', icon: 'icon-xiazai9' },
]
-let offsetX = 0, offsetY = 0, dragtime = 0
// ==== 方法 ===
const tabChange = (val) => { // 切换tab-change
+ console.log(val)
switch (val) {
case 'brush': // 画笔
break
@@ -71,47 +70,11 @@ const tabChange = (val) => { // 切换tab-change
}
}
const logoHandle = (e,t) => { // logo 点击-事件 折叠|展开
- if (Date.now() - dragtime < 200) {
+ if (Date.now() - dragtime.value < 200) {
isFold.value = !isFold.value
}
- console.log('click', isDrag.value)
-}
-const dargHandle = (e, type) => { // 拖拽处理
- e.preventDefault(); // 阻止默认的拖拽行为
- if (type == 'down') {
- dragtime = Date.now()
- return isDrag.value = true
- } else if (type == 'up') {
- return isDrag.value = false
- } else {
- if (!isDrag.value) return false
- if (!e.clientX&&!e.clientY){ // 最后一次松开坐标为0
- offsetX = 0
- offsetY = 0
- return false
- }
- if (!offsetX&&!offsetY) { // 第一次, 获取元素坐标
- setStyle()
- } else {
- const x = e.clientX - offsetX
- const y = e.clientY - offsetY
- setStyle(x, y)
- }
- offsetX = e.clientX
- offsetY = e.clientY
- }
-}
-const setStyle = (x, y) => { // 拖拽-设置值
- if (offsetX && offsetY) { // 有值
- const {left, top} = dataPos.style
- const ox = parseInt(left.replace('px',''))
- const oy = parseInt(top.replace('px',''))
- dataPos.style = {...dataPos.style, left: ox + x + 'px', top: oy + y + 'px'}
- } else { // 初始值
- const {left, top} = tool.value.getBoundingClientRect() // 获取元素位置
- dataPos.style = {bottom: 'unset', transform:'unset', left: left+'px', top: top+'px'}
- }
}
+
const mouseChange = (bool) => { // 鼠标移入工具栏 是否穿透
let resBool = false
if (tabActive.value == 'select') resBool = !!bool
@@ -153,8 +116,7 @@ const mouseChange = (bool) => { // 鼠标移入工具栏 是否穿透
:deep(.el-segmented__item){
position: relative;
margin: 0 0.5rem;
- &:nth-last-child(1):before,
- &:nth-last-child(2):before{
+ &:not(:nth-of-type(1)):before{
content: "";
width: 2px;
height: calc(100% - 20px);