Merge branch 'main' of ssh://18.167.251.121:10002/aidlab/FiDA_Front
This commit is contained in:
@@ -38,10 +38,10 @@
|
||||
<button class="export" @click="emit('import-local')">
|
||||
<span class="text">本地导入</span>
|
||||
</button> -->
|
||||
<button class="workbench" @click="onWorkbench">
|
||||
<!-- <button class="workbench" @click="onWorkbench">
|
||||
<span class="icon"><svg-icon name="dc-workbench" size="20" /></span>
|
||||
<span class="text">{{ $t('DepthCanvas.save') }}</span>
|
||||
</button>
|
||||
</button> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -183,11 +183,8 @@
|
||||
if (!activeLayerId.value) return
|
||||
layerManager.deleteLayerById(activeLayerId.value)
|
||||
}
|
||||
const onWorkbench = async () => {
|
||||
exportCanvasToImage(canvasManager.canvas).then((url) => {
|
||||
const { canvas, images } = canvasManager.getCanvasDisUrlJSON()
|
||||
emit('workbench', { url, canvas, images })
|
||||
})
|
||||
const onWorkbench = () => {
|
||||
emit('workbench')
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<details-panel />
|
||||
<brush-control-panel :currentTool="toolManager.currentTool.value" />
|
||||
<ai-selectbox-panel :currentTool="toolManager.currentTool.value" />
|
||||
<depth-header-tools @export="exportCanvas" @workbench="(v) => emit('workbench', v)" />
|
||||
<depth-header-tools @export="exportCanvas" @workbench="onWorkbench" />
|
||||
|
||||
<zoom
|
||||
:zoom="canvasManager.currentZoom.value / 100"
|
||||
@@ -52,6 +52,12 @@
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const onWorkbench = async () => {
|
||||
exportCanvasToImage(canvasManager.canvas).then((url) => {
|
||||
const { canvas, images } = canvasManager.getCanvasDisUrlJSON()
|
||||
emit('workbench', { url, canvas, images })
|
||||
})
|
||||
}
|
||||
|
||||
// 准备就绪
|
||||
const isReady = ref(false)
|
||||
@@ -78,7 +84,7 @@
|
||||
provide('toolManager', toolManager)
|
||||
|
||||
//键盘事件管理器
|
||||
const keyEventManager = new KeyEventManager({ stateManager })
|
||||
const keyEventManager = new KeyEventManager({ stateManager, onWorkbench })
|
||||
stateManager.setManager({ keyEventManager })
|
||||
provide('keyEventManager', keyEventManager)
|
||||
|
||||
@@ -183,6 +189,10 @@
|
||||
// const canvas = canvasManager.processCanvasDisUrlJSON(object)
|
||||
// console.log(canvas)
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
onWorkbench
|
||||
})
|
||||
</script>
|
||||
<style lang="less">
|
||||
@import '@vue-flow/core/dist/style.css';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<fullscreen-dialog v-model="dialogVisible" @close="onClose" hide-destroy>
|
||||
<div class="canvas-box">
|
||||
<depth-canvas :config="config" @workbench="onWorkbench" />
|
||||
<depth-canvas ref="depthCanvasRef" :config="config" @workbench="onWorkbench" />
|
||||
</div>
|
||||
</fullscreen-dialog>
|
||||
</template>
|
||||
@@ -22,6 +22,7 @@
|
||||
onWorkbench(options) {},
|
||||
onClose() {}
|
||||
})
|
||||
const depthCanvasRef = ref(null)
|
||||
|
||||
const open = async (options) => {
|
||||
config.value = options
|
||||
@@ -61,8 +62,9 @@
|
||||
}
|
||||
// 关闭
|
||||
const onClose = () => {
|
||||
dialogVisible.value = false
|
||||
config.value.onClose?.()
|
||||
depthCanvasRef.value.onWorkbench()
|
||||
// dialogVisible.value = false
|
||||
// config.value.onClose?.()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
||||
@@ -100,6 +100,7 @@ export class AISelectboxToolManager {
|
||||
this.demoObject = null
|
||||
}
|
||||
createIndicatorObject() {
|
||||
this.clearIndicatorObject()
|
||||
const rect = new fabric.Rect({
|
||||
left: this.startX,
|
||||
top: this.startY,
|
||||
@@ -198,8 +199,8 @@ export class AISelectboxToolManager {
|
||||
if (!this.isDragging) return;
|
||||
this.isDragging = false;
|
||||
const object = this.indicatorObject.toJSON("evented")
|
||||
if (object.width === 0) object.width = 100
|
||||
if (object.height === 0) object.height = 100
|
||||
// if (object.width === 0) object.width = 100
|
||||
// if (object.height === 0) object.height = 100
|
||||
this.clearIndicatorObject()
|
||||
this.canvasManager.canvas.renderAll()
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ fabric.Object.prototype.toObject_ = fabric.Object.prototype.toObject
|
||||
fabric.Object.prototype.toObject = function () {
|
||||
const args = [...arguments]
|
||||
const arr = [...fabric.Object.prototype.customProperties]
|
||||
args.forEach(v => {
|
||||
if (typeof v === 'string') {
|
||||
arr.push(v)
|
||||
} else if (Array.isArray(v)) {
|
||||
arr.push(...v)
|
||||
}
|
||||
})
|
||||
args.forEach(v => (Array.isArray(v) ? arr.push(...v) : arr.push(v)))
|
||||
if (this.fill?.source === null) {
|
||||
let image = new Image()
|
||||
image.crossOrigin = 'anonymous'
|
||||
image.src = this.info?.fill?.source
|
||||
this.fill.source = image
|
||||
}
|
||||
const object = this.toObject_(arr)
|
||||
if (object.info) {
|
||||
let lock = !!object.info.lock
|
||||
@@ -153,6 +153,7 @@ export class CanvasManager {
|
||||
this.canvas.add(obj)
|
||||
const id = obj?.info?.id || ""
|
||||
if (id) {
|
||||
this.sortActiveObject(obj)
|
||||
await this.layerManager.updateLayers(!!obj.info.parentId)
|
||||
this.renderAll()
|
||||
await this.layerManager.updateLayerThumbnailsById(id)
|
||||
@@ -167,6 +168,19 @@ export class CanvasManager {
|
||||
this.renderAll()
|
||||
}
|
||||
}
|
||||
/** 根据激活对象排序当前对象 */
|
||||
async sortActiveObject(object: any) {
|
||||
const activeID = this.layerManager.activeID.value;
|
||||
if (!activeID) return
|
||||
const activeObject = this.getObjectById(activeID)
|
||||
if (!activeObject) return
|
||||
const parentId = activeObject.info?.parentId
|
||||
if (!object.info.parentId) object.info.parentId = parentId
|
||||
const index = this.getObjects().indexOf(activeObject)
|
||||
this.canvas.moveTo(object, index + 1)
|
||||
// await this.sortObjectByIds(ids, isRecord)
|
||||
}
|
||||
|
||||
|
||||
/** 更新子图层裁剪区域 */
|
||||
async updateSubLayerClipPath() {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
export class KeyEventManager {
|
||||
stateManager: any
|
||||
onWorkbench: any
|
||||
constructor(options) {
|
||||
this.stateManager = options.stateManager;
|
||||
this.onWorkbench = options.onWorkbench;
|
||||
this._handleKeyDown = this.handleKeyDown.bind(this)
|
||||
}
|
||||
onMounted() { }
|
||||
@@ -9,6 +11,7 @@ export class KeyEventManager {
|
||||
/** 处理键盘事件 */
|
||||
_handleKeyDown: any
|
||||
handleKeyDown(event: any) {
|
||||
event.preventDefault()
|
||||
const activeID = this.stateManager.layerManager.activeID.value
|
||||
const ctrl = event.ctrlKey ? 'ctrl-' : "";
|
||||
const shift = event.shiftKey ? 'shift-' : "";
|
||||
@@ -18,6 +21,7 @@ export class KeyEventManager {
|
||||
{ key: "ctrl-c", handler: () => this.stateManager.layerManager.copyLayerById(activeID) },
|
||||
{ key: "delete", handler: () => this.stateManager.layerManager.deleteLayerById(activeID) },
|
||||
{ key: "ctrl-z", handler: () => this.stateManager.undoState() },
|
||||
{ key: "ctrl-s", handler: () => this.onWorkbench() },
|
||||
{ key: "ctrl-shift-z", handler: () => this.stateManager.redoState() },
|
||||
]
|
||||
list.forEach((v: any) => {
|
||||
|
||||
Reference in New Issue
Block a user