fix
This commit is contained in:
@@ -31,6 +31,9 @@ export const putSketchFlowCanvas = (data:saveSketchFlowCanvasData) => {
|
|||||||
return request({
|
return request({
|
||||||
url: `/api/canvas/detail/${data.id}`,
|
url: `/api/canvas/detail/${data.id}`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
data: data.canvasData
|
data: data.canvasData
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -52,3 +55,54 @@ export const deleteSketchFlowCanvas = (data:deleteSketchFlowCanvasData) => {
|
|||||||
method: 'delete',
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据taskId查询结果
|
||||||
|
* @param data 根据taskId查询结果的参数
|
||||||
|
* @param data.taskIds taskIds列表
|
||||||
|
* @returns 根据taskId查询结果
|
||||||
|
*/
|
||||||
|
export interface taskIdList {
|
||||||
|
taskIds?: Array<string>
|
||||||
|
}
|
||||||
|
export const getTaskidResult = (data:taskIdList) => {
|
||||||
|
return request({
|
||||||
|
url: `/api/image/tasks/batch`,
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
taskIds: data.taskIds
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片转真是风格
|
||||||
|
* @param data 图片转真是风格的参数
|
||||||
|
* @param data.sketchId sketch id
|
||||||
|
* @param data.mode 选择的模型
|
||||||
|
* @param data.size 生成图片的大小
|
||||||
|
* @param data.imageUrl 进行生成的图片。minio地址和正常地址都可以
|
||||||
|
* @param data.userPrompt 生成图片的提示词
|
||||||
|
* @returns 图片转真是风格
|
||||||
|
*/
|
||||||
|
export interface toRealStyleData {
|
||||||
|
sketchId?: string
|
||||||
|
mode?: string
|
||||||
|
size?: string
|
||||||
|
imageUrl?: string
|
||||||
|
userPrompt?: string
|
||||||
|
}
|
||||||
|
export const toRealStyleApi = (data:toRealStyleData) => {
|
||||||
|
return request({
|
||||||
|
url: `/api/image/to-real-style`,
|
||||||
|
method: 'post',
|
||||||
|
data:{
|
||||||
|
sketchId: data.sketchId,
|
||||||
|
mode: data.mode,
|
||||||
|
size: data.size,
|
||||||
|
imageUrl: data.imageUrl,
|
||||||
|
userPrompt: data.userPrompt
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,12 @@
|
|||||||
)
|
)
|
||||||
const onAdd = () => {
|
const onAdd = () => {
|
||||||
const tier_ = tier.value + 1
|
const tier_ = tier.value + 1
|
||||||
|
// 从data中获取originalImage
|
||||||
|
let nodeData = props.node?.data?.data.imageProcessTasks.filter((v) => v.taskId === props.node?.data?.data.selectTaskId)
|
||||||
|
const originalImage = nodeData[0]?.url
|
||||||
|
if(!originalImage)console.log('originalImage 找不到原始图片')
|
||||||
props.stateManager.nodeManager.createCardsSelect({
|
props.stateManager.nodeManager.createCardsSelect({
|
||||||
data: { tier: tier_, superiorID: props.node.id }
|
data: { tier: tier_, superiorID: props.node.id, originalImage }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const posCenter = computed(() => {
|
const posCenter = computed(() => {
|
||||||
|
|||||||
@@ -60,7 +60,8 @@
|
|||||||
data: {
|
data: {
|
||||||
tier: v.tier,
|
tier: v.tier,
|
||||||
type: v.type,
|
type: v.type,
|
||||||
superiorID
|
superiorID,
|
||||||
|
originalImage: props.node.data?.originalImage,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
import To3View from './to-3view.vue'
|
import To3View from './to-3view.vue'
|
||||||
import To3DModel from './to-3d-model.vue'
|
import To3DModel from './to-3d-model.vue'
|
||||||
|
|
||||||
|
import { toRealStyleApi } from '@/api/flow-canvas'
|
||||||
|
|
||||||
// import ToVideo from './to-video.vue'
|
// import ToVideo from './to-video.vue'
|
||||||
// import AddPrint from './add-print.vue'
|
// import AddPrint from './add-print.vue'
|
||||||
// import ToCAD from './to-cad.vue'
|
// import ToCAD from './to-cad.vue'
|
||||||
@@ -46,19 +48,20 @@
|
|||||||
title: 'Advanced Tools',
|
title: 'Advanced Tools',
|
||||||
component: CardsSelect,
|
component: CardsSelect,
|
||||||
hideFooter: true,
|
hideFooter: true,
|
||||||
hideIcon: true
|
hideIcon: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tier: NODE_DATATIER.TO_REAL_STYLE,
|
tier: NODE_DATATIER.TO_REAL_STYLE,
|
||||||
type: NODE_DATATYPE.TO_REAL_STYLE,
|
type: NODE_DATATYPE.TO_REAL_STYLE,
|
||||||
title: 'To Real Style',
|
title: 'To Real Style',
|
||||||
component: ToRealStyle
|
component: ToRealStyle,
|
||||||
|
api: toRealStyleApi
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tier: NODE_DATATIER.SURFACE_EDIT,
|
tier: NODE_DATATIER.SURFACE_EDIT,
|
||||||
type: NODE_DATATYPE.SURFACE_EDIT,
|
type: NODE_DATATYPE.SURFACE_EDIT,
|
||||||
title: 'Surface Edit',
|
title: 'Surface Edit',
|
||||||
component: SurfaceEdit
|
component: SurfaceEdit,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tier: NODE_DATATIER.SCENE_COMPOSITION,
|
tier: NODE_DATATIER.SCENE_COMPOSITION,
|
||||||
@@ -100,6 +103,10 @@
|
|||||||
| 'to-3view',
|
| 'to-3view',
|
||||||
default: 'to-real-style'
|
default: 'to-real-style'
|
||||||
},
|
},
|
||||||
|
sketchId: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
@@ -110,17 +117,32 @@
|
|||||||
return components.find((item) => item.type === props.type)
|
return components.find((item) => item.type === props.type)
|
||||||
})
|
})
|
||||||
const componentRef = ref(null)
|
const componentRef = ref(null)
|
||||||
const onGenerateClick = () => {
|
|
||||||
|
const onGenerateClick = async () => {
|
||||||
const data = componentRef.value.data
|
const data = componentRef.value.data
|
||||||
const subordNode = stateManager.getSubordNodeByID(attrs.node.id)
|
const subordNode = stateManager.getSubordNodeByID(attrs.node.id)
|
||||||
emit('update-data', data)
|
emit('update-data', data)
|
||||||
|
console.log(attrs.node,data)
|
||||||
|
if(!attrs.node?.data?.originalImage)console.log('originalImage 找不到原始图片')
|
||||||
|
|
||||||
|
const apiData = {
|
||||||
|
sketchId: props.sketchId,
|
||||||
|
mode: data.mode,
|
||||||
|
size: data.pixelRatio,
|
||||||
|
imageUrl: attrs.node?.data?.originalImage,
|
||||||
|
userPrompt: data.prompt,
|
||||||
|
}
|
||||||
|
const taskList = await currentComponent.value.api(apiData).then((rv)=>{
|
||||||
|
return rv
|
||||||
|
}) || []
|
||||||
if (!subordNode) {
|
if (!subordNode) {
|
||||||
nodeManager.createResultNode({
|
nodeManager.createResultNode({
|
||||||
data: {
|
data: {
|
||||||
superiorID: attrs.node.id,
|
superiorID: attrs.node.id,
|
||||||
tier: currentComponent.value.tier,
|
tier: currentComponent.value.tier,
|
||||||
data: {
|
data: {
|
||||||
url: 'https://s3-alpha-sig.figma.com/img/ea2f/590e/9638f62a2fc91e31f33db0022db1642c?Expires=1773014400&Key-Pair-Id=APKAQ4GOSFWCW27IBOMQ&Signature=M0B8oJJOk~dGG0aZAqOIocAp7T0LFdJ9FYmCrEZVTCRzYxM6SJRNtYMTX-rTO3Z~s14QINh~o-S41XiZnBv-0zcKjuWot~VVaNHfd0~1LesfNe2KwvCinT~72btFut1pheLnKE-wWCX5ewtonxU77bnw386YPMTqv7DBZzksf2udsJA7NmOYD6~TUG3Q2dWSt~zPH~lkaidscPqpCnCbqzljCEi4RiHY4U3A45l5XypcX2umqn1UaYUFCTqV9471J4qdB6Dg2pcKocdp-7-3s1De6Q~2SmBOrSgDQ~KEADCB2lhKfhxgWmy0lwMvhTd4l90ygVZDWZRABgjHNrGUvg__'
|
imageProcessTasks:taskList,
|
||||||
|
selectTaskId:taskList[0].taskId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,49 +1,56 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 结果图片 -->
|
<!-- 结果图片 -->
|
||||||
<div class="result-image">
|
<div class="result-image-container" :class="{'show-border': data.imageProcessTasks.length > 1}">
|
||||||
<div class="header" v-show="showHeader" @mousedown.stop>
|
<div class="result-image"
|
||||||
<span class="icon">
|
v-for="(item, i) in data.imageProcessTasks"
|
||||||
<svg-icon name="chat-compose" size="20" size-unit="px" />
|
:key="item.taskId"
|
||||||
</span>
|
:class="{'active': item.taskId === data.selectTaskId}"
|
||||||
<span class="icon" @click="onPreview">
|
@click="setSelectTaskId(item.taskId)"
|
||||||
<svg-icon name="expand-lg" size="20" size-unit="px" />
|
>
|
||||||
</span>
|
<div class="header" v-show="showHeader && item.taskId === data.selectTaskId" @mousedown.stop>
|
||||||
<span class="icon" @click="onDownload">
|
<span class="icon">
|
||||||
<svg-icon name="download" size="20" size-unit="px" />
|
<svg-icon name="chat-compose" size="20" size-unit="px" />
|
||||||
</span>
|
</span>
|
||||||
<button class="edit" @click="onEdit">
|
<span class="icon" @click="onPreview(item?.url)">
|
||||||
<span class="icon"><svg-icon name="edit" size="13" /></span>
|
<svg-icon name="expand-lg" size="20" size-unit="px" />
|
||||||
<span class="text">Edit</span>
|
</span>
|
||||||
</button>
|
<span class="icon" @click="onDownload(item?.url)">
|
||||||
</div>
|
<svg-icon name="download" size="20" size-unit="px" />
|
||||||
<img
|
</span>
|
||||||
class="image"
|
<button class="edit" @click="onEdit(item?.url)">
|
||||||
:src="data.url"
|
<span class="icon"><svg-icon name="edit" size="13" /></span>
|
||||||
:style="{ transform: `scale(${data?.scale?.x || 1}, ${data?.scale?.y || 1})` }"
|
<span class="text">Edit</span>
|
||||||
/>
|
</button>
|
||||||
<div class="more" @click="showMenu = !showMenu" @mousedown.stop>
|
</div>
|
||||||
<svg-icon name="more" size="24" size-unit="px" color="#C9C9C9" />
|
<img
|
||||||
</div>
|
class="image"
|
||||||
<div class="menu" v-show="showMenu" @mousedown.stop>
|
:src="item?.url"
|
||||||
<div
|
:style="{ transform: `scale(${item?.scale?.x || 1}, ${item?.scale?.y || 1})` }"
|
||||||
v-for="(v, i) in menus"
|
/>
|
||||||
:key="i"
|
<div class="more" @click="clickimageProcessTaskItem(item.taskId)" @mousedown.stop>
|
||||||
:class="[v.isDivide ? 'divide' : 'item', { disabled: v.disabled }]"
|
<svg-icon name="more" size="24" size-unit="px" color="#C9C9C9" />
|
||||||
@click="onMenuItem(v)"
|
</div>
|
||||||
>
|
<div class="menu" v-show="showMenu && item.taskId === clickTaskId" @mousedown.stop>
|
||||||
<template v-if="!v.isDivide">
|
<div
|
||||||
<span class="label">{{ v.label }}</span>
|
v-for="(v, i) in menus"
|
||||||
<span class="tip">{{ v.tip }}</span>
|
:key="i"
|
||||||
</template>
|
:class="[v.isDivide ? 'divide' : 'item', { disabled: v.disabled }]"
|
||||||
|
@click="onMenuItem(v)"
|
||||||
|
>
|
||||||
|
<template v-if="!v.isDivide">
|
||||||
|
<span class="label">{{ v.label }}</span>
|
||||||
|
<span class="tip">{{ v.tip }}</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import myEvent from '@/utils/myEvent'
|
import myEvent from '@/utils/myEvent'
|
||||||
import { downloadImage } from '../../../tools/tools'
|
import { downloadImage } from '../../../tools/tools'
|
||||||
import { reactive, ref, onBeforeUnmount, useAttrs, inject, watch } from 'vue'
|
import { reactive, ref, onBeforeUnmount, useAttrs, inject, watch, } from 'vue'
|
||||||
const openImagePreview = inject('openImagePreview') as (url: string) => void
|
const openImagePreview = inject('openImagePreview') as (url: string) => void
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
config: {
|
config: {
|
||||||
@@ -65,10 +72,21 @@
|
|||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
const showHeader = ref(!!attrs.node?.data?.isHeader)
|
const showHeader = ref(!!attrs.node?.data?.isHeader)
|
||||||
const showMenu = ref(false)
|
const showMenu = ref(false)
|
||||||
|
const clickTaskId = ref('')
|
||||||
|
const clickimageProcessTaskItem = (taskId: string) => {
|
||||||
|
if(clickTaskId.value == taskId){
|
||||||
|
showMenu.value = !showMenu.value
|
||||||
|
}
|
||||||
|
clickTaskId.value = taskId
|
||||||
|
}
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
url: props.data?.url || '',
|
selectTaskId: props.data?.selectTaskId || '',
|
||||||
scale: props.data?.scale || { x: 1, y: 1 }
|
imageProcessTasks: props.data?.imageProcessTasks || [],
|
||||||
})
|
})
|
||||||
|
const setSelectTaskId = (taskId: string) => {
|
||||||
|
data.selectTaskId = taskId
|
||||||
|
emit('update-data', data)
|
||||||
|
}
|
||||||
watch(
|
watch(
|
||||||
() => props.data.url,
|
() => props.data.url,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
@@ -76,34 +94,49 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
const menus = ref([
|
const menus = ref([
|
||||||
{ label: 'Copy', tip: 'Ctrl+C', on: () => emit('copy-node') },
|
{ label: 'Copy', tip: 'Ctrl+C', on: () => emit('copy-node', clickTaskId.value) },
|
||||||
{
|
{
|
||||||
label: 'Delete',
|
label: 'Delete',
|
||||||
tip: 'Del',
|
tip: 'Del',
|
||||||
on: () => emit('delete-node'),
|
on: () => {
|
||||||
|
if(data.imageProcessTasks.length > 1){
|
||||||
|
if(clickTaskId.value){
|
||||||
|
data.imageProcessTasks = data.imageProcessTasks.filter((item) => item.taskId !== clickTaskId.value)
|
||||||
|
clickTaskId.value = ''
|
||||||
|
emit('update-data', data)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
emit('delete-node')
|
||||||
|
}
|
||||||
|
},
|
||||||
disabled: !!props.config?.disableDelete
|
disabled: !!props.config?.disableDelete
|
||||||
},
|
},
|
||||||
{ isDivide: true },
|
{ isDivide: true },
|
||||||
{
|
// {
|
||||||
label: 'Bring to font',
|
// label: 'Bring to font',
|
||||||
tip: '',
|
// tip: '',
|
||||||
on: () => {
|
// on: () => {
|
||||||
emit('bring-to-font')
|
// emit('bring-to-font')
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
label: 'Send to back',
|
// label: 'Send to back',
|
||||||
tip: '',
|
// tip: '',
|
||||||
on: () => {
|
// on: () => {
|
||||||
emit('send-to-back')
|
// emit('send-to-back')
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{ isDivide: true },
|
// { isDivide: true },
|
||||||
{
|
{
|
||||||
label: 'Flip horizontal',
|
label: 'Flip horizontal',
|
||||||
tip: '',
|
tip: '',
|
||||||
on: () => {
|
on: () => {
|
||||||
data.scale.x = -data.scale.x
|
data.imageProcessTasks.forEach((item) => {
|
||||||
|
if(!item.scale){
|
||||||
|
item.scale = { x: 1, y: 1 }
|
||||||
|
}
|
||||||
|
item.scale.x = -item.scale.x
|
||||||
|
})
|
||||||
emit('update-data', data)
|
emit('update-data', data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -111,16 +144,21 @@
|
|||||||
label: 'Flip vertical',
|
label: 'Flip vertical',
|
||||||
tip: '',
|
tip: '',
|
||||||
on: () => {
|
on: () => {
|
||||||
data.scale.y = -data.scale.y
|
data.imageProcessTasks.forEach((item) => {
|
||||||
|
if(!item.scale){
|
||||||
|
item.scale = { x: 1, y: 1 }
|
||||||
|
}
|
||||||
|
item.scale.y = -item.scale.y
|
||||||
|
})
|
||||||
emit('update-data', data)
|
emit('update-data', data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
const onPreview = () => {
|
const onPreview = (url: string) => {
|
||||||
openImagePreview(data.url)
|
openImagePreview(url)
|
||||||
}
|
}
|
||||||
const onDownload = () => {
|
const onDownload = (url: string) => {
|
||||||
downloadImage(data.url, 'image.png')
|
downloadImage(url, 'image.png')
|
||||||
}
|
}
|
||||||
const onMenuItem = (v) => {
|
const onMenuItem = (v) => {
|
||||||
if (v.disabled) return
|
if (v.disabled) return
|
||||||
@@ -129,9 +167,10 @@
|
|||||||
}
|
}
|
||||||
const hideMenu = () => {
|
const hideMenu = () => {
|
||||||
showMenu.value = false
|
showMenu.value = false
|
||||||
|
clickTaskId.value = ''
|
||||||
}
|
}
|
||||||
const onEdit = () => {
|
const onEdit = (url: string) => {
|
||||||
myEvent.emit('openDepthCanvas', { url: data.url })
|
myEvent.emit('openDepthCanvas', { url })
|
||||||
}
|
}
|
||||||
document.addEventListener('mousedown', hideMenu)
|
document.addEventListener('mousedown', hideMenu)
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@@ -141,6 +180,16 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
.result-image-container{
|
||||||
|
&.show-border{
|
||||||
|
border: 1px solid #d9d9d9;
|
||||||
|
border-radius: 9.4px;
|
||||||
|
padding: 16px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr); /* 一行3列 */
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
.result-image {
|
.result-image {
|
||||||
width: 244px;
|
width: 244px;
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
|
|||||||
@@ -31,10 +31,11 @@
|
|||||||
:active="stateManager.activeNodeID.value === node.id"
|
:active="stateManager.activeNodeID.value === node.id"
|
||||||
:node="node"
|
:node="node"
|
||||||
:config="node.data"
|
:config="node.data"
|
||||||
|
:sketchId="config.imgId"
|
||||||
:data="node.data.data"
|
:data="node.data.data"
|
||||||
v-bind="node.data"
|
v-bind="node.data"
|
||||||
@delete-node="deleteNode(node.id)"
|
@delete-node="deleteNode(node.id)"
|
||||||
@copy-node="copyNode(node.id)"
|
@copy-node="copyNode($event,node.id)"
|
||||||
@update-data="(v) => (node.data.data = v)"
|
@update-data="(v) => (node.data.data = v)"
|
||||||
@bring-to-font="bringToFont(node.id)"
|
@bring-to-font="bringToFont(node.id)"
|
||||||
@send-to-back="sendToBack(node.id)"
|
@send-to-back="sendToBack(node.id)"
|
||||||
@@ -157,8 +158,8 @@
|
|||||||
nodeManager.deleteNode(id)
|
nodeManager.deleteNode(id)
|
||||||
}
|
}
|
||||||
/** 复制节点 */
|
/** 复制节点 */
|
||||||
const copyNode = (id) => {
|
const copyNode = (clickTaskId,id) => {
|
||||||
nodeManager.copyNodeById(id)
|
nodeManager.copyNodeById(clickTaskId,id)
|
||||||
}
|
}
|
||||||
/** 节点zIndex设置最大 */
|
/** 节点zIndex设置最大 */
|
||||||
const bringToFont = (id) => {
|
const bringToFont = (id) => {
|
||||||
@@ -171,11 +172,11 @@
|
|||||||
// 导出流程
|
// 导出流程
|
||||||
const exportFlow = () => {
|
const exportFlow = () => {
|
||||||
// flowManager.exportFlow()
|
// flowManager.exportFlow()
|
||||||
|
|
||||||
const str = JSON.stringify(stateManager.nodes.value)
|
const str = JSON.stringify(stateManager.nodes.value)
|
||||||
const json = JSON.parse(str)
|
const json = JSON.parse(str)
|
||||||
putSketchFlowCanvas({
|
putSketchFlowCanvas({
|
||||||
id: props.config.id || '==========',
|
id: props.config.imgId,
|
||||||
canvasData: str
|
canvasData: str
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
@@ -214,10 +215,9 @@
|
|||||||
// window['nodes'] = nodes
|
// window['nodes'] = nodes
|
||||||
let json = []
|
let json = []
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
getSketchFlowCanvas({ id: props.config.id || '==========' }).then((res) => {
|
getSketchFlowCanvas({ id: props.config.imgId }).then((res:any) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
console.log(res)
|
json = JSON.parse(res)
|
||||||
json = res.data
|
|
||||||
}
|
}
|
||||||
resolve(true)
|
resolve(true)
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
@@ -227,12 +227,21 @@
|
|||||||
if(json.length > 0){
|
if(json.length > 0){
|
||||||
importFlow(json)
|
importFlow(json)
|
||||||
}else{
|
}else{
|
||||||
|
const timestamp = Date.now()
|
||||||
nodeManager.createResultNode({
|
nodeManager.createResultNode({
|
||||||
data: {
|
data: {
|
||||||
disableDelete: true,
|
disableDelete: true,
|
||||||
isHeader: false,
|
isHeader: false,
|
||||||
data: {
|
data: {
|
||||||
url: props.config.url
|
imageProcessTasks:[
|
||||||
|
{
|
||||||
|
id: props.config.imgId,
|
||||||
|
url: props.config.url,
|
||||||
|
state:'success',
|
||||||
|
taskId: timestamp + '',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
selectTaskId: timestamp + '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
33
src/components/Canvas/FlowCanvas/manager/GenerateManager.ts
Normal file
33
src/components/Canvas/FlowCanvas/manager/GenerateManager.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { getTaskidResult } from '@/api/flow-canvas'
|
||||||
|
interface NodeOptions {
|
||||||
|
id?: string
|
||||||
|
position?: { x: number, y: number }
|
||||||
|
positionX?: number
|
||||||
|
positionY?: number
|
||||||
|
component?: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GenerateManager {
|
||||||
|
stateManager: any
|
||||||
|
taskIds: string[] = []
|
||||||
|
constructor(options) {
|
||||||
|
this.stateManager = options.stateManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除taskId */
|
||||||
|
deleteTaskId(taskId: string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
/** 添加taskId */
|
||||||
|
addTaskId(TaskId: any) {
|
||||||
|
this.stateManager.addTaskId(TaskId)
|
||||||
|
}
|
||||||
|
/** 添加taskId */
|
||||||
|
async getTasksIdImg(list) {
|
||||||
|
let taskIds = list.map((item)=>item.taskId)
|
||||||
|
getTaskidResult({taskIds}).then((rv)=>{
|
||||||
|
console.log(rv)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ interface NodeData {
|
|||||||
superiorID?: string// 上级节点ID
|
superiorID?: string// 上级节点ID
|
||||||
disableDelete?: boolean// 是否禁用删除
|
disableDelete?: boolean// 是否禁用删除
|
||||||
disableCopy?: boolean// 是否禁用复制
|
disableCopy?: boolean// 是否禁用复制
|
||||||
|
originalImage?: string// 要进行生成的图片
|
||||||
}
|
}
|
||||||
interface NodeOptions {
|
interface NodeOptions {
|
||||||
id?: string
|
id?: string
|
||||||
@@ -113,13 +114,15 @@ export class NodeManager {
|
|||||||
return this.createNode(options_)
|
return this.createNode(options_)
|
||||||
}
|
}
|
||||||
|
|
||||||
copyNodeById(id: string) {
|
copyNodeById(clickTaskId:string, id: string) {
|
||||||
const node = this.stateManager.getNodeById(id)
|
const node = this.stateManager.getNodeById(id)
|
||||||
|
let copyNode = JSON.parse(JSON.stringify(node))
|
||||||
|
copyNode.data.data.imageProcessTasks = copyNode.data.data.imageProcessTasks.filter((item:any)=>item.taskId == clickTaskId)
|
||||||
const flowNode = this.stateManager.flowManager.getNodeById(id)
|
const flowNode = this.stateManager.flowManager.getNodeById(id)
|
||||||
if (!node) return console.warn(`${id}找不到对应节点`)
|
if (!node) return console.warn(`${id}找不到对应节点`)
|
||||||
if (node.data?.disableCopy) return console.warn(`${id}节点已禁用复制`)
|
if (node.data?.disableCopy) return console.warn(`${id}节点已禁用复制`)
|
||||||
const node_ = {
|
const node_ = {
|
||||||
...JSON.parse(JSON.stringify(node)),
|
...copyNode,
|
||||||
id: createId(),
|
id: createId(),
|
||||||
position: {
|
position: {
|
||||||
x: node.position.x,
|
x: node.position.x,
|
||||||
|
|||||||
Reference in New Issue
Block a user