From e8dcd666c2400d5dd5aca88a4115640441d4708c Mon Sep 17 00:00:00 2001 From: Nevermore <15972699417@163.com> Date: Wed, 26 Jun 2024 10:14:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=83=E7=B4=A0=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E5=9B=9E=E6=BB=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/logic/Canvas/useCanvas.ts | 14 +++++++++----- src/store/modules/template.ts | 5 +---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/logic/Canvas/useCanvas.ts b/src/logic/Canvas/useCanvas.ts index 5b20a3d..3b5eeb6 100644 --- a/src/logic/Canvas/useCanvas.ts +++ b/src/logic/Canvas/useCanvas.ts @@ -1,10 +1,10 @@ import { watch } from 'vue' import { storeToRefs } from 'pinia' -import { Leafer, App, Rect, Frame, Text, ChildEvent, UI, PropertyEvent } from 'leafer-ui' +import { Leafer, App, Rect, Frame, Text, ChildEvent, UI, PropertyEvent, LeafList, LayoutEvent, DragEvent } from 'leafer-ui'; import { useElementBounding } from '@vueuse/core' import { useTemplatesStore, useLeaferStore } from '@/store' -import { Editor } from '@leafer-in/editor' +import { Editor, EditorMoveEvent, EditorEvent } from '@leafer-in/editor' import { CanvasTypes } from '@/enums' import '@leafer-in/view' import '@leafer-in/editor' @@ -68,11 +68,15 @@ const initEvent = () => { const workspace = app.tree.findOne(`#${CanvasTypes.WorkSpaceDrawType}`) if (!workspace) return workspace.on(ChildEvent.ADD, function (e: ChildEvent) { - console.log('add:', e) // changed list + console.log('ChildEvent.ADD:', e) // changed list templatesStore.modifedElement() }) - workspace.on(PropertyEvent.CHANGE, (e: PropertyEvent) => { - console.log('change:', e) // changed list + workspace.on(ChildEvent.REMOVE, function (e: ChildEvent) { + console.log('ChildEvent.REMOVE:', e) // changed list + templatesStore.modifedElement() + }) + app.tree.on(DragEvent.END, (e: DragEvent) => { + console.log('DragEvent.END', e) templatesStore.modifedElement() }) } diff --git a/src/store/modules/template.ts b/src/store/modules/template.ts index 0acf2bc..1f96024 100644 --- a/src/store/modules/template.ts +++ b/src/store/modules/template.ts @@ -55,10 +55,7 @@ export const useTemplatesStore = defineStore('Templates', { }, currentTemplateElement(state) { - const currentTemplate = state.templates[state.templateIndex] - const [ canvas ] = useCanvas() - const activeObject = canvas.getActiveObject() as CanvasElement - return currentTemplate.objects.filter(ele => ele.id === activeObject.id)[0] + } },