工具栏-橡皮擦

This commit is contained in:
zdg 2024-08-01 10:44:52 +08:00
parent e788174a3a
commit 24c2540436
4 changed files with 31 additions and 13 deletions

View File

@ -777,7 +777,8 @@ export class TYPES {
DRAW: 'draw', // 画笔模式 DRAW: 'draw', // 画笔模式
ERASE: 'erase', // 橡皮擦模式 ERASE: 'erase', // 橡皮擦模式
SELECT: 'select', // 选择模式 SELECT: 'select', // 选择模式
Board: 'board' // 画板模式 Board: 'board', // 画板模式
OTHER: 'other', // 其他模式
} }
// 画笔类型 // 画笔类型
static DrawType = { static DrawType = {
@ -1612,6 +1613,10 @@ export class fabricVue {
objectSet.hoverCursor = undefined objectSet.hoverCursor = undefined
this.canvas.selection = true this.canvas.selection = true
break break
case TYPES.ActionMode.OTHER: // 其他(工具选择)
this.canvas.isDrawingMode = false
this.canvas.freeDrawingCursor = 'default'
break
default: default:
break break
} }

View File

@ -69,9 +69,9 @@ export const createWindow = async (type, data) => {
// parent: mainWin, // 父窗口 // parent: mainWin, // 父窗口
// autoClose: true, // 关闭窗口后自动关闭 // autoClose: true, // 关闭窗口后自动关闭
} }
data.isConsole = true // 是否开启控制台
data.option = {...defOption, ...option} data.option = {...defOption, ...option}
const win = await toolWindow(data) const win = await toolWindow(data)
win.setTitle('窗口标题: 我的自定义参数')
win.type = type // 唯一标识 win.type = type // 唯一标识
win.show() win.show()
win.setFullScreen(true) // 设置窗口为全屏 win.setFullScreen(true) // 设置窗口为全屏
@ -110,7 +110,7 @@ export const createWindow = async (type, data) => {
* @author: zdg * @author: zdg
* @date 2021-07-05 14:07:01 * @date 2021-07-05 14:07:01
*/ */
export function toolWindow({url, isFile, isConsole, option={}}) { export function toolWindow({url, isConsole, option={}}) {
// width = window.screen.width // width = window.screen.width
let width = option?.width || 800 let width = option?.width || 800
let height = option?.height || 600 let height = option?.height || 600

View File

@ -4,24 +4,39 @@
</template> </template>
<script setup> <script setup>
// //
import { ref, onMounted } from 'vue' import { ref, onMounted, watchEffect } from 'vue'
import {FabricVue, TYPES} from '@/plugins/fabric' import {FabricVue, TYPES} from '@/plugins/fabric'
import { useBoardStore, useDrawStore } from '@/store/modules/draw' const canvasRef = ref(null) //
const canvasRef = ref(null) const isMouse = ref(true) //
const props = defineProps({ const props = defineProps({
modelValue: String modelValue: String
}) })
//
onMounted(async() => { onMounted(async() => {
if (canvasRef.value) { if (canvasRef.value) {
// useBoardStore().backgroundColor = 'transparent'
// useDrawStore().drawColors = ['red']
FabricVue.drawConfig.drawColors = ['red'] FabricVue.drawConfig.drawColors = ['red']
FabricVue.boardConfig.backgroundColor = 'transparent' FabricVue.boardConfig.backgroundColor = 'transparent'
const option = { freeDrawingCursor: 'default' } const option = { freeDrawingCursor: 'default' }
await FabricVue.initCanvas(canvasRef.value, option) await FabricVue.initCanvas(canvasRef.value, option)
} }
}) })
//
watchEffect(() => {
// console.log('board : ', props.modelValue)
isMouse.value = false
switch(props.modelValue) {
case 'select': //
FabricVue.handleMode(TYPES.ActionMode.OTHER)
break
case 'brush': //
FabricVue.handleMode(TYPES.ActionMode.DRAW)
FabricVue.canvas.freeDrawingCursor = 'default'
break
case 'eraser': //
FabricVue.handleMode(TYPES.ActionMode.ERASE)
break
}
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
</style> </style>

View File

@ -42,12 +42,10 @@ const btnList = [
// ==== === // ==== ===
const tabChange = (val) => { // tab-change const tabChange = (val) => { // tab-change
console.log('xxxx', val)
switch (val) { switch (val) {
case 'brush': case 'brush': //
break break
case 'eraser': case 'eraser': //
break break
case 'interact': case 'interact':
break break