Skip to content

Commit

Permalink
feature: 梳理了toolkey
Browse files Browse the repository at this point in the history
  • Loading branch information
AnsGoo committed May 14, 2024
1 parent 1f624eb commit 61ba44c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
9 changes: 2 additions & 7 deletions examples/src/pages/DesignerView/toolbars/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exportCanvas, importCanvas, recoveryDraft, setShowEm, undo } from '@open-data-v/designer'
import { exportCanvas, importCanvas, recoveryDraft, setShowEm, undo, fullScreen } from '@open-data-v/designer'
import { h } from 'vue'
import type { RouteLocationNormalizedLoaded, Router } from 'vue-router'

Expand Down Expand Up @@ -74,12 +74,7 @@ export default function useToolBars(
},
{
label: '全屏',
action: () => {
const el: HTMLElement | null = document.querySelector('#editor')
if (document.fullscreenEnabled && el) {
el.requestFullscreen()
}
},
action: fullScreen,
icon: 'fullScreen'
},
{
Expand Down
22 changes: 18 additions & 4 deletions packages/designer/src/toolbars.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { StoreComponentData } from './db'
import useCanvasState from './state/canvas'
import useSnapShotState from './state/snapshot'
import { useCanvasState, useClipBoardState, useSnapshotState } from './state'
import type { CanvasStyleData } from './state/type'
import type { ComponentDataType } from './type'
import { exportRaw, handleLogger, importRaw } from './utils'

const snapShotState = useSnapShotState()
const snapShotState = useSnapshotState()
const clipBoardState = useClipBoardState()

// 状态管理
const canvasState = useCanvasState()
Expand Down Expand Up @@ -70,4 +70,18 @@ const fileHandler = (loadEvent: ProgressEvent<FileReader>) => {
}
}

export { exportCanvas, importCanvas, recoveryDraft, setShowEm, undo }
const decompose = () => {
canvasState.decompose()
}
const copy = () => {
clipBoardState.copy(canvasState.activeComponent!)
}

const fullScreen = () => {
const el: HTMLElement | null = document.querySelector('#editor')
if (document.fullscreenEnabled && el) {
el.requestFullscreen()
}
}

export { copy, decompose, exportCanvas, fullScreen, importCanvas, recoveryDraft, setShowEm, undo }

0 comments on commit 61ba44c

Please sign in to comment.