zdg #92

Merged
zhengdegang merged 8 commits from zdg into main 2024-08-02 09:23:15 +08:00
4 changed files with 31 additions and 13 deletions
Showing only changes of commit 24c2540436 - Show all commits

View File

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

View File

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

View File

@ -4,24 +4,39 @@
</template>
<script setup>
//
import { ref, onMounted } from 'vue'
import { ref, onMounted, watchEffect } from 'vue'
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({
modelValue: String
})
//
onMounted(async() => {
if (canvasRef.value) {
// useBoardStore().backgroundColor = 'transparent'
// useDrawStore().drawColors = ['red']
FabricVue.drawConfig.drawColors = ['red']
FabricVue.boardConfig.backgroundColor = 'transparent'
const option = { freeDrawingCursor: 'default' }
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>
<style lang="scss" scoped>
</style>

View File

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