Files
FiDA_Front/src/components/Canvas/DepthCanvas/index.vue

59 lines
1.4 KiB
Vue
Raw Normal View History

2026-03-06 15:50:05 +08:00
<template>
2026-03-17 11:06:32 +08:00
<fullscreen-dialog v-model="dialogVisible" @close="onClose" hide-destroy>
2026-03-06 15:50:05 +08:00
<div class="canvas-box">
2026-03-17 11:35:04 +08:00
<depth-canvas :config="config" @workbench="onWorkbench" />
2026-03-06 15:50:05 +08:00
</div>
</fullscreen-dialog>
</template>
<script setup lang="ts">
import { base64Tofile } from '../tools/tools'
import { uploadImage } from '@/api/upload'
2026-03-06 15:50:05 +08:00
import FullscreenDialog from '../components/fullscreen-dialog.vue'
import depthCanvas from './depth-canvas.vue'
import { ref } from 'vue'
const dialogVisible = ref(false)
2026-03-17 09:56:58 +08:00
const config = ref({
2026-03-17 10:53:43 +08:00
id: '',
2026-03-19 11:00:31 +08:00
url: '',
json: ''
2026-03-17 09:56:58 +08:00
})
2026-03-17 10:53:43 +08:00
2026-03-06 15:50:05 +08:00
const open = (options) => {
2026-03-17 10:53:43 +08:00
config.value = options
2026-03-19 11:32:23 +08:00
console.log(config.value)
config.value.json = sessionStorage.getItem('canvasJson_' + config.value.id)
2026-03-06 15:50:05 +08:00
dialogVisible.value = true
}
2026-03-17 10:53:43 +08:00
// 工作区
const onWorkbench = async (options) => {
2026-03-19 11:32:23 +08:00
const json = options.json
2026-03-19 11:32:23 +08:00
sessionStorage.setItem('canvasJson_' + config.value.id, json)
const file = base64Tofile(options.url, 'canvas.png')
const formData = new FormData()
formData.append('file', file)
const url = await uploadImage(formData)
config.value.onWorkbench?.({ url })
dialogVisible.value = false
2026-03-17 10:53:43 +08:00
}
// 关闭
const onClose = () => {
2026-03-06 15:50:05 +08:00
dialogVisible.value = false
2026-03-17 10:53:43 +08:00
config.value.onClose?.()
2026-03-06 15:50:05 +08:00
}
2026-03-17 10:53:43 +08:00
2026-03-06 15:50:05 +08:00
defineExpose({
open,
close
})
</script>
<style lang="less" scoped>
.canvas-box {
padding-top: 10rem;
width: 100%;
height: 100%;
}
</style>