Merge branch 'main' of ssh://18.167.251.121:10002/aidlab/FiDA_Front

This commit is contained in:
2026-04-22 09:43:27 +08:00
8 changed files with 54 additions and 7 deletions

View File

@@ -59,6 +59,10 @@
updateVersionSketchUrlApi({
sketchId: stateManager.sketchId.value,
newUrl: options.url,
}).then(()=>{
//更新VersionNode的versionImgUpdataList中指定key的URL值
let initialNode = stateManager.getInitialNode()
initialNode.data.versionImgUpdataList.push(options.url)
})
},
}

View File

@@ -230,6 +230,10 @@
updateVersionSketchUrlApi({
sketchId: stateManager.sketchId.value,
newUrl: options.url,
}).then(()=>{
//更新VersionNode的versionImgUpdataList中指定key的URL值
let initialNode = stateManager.getInitialNode()
initialNode.data.versionImgUpdataList.push(options.url)
})
},
onClose:depthCanvasClose

View File

@@ -289,6 +289,7 @@
const timestamp = Date.now()
nodeManager.createResultNode({
data: {
versionImgUpdataList:[props.config.url],
disableDelete: true,
isHeader: false,
data: {
@@ -307,6 +308,9 @@
})
}
})
const putFlowJson = async () => {
await stateManager.exportFlow(0,true)
}
onBeforeUnmount(() => {
stateManager.dispose()
eventManager.dispose()
@@ -315,7 +319,8 @@
toolManager.dispose()
})
defineExpose({
getFlowJson
getFlowJson,
putFlowJson
})
</script>
<style lang="less">

View File

@@ -18,21 +18,25 @@
const {t:$t} = useI18n()
const open = async (options) => {
let json = []
let isGetJson = false
await new Promise((resolve) => {
getSketchFlowCanvas({ id: options.imgId },true).then((res:any) => {
if (res) {
json = JSON.parse(res)
}
isGetJson = true
resolve(true)
}).catch(() => {
resolve(true)
resolve(false)
})
})
if(!isGetJson)return
config.value = options || {}
config.value.json = json
dialogVisible.value = true
}
const close = async () => {
await flowCanvasRef.value?.putFlowJson()
dialogVisible.value = false
myEvent.emit('closeFlowCanvas')
}

View File

@@ -108,6 +108,7 @@ export class EventManager {
const list = [
{ key: "ctrl-c", handler: () => this.handleCopy(event, activeNodeID) },
{ key: "delete", handler: () => this.handleDelete(event, activeNodeID) },
{ key: "Backspace", handler: () => this.handleDelete(event, activeNodeID) },
{ key: "ctrl-z", handler: () => this.stateManager.undoState() },
{ key: "ctrl-shift-z", handler: () => this.stateManager.redoState() },
]

View File

@@ -55,11 +55,14 @@ export class GenerateManager {
nodeDataItem.url = item.url
nodeDataItem.createTime = item.createTime
nodeDataItem.status = item.status
//更新VersionNode的sketchIDAndUrl中指定key的URL值
updateVersionSketchUrlApi({
sketchId: this.stateManager.sketchId.value,
newUrl: item.url,
}).then(()=>{
//更新VersionNode的versionImgUpdataList中指定key的URL值
let initialNode = this.stateManager.getInitialNode()
initialNode.data.versionImgUpdataList.push(item.url)
})
if(item.glbPath){
nodeDataItem.glbPath = item.glbPath

View File

@@ -14,6 +14,7 @@ interface NodeData {
disableCopy?: boolean// 是否禁用复制
createIndexPosition?: number// 创建索引位置
isActive?: boolean// 是否激活
versionImgUpdataList?: Array<any>// 版本节点
}
interface NodeOptions {
id?: string
@@ -98,7 +99,6 @@ export class NodeManager {
}
/** 创建结果节点 */
createResultNode(options?: NodeOptions) {
console.log(options)
const options_ = {
...(options ? options : {}),
component: NODE_COMPONENT.RESULT_IMAGE,

View File

@@ -4,6 +4,7 @@ import { ElMessageBox } from 'element-plus'
import i18n from '@/lang'
import { putSketchFlowCanvas } from '@/api/flow-canvas'
import myEvent from '@/utils/myEvent'
import { updateVersionSketchUrlApi } from '@/api/flow-canvas'
const t = i18n.global.t
@@ -161,6 +162,8 @@ export class StateManager {
this.nodes.value = this.nodes.value.filter((node: NodesItem) => node.id !== id)
}
/** 获取初始节点 */
getInitialNode() { return this.nodes.value.find((node: NodesItem) => node?.data?.versionImgUpdataList) }
/** 获取节点 */
getNodeById(id: string) { return this.nodes.value.find((node: NodesItem) => node.id === id) }
/** 获取下级节点 */
@@ -186,12 +189,19 @@ export class StateManager {
if (node.data.disableDelete) return ElMessage.error(t('FlowCanvas.initialNodeProhibited'))
const result = [node]
const deleteVersionImgUpdataList = []
node.data.data?.imageProcessTasks?.forEach((item) =>{
deleteVersionImgUpdataList.push(item.url)
})
const findChildren = (parentId: string) => {
const children = this.nodes.value.filter(item => item.data.superiorID === parentId)
children.forEach(child => {
if(child.data.type !== NODE_DATATYPE.RESULT_IMAGE){
result.push(child)
console.log(child)
child.data.data?.imageProcessTasks?.forEach((item) =>{
deleteVersionImgUpdataList.push(item.url)
})
}
findChildren(child.id)
})
@@ -215,6 +225,22 @@ export class StateManager {
}
if(!deletePromise) return console.log('删除操作被取消')
// 删除如果是最后一张图需要更新版本图url
let initialNode = this.getInitialNode()
let updataListIndex
let isUpdataEndUrl = false
deleteVersionImgUpdataList?.forEach((item) => {
updataListIndex = initialNode.data.versionImgUpdataList.indexOf(item)
if(updataListIndex == (initialNode.data.versionImgUpdataList.length - 1))isUpdataEndUrl = true
if(initialNode.data.versionImgUpdataList.length > 1)initialNode.data.versionImgUpdataList = initialNode.data.versionImgUpdataList.filter((v) => v !== item)
})
if(isUpdataEndUrl){
updateVersionSketchUrlApi({
sketchId: this.sketchId.value,
newUrl: initialNode.data.versionImgUpdataList[initialNode.data.versionImgUpdataList.length - 1],
})
}
if(node.data.data?.imageProcessTasks?.length > 1){
node.data.data.imageProcessTasks = node.data.data.imageProcessTasks.filter((item) => item.taskId !== node.data.data.selectTaskId)
return
@@ -263,7 +289,7 @@ export class StateManager {
this.historyIndex.value = this.historyList.value.length - 1
}
/** 画布数据存储 */
async exportFlow (time:number = 0){
async exportFlow (time:number = 0,loading:boolean = false){
if(!this.sketchId.value)return
clearTimeout(this.saveCanvasTime)
await new Promise((resolve) => {
@@ -272,7 +298,7 @@ export class StateManager {
id: this.sketchId.value,
canvasData: JSON.stringify(this.nodes.value) }).then(() => {
resolve(true)
}).catch(() => {
},loading).catch(() => {
resolve(true)
})
},time)