This commit is contained in:
lzp
2026-03-23 16:43:09 +08:00
20 changed files with 268 additions and 128 deletions

View File

@@ -0,0 +1,3 @@
<svg width="8" height="5" viewBox="0 0 8 5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0.167367 0.183059C0.390523 -0.0610191 0.752332 -0.0610197 0.975489 0.183058L4.00001 3.49112L7.02451 0.183059C7.24767 -0.0610191 7.60948 -0.0610197 7.83263 0.183058C8.05579 0.427135 8.05579 0.822863 7.83263 1.06694L4.40407 4.81694C4.29691 4.93415 4.15156 5 4.00001 5C3.84846 5 3.70311 4.93415 3.59595 4.81694L0.167368 1.06694C-0.0557889 0.822865 -0.0557895 0.427137 0.167367 0.183059Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 516 B

View File

@@ -0,0 +1,3 @@
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 6C0 2.68629 2.68629 0 6 0C9.31371 0 12 2.68629 12 6C12 9.31371 9.31371 12 6 12C2.68629 12 0 9.31371 0 6ZM8.4453 3.55932C8.1743 3.36861 7.80002 3.43371 7.60932 3.7047L5.19026 7.14232L4.19396 6.0464C3.97106 5.8012 3.59159 5.78313 3.3464 6.00604C3.1012 6.22894 3.08313 6.60841 3.30604 6.8536L4.80604 8.5036C4.92853 8.63835 5.1056 8.71017 5.28736 8.69884C5.46911 8.6875 5.63588 8.59423 5.74068 8.4453L8.59068 4.3953C8.78139 4.1243 8.71629 3.75002 8.4453 3.55932Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -11,15 +11,12 @@
<div class="item" @mousedown="(e) => stateManager.setActiveNodeID(node.id)"> <div class="item" @mousedown="(e) => stateManager.setActiveNodeID(node.id)">
<slot></slot> <slot></slot>
</div> </div>
<div class="add" @mousedown.stop v-if="isAdd" @click="onAdd">
<svg-icon name="add" size="14" size-unit="px" />
</div>
<div class="mask" v-show="mask"></div> <div class="mask" v-show="mask"></div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { Handle, Position } from '@vue-flow/core' import { Handle, Position } from '@vue-flow/core'
import { NODE_DATATYPE, NODE_DATATIER, NODE_TYPE } from '../tools/index.d' import { NODE_DATATYPE, NODE_TYPE } from '../tools/index.d'
import { computed, ref, inject } from 'vue' import { computed, ref, inject } from 'vue'
const handles = ref({ const handles = ref({
[NODE_TYPE.INPUT]: [{ id: 'Right', type: 'source', position: Position.Right }], [NODE_TYPE.INPUT]: [{ id: 'Right', type: 'source', position: Position.Right }],
@@ -48,38 +45,6 @@
default: false default: false
} }
}) })
const stateManager = inject('stateManager') as any
const nodes = computed(() => props.stateManager.nodes.value)
const isSubord = computed(() => nodes.value.some((v) => v.data.superiorID === props.node.id))
const tier = computed(() => Number(props.node?.data?.tier || 0))
//只有3d模型才有三级菜单,目前三级菜单内容少直接禁用按钮
const isAdd3d = computed(() => (tier.value === 2 && props.node?.data?.superiorNodeType === NODE_DATATYPE.TO_3D_MODEL) || tier.value != 2)
const isReturned = computed(() => {
return (
props.node.data.type == NODE_DATATYPE.RESULT_IMAGE &&
props.node.data.data.imageProcessTasks[0].status == 'RETURNED'
)
})
const isAdd = computed(
() =>
!isSubord.value &&
NODE_DATATYPE.RESULT_IMAGE === props.node.data.type &&
!(tier.value === NODE_DATATIER.TO_3VIEW) &&
isReturned.value &&
isAdd3d.value
)
const onAdd = () => {
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({
data: { tier: tier_, superiorID: props.node.id, originalImage }
})
}
const posCenter = computed(() => { const posCenter = computed(() => {
const arr = [NODE_DATATYPE.RESULT_IMAGE] const arr = [NODE_DATATYPE.RESULT_IMAGE]
return arr.includes(props.node?.data?.type) return arr.includes(props.node?.data?.type)
@@ -105,25 +70,6 @@
> .item { > .item {
position: relative; position: relative;
} }
> .add {
position: absolute;
width: 32px;
height: 32px;
border: 2px solid #fff;
top: var(--top);
right: -16px;
transform: translateY(-50%);
background-color: #ed8936;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 25px;
box-shadow: 0 8px 20px 0 #71809633;
cursor: pointer;
z-index: 20;
}
&.center { &.center {
--top: 50%; --top: 50%;
} }

View File

@@ -69,28 +69,31 @@
const onClickItem = (v) => { const onClickItem = (v) => {
const id = props.node.id const id = props.node.id
if (!id) return if (!id) return
stateManager.deleteNode(id) const superiorID = props.node.data.superiorID
console.log(props.node)
if(v.secondaryMenu){ if(v.secondaryMenu){
nodeManager.createCardsSelect({ nodeManager.createCardsSelect({
data: { data: {
tier: props.node.data?.tier, tier: props.node.data?.tier,
superiorID: props.node.data?.superiorID, superiorID,
isActive: props.node.data?.isActive,
originalImage: props.node.data?.originalImage, originalImage: props.node.data?.originalImage,
secondaryMenu: v.secondaryMenu secondaryMenu: v.secondaryMenu,
createIndexPosition: props.node.data.createIndexPosition,
} }
}) })
}else{ }else{
const superiorID = props.node.data.superiorID
nodeManager.createCardNode({ nodeManager.createCardNode({
data: { data: {
tier: v.tier, tier: v.tier,
type: v.type, type: v.type,
superiorID, superiorID,
isActive: props.node.data?.isActive,
createIndexPosition: props.node.data.createIndexPosition,
originalImage: props.node.data?.originalImage, originalImage: props.node.data?.originalImage,
} }
}) })
} }
stateManager.deleteNode(id)
} }
defineExpose({}) defineExpose({})

View File

@@ -143,7 +143,6 @@
const onGenerateClick = async () => { const onGenerateClick = async () => {
const data = componentRef.value?.getApiData?.() || {} const data = componentRef.value?.getApiData?.() || {}
const subordNode = stateManager.getSubordNodeById(attrs.node.id)
const subordNodes = stateManager.getSubordNodes(attrs.node.id) const subordNodes = stateManager.getSubordNodes(attrs.node.id)
emit('update-data', componentRef.value?.data) emit('update-data', componentRef.value?.data)
if(!attrs.node?.data?.originalImage)console.log('originalImage 找不到原始图片') if(!attrs.node?.data?.originalImage)console.log('originalImage 找不到原始图片')
@@ -160,7 +159,7 @@
// if (!subordNode) { // if (!subordNode) {
//如果是添加印花的结果就作为一级节点可以再次选择添加印花或者生成真实图 //如果是添加印花的结果就作为一级节点可以再次选择添加印花或者生成真实图
let tier = NODE_DATATIER.Fast_MODE == currentComponent.value.tier?0:currentComponent.value.tier let tier = (NODE_DATATIER.Fast_MODE == currentComponent.value.tier && currentComponent.value.type == NODE_DATATYPE.Fast_MODE)?0:currentComponent.value.tier
taskList.forEach((item,index) => { taskList.forEach((item,index) => {
nodeManager.createResultNode({ nodeManager.createResultNode({
data: { data: {

View File

@@ -4,10 +4,10 @@
<div class="result-image" <div class="result-image"
v-for="(item, i) in data.imageProcessTasks" v-for="(item, i) in data.imageProcessTasks"
:key="item.taskId" :key="item.taskId"
:class="{'active': config.isActive}" :class="{'active': node.id == stateManager.activeNodeID.value}"
@click="setSelectTaskId(item.taskId)" @click="setSelectTaskId(item.taskId)"
> >
<div class="header" v-if="item.status == 'RETURNED'" v-show="showHeader && config.isActive" @mousedown.stop> <div class="header" v-if="item.status == 'RETURNED'" v-show="showHeader && node.id == stateManager.activeNodeID.value" @mousedown.stop>
<span class="icon"> <span class="icon">
<svg-icon name="chat-compose" size="20" size-unit="px" /> <svg-icon name="chat-compose" size="20" size-unit="px" />
</span> </span>
@@ -53,6 +53,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="add" @mousedown.stop v-if="isAdd" @click="onAdd">
<svg-icon name="add" size="14" size-unit="px" />
</div>
</div> </div>
</template> </template>
@@ -61,7 +64,7 @@
import { downloadImage } from '../../../tools/tools' import { downloadImage } from '../../../tools/tools'
import { reactive, ref, onBeforeUnmount, useAttrs, inject, watch, computed, onMounted } from 'vue' import { reactive, ref, onBeforeUnmount, useAttrs, inject, watch, computed, onMounted } from 'vue'
import HighlightAdmin from '@/components/highlightAdmin.vue' import HighlightAdmin from '@/components/highlightAdmin.vue'
import { NODE_DATATYPE } from '../../tools/index.d' import { NODE_DATATIER, NODE_DATATYPE } from '../../tools/index.d'
const openImagePreview = inject('openImagePreview') as (url: string) => void const openImagePreview = inject('openImagePreview') as (url: string) => void
const openThreeModelPreview = inject('openThreeModelPreview') as (url: string) => void const openThreeModelPreview = inject('openThreeModelPreview') as (url: string) => void
const props = defineProps({ const props = defineProps({
@@ -86,7 +89,8 @@
'update-data' 'update-data'
]) ])
// const attrs = useAttrs() // const attrs = useAttrs()
const showHeader = ref(!!props.node?.data?.isHeader) const showHeader = ref(true)
// const showHeader = ref(!!props.node?.data?.isHeader)
const showMenu = ref(false) const showMenu = ref(false)
const clickTaskId = ref('') const clickTaskId = ref('')
const generateManager = inject('generateManager') as any const generateManager = inject('generateManager') as any
@@ -228,6 +232,45 @@
eventManager.removeEvents() eventManager.removeEvents()
myEvent.emit('openDepthCanvas', data) myEvent.emit('openDepthCanvas', data)
} }
const isSubord = computed(() => props.node.id == stateManager.activeNodeID.value)
const tier = computed(() => Number(props.node?.data?.tier || 0))
//只有3d模型才有三级菜单,目前三级菜单内容少直接禁用按钮
const isAdd3d = computed(() => (tier.value === 2 && props.node?.data?.superiorNodeType === NODE_DATATYPE.TO_3D_MODEL) || props.node?.data?.superiorNodeType !== NODE_DATATYPE.TO_3D_MODEL)
const isReturned = computed(() => {
return (
props.node.data.type == NODE_DATATYPE.RESULT_IMAGE &&
props.node.data.data.imageProcessTasks[0].status == 'RETURNED'
)
})
const isAdd = computed(
() =>
NODE_DATATYPE.RESULT_IMAGE === props.node.data.type &&
!(tier.value === NODE_DATATIER.TO_3VIEW) &&
isReturned.value &&
isAdd3d.value &&
isSubord.value
)
const onAdd = () => {
const tier_ = tier.value + 1
// 从data中获取originalImage
let nodeData = props.node?.data?.data.imageProcessTasks.filter(
(v) => v.taskId === props.node?.data?.data.selectTaskId
)
const subordNodes = stateManager.getSubordNodes(props.node.id)
const originalImage = nodeData[0]?.url
if (!originalImage) console.log('originalImage 找不到原始图片')
stateManager.nodeManager.createCardsSelect({
data: {
tier: tier_,
superiorID: props.node.id,
originalImage,
createIndexPosition: subordNodes.length + 1,
isActive: subordNodes.length == 0
}
})
stateManager.setActiveNodeID('')
}
document.addEventListener('mousedown', hideMenu) document.addEventListener('mousedown', hideMenu)
onBeforeUnmount(() => { onBeforeUnmount(() => {
document.removeEventListener('mousedown', hideMenu) document.removeEventListener('mousedown', hideMenu)
@@ -249,6 +292,25 @@
gap: 8px; gap: 8px;
} }
} }
.add {
position: absolute;
width: 32px;
height: 32px;
border: 2px solid #fff;
top: var(--top);
right: -16px;
transform: translateY(-50%);
background-color: #ed8936;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 25px;
box-shadow: 0 8px 20px 0 #71809633;
cursor: pointer;
z-index: 20;
}
.result-image { .result-image {
width: 244px; width: 244px;
border-radius: 16px; border-radius: 16px;

View File

@@ -45,24 +45,27 @@ export class NodeManager {
/** 创建节点 */ /** 创建节点 */
createNode(options: NodeOptions) { createNode(options: NodeOptions) {
const superiorID = options?.data?.superiorID const superiorID = options?.data?.superiorID
const snode = superiorID ? this.stateManager.flowManager.getNodeById(superiorID) : this.stateManager.flowManager.getLastNode();
//获取上级节点所生成的最后一个node设置位置为最后一个节点的xy 加上 节点间距 //获取上级节点所生成的最后一个node设置位置为最后一个节点的xy 加上 节点间距
const superiorGenerateNodes = this.stateManager.getSubordNodes(superiorID) const superiorGenerateNodes = this.stateManager.getSubordNodes(superiorID)
const currentNode = superiorGenerateNodes.find((node) => {
return node.data.createIndexPosition === options?.data?.createIndexPosition
})
const endGenerateNode = superiorGenerateNodes.reduce((max, current) => { const endGenerateNode = superiorGenerateNodes.reduce((max, current) => {
return current.data.createIndexPosition > max.data.createIndexPosition ? current : max return current.data.createIndexPosition > max.data.createIndexPosition ? current : max
}, superiorGenerateNodes[0]) }, superiorGenerateNodes[0])
const snode = superiorID ? this.stateManager.flowManager.getNodeById(superiorID) : this.stateManager.flowManager.getLastNode();
const id = options.id || createId() const id = options.id || createId()
const positionX = options.positionX || 0 const positionX = options.positionX || 0
const positionY = options.positionY || 0 const positionY = options.positionY || 0
const position = options.position || const position = options.position ||
( (
endGenerateNode? currentNode ?
currentNode.position :
endGenerateNode ?
{ {
x: endGenerateNode.position.x + positionX, x: endGenerateNode.position.x + positionX,
y: endGenerateNode.position.y + positionY + this.ranksep + 200 y: endGenerateNode.position.y + positionY + this.ranksep + 200
} : } :
!snode ?
{ x: positionX, y: positionY } :
{ {
x: snode.position.x + snode.dimensions.width + this.nodesep + positionX, x: snode.position.x + snode.dimensions.width + this.nodesep + positionX,
y: snode.position.y + positionY y: snode.position.y + positionY
@@ -103,6 +106,7 @@ export class NodeManager {
data: { data: {
tier: NODE_DATATIER.CARDS_SELECT, tier: NODE_DATATIER.CARDS_SELECT,
type: NODE_DATATYPE.CARDS_SELECT, type: NODE_DATATYPE.CARDS_SELECT,
createIndexPosition: options?.data?.createIndexPosition || 1,
...(options?.data || {}), ...(options?.data || {}),
}, },
} }
@@ -113,7 +117,7 @@ export class NodeManager {
const options_ = { const options_ = {
...(options ? options : {}), ...(options ? options : {}),
component: NODE_COMPONENT.CARD, component: NODE_COMPONENT.CARD,
data: { data: {
...(options?.data || {}), ...(options?.data || {}),
} }
} }

View File

@@ -101,7 +101,7 @@ export class StateManager {
source: source, source: source,
target: target, target: target,
selectable: false, selectable: false,
visible: (node.data.type !== NODE_DATATYPE.RESULT_IMAGE || node.data.isActive), visible: (node.data.isActive),
type: 'default' type: 'default'
}) })
} }
@@ -223,8 +223,7 @@ export class StateManager {
/** 显示指定子节点和父节点连接线,隐藏父节点和其他子节点链接线, */ /** 显示指定子节点和父节点连接线,隐藏父节点和其他子节点链接线, */
showNodeConnections(id: string) { showNodeConnections(id: string) {
const node = this.getNodeById(id) const node = this.getNodeById(id)
if(node.data.component != NODE_DATATYPE.RESULT_IMAGE && node.data.superiorID) return if(!node.data.superiorID) return
let edges_ = JSON.parse(JSON.stringify(this.edges.value))
this.nodes.value.forEach((nodeItem) => { this.nodes.value.forEach((nodeItem) => {
if(node.data.superiorID === nodeItem.data.superiorID && nodeItem.id == id) { if(node.data.superiorID === nodeItem.data.superiorID && nodeItem.id == id) {
nodeItem.data.isActive = true nodeItem.data.isActive = true

View File

@@ -15,7 +15,8 @@ import { computed } from "vue";
const props = defineProps({ const props = defineProps({
name: { name: {
type: String, type: String,
required: true, default: "",
// required: true,
}, },
color: { color: {
type: String, type: String,
@@ -30,7 +31,7 @@ const props = defineProps({
default: 'rem', default: 'rem',
} }
}); });
const iconName = computed(() => `#icon-${props.name}`); const iconName = computed(() => `#icon-${props?.name}`);
const svgClass = computed(() => { const svgClass = computed(() => {
if (props.name) return `svg-icon icon-${props.name}`; if (props.name) return `svg-icon icon-${props.name}`;
return "svg-icon"; return "svg-icon";

View File

@@ -154,6 +154,7 @@ export default {
Download: 'Download', Download: 'Download',
deleteSuccess: 'Successfully deleted', deleteSuccess: 'Successfully deleted',
thinking: 'Thinking...', thinking: 'Thinking...',
thinkComplete: 'Thinking complete.',
}, },
// Version Tree // Version Tree

View File

@@ -148,7 +148,8 @@ export default {
'复制失败。您的浏览器可能限制了剪贴板访问,请允许浏览器访问剪贴板或尝试手动复制。', '复制失败。您的浏览器可能限制了剪贴板访问,请允许浏览器访问剪贴板或尝试手动复制。',
Download: '下载', Download: '下载',
deleteSuccess: '删除成功', deleteSuccess: '删除成功',
thinking:'已思考' thinking:'已思考',
thinkComplete: '思考完成。'
}, },
// Version Tree // Version Tree

View File

@@ -156,7 +156,6 @@
loading: true, loading: true,
thinking: false, thinking: false,
thinkingText: '', thinkingText: '',
thinkingCollapsed: false,
streaming: true streaming: true
}) })
messageList.value.push(aiMessage) messageList.value.push(aiMessage)
@@ -309,7 +308,7 @@
// } // }
if (eventName === 'tool') { if (eventName === 'tool') {
MyEvent.emit('loading-sketch') MyEvent.emit('loading-sketch', sketchList.value.length)
} }
if (dataLines.length === 0) continue if (dataLines.length === 0) continue
@@ -330,7 +329,10 @@
sketchList.value.push({ sketchList.value.push({
[Object.keys(jsonData)[0]]: jsonData[Object.keys(jsonData)[0]] [Object.keys(jsonData)[0]]: jsonData[Object.keys(jsonData)[0]]
}) })
// 通知 Preview 有新 sketch 正在加载,传入 sketch 索引
MyEvent.emit('loading-sketch', sketchList.value.length - 1)
MyEvent.emit('OpenSketch') MyEvent.emit('OpenSketch')
contentBody += `<slot slot-name="sketch"></slot>`
} }
if (eventName === 'report') { if (eventName === 'report') {
reportsContent.value += jsonData.report reportsContent.value += jsonData.report
@@ -575,6 +577,15 @@
// 延迟设置新数据,确保 UI 有时间响应清空操作 // 延迟设置新数据,确保 UI 有时间响应清空操作
nextTick(() => { nextTick(() => {
// 找到每个 sessionId 对应的最后一项插入sketch卡片
const sessionLastIndexMap = new Map<string, number>()
ancestorsList.forEach((item, index) => {
sessionLastIndexMap.set(item.sessionId, index)
})
sessionLastIndexMap.forEach((lastIndex) => {
ancestorsList[lastIndex].text += '<slot slot-name="sketch"></slot>'
})
messageList.value = [...ancestorsList] messageList.value = [...ancestorsList]
params.versionID = current?.id params.versionID = current?.id
sketchList.value = imgList sketchList.value = imgList

View File

@@ -16,22 +16,40 @@
class="img-item" class="img-item"
/> />
</div> </div>
<div class="message-context" v-show="content.thinkingText?.length > 0"> <!-- <div class="thinking-wrapper" v-show="content.thinkingText?.length > 0">
<div class="thinking"> <div class="thinking">
<div <div
class="thinking-header flex align-center" class="thinking-header flex align-center space-between"
@click="toggleThinkingCollapsed" @click="toggleThinkingCollapsed"
> >
<span>{{ t('agent.thinking') }}</span> <div class="left flex align-center">
<!-- <SvgIcon :name="content.thinkingCollapsed ? 'arrowDown' : 'arrowUp'" size="16" color="#666" /> --> <span class="think-title" v-show="content.thinking">{{
t('agent.thinking')
}}</span>
<SvgIcon
v-show="!content.thinking"
class="think-icon"
name="checked"
size="12"
color="#FF7A51"
/>
<span class="think-title" v-show="!content.thinking">{{
t('agent.thinkComplete')
}}</span>
</div>
<SvgIcon
:class="{ reverse: thinkingCollapsed }"
name="arrowDown"
size="16"
color="#FF7A51"
/>
</div> </div>
<div class="thinking-content" v-show="!content.thinkingCollapsed"> <div class="thinking-content" v-show="!thinkingCollapsed">
<pre>{{ content.thinkingText }}</pre> <pre>{{ content.thinkingText }}</pre>
</div> </div>
</div> </div>
</div> </div> -->
<div class="message-txt markdown-body flex flex-col"> <div class="message-txt markdown-body flex flex-col">
<!-- <div v-html="formatMessage"></div> -->
<VueMarkdown <VueMarkdown
:custom-attrs="customAttrs" :custom-attrs="customAttrs"
:markdown="content.text" :markdown="content.text"
@@ -43,6 +61,9 @@
<template v-slot:s-url="{ children: children }"> <template v-slot:s-url="{ children: children }">
<Url :list="content.webAddress" @click.native="handleClickUrls" /> <Url :list="content.webAddress" @click.native="handleClickUrls" />
</template> </template>
<template v-slot:s-sketch="{ children: children }">
<Sketch @click.native="handleClickSketch" />
</template>
</VueMarkdown> </VueMarkdown>
<div <div
class="web-address flex align-center" class="web-address flex align-center"
@@ -94,6 +115,7 @@
import agentThumb from '@/assets/images/agent-thumb.png' import agentThumb from '@/assets/images/agent-thumb.png'
import Card from './ReportCard.vue' import Card from './ReportCard.vue'
import Url from './UrlCard.vue' import Url from './UrlCard.vue'
import Sketch from './SketchCard.vue'
import { VueMarkdown } from '@crazydos/vue-markdown' import { VueMarkdown } from '@crazydos/vue-markdown'
import type { CustomAttrs } from '@crazydos/vue-markdown' import type { CustomAttrs } from '@crazydos/vue-markdown'
import rehypeRaw from 'rehype-raw' import rehypeRaw from 'rehype-raw'
@@ -228,9 +250,9 @@
}) })
} }
} }
const thinkingCollapsed = ref(true)
const toggleThinkingCollapsed = () => { const toggleThinkingCollapsed = () => {
props.content.thinkingCollapsed = !props.content.thinkingCollapsed thinkingCollapsed.value = !thinkingCollapsed.value
} }
const handleClickReport = () => { const handleClickReport = () => {
@@ -241,6 +263,9 @@
MyEvent.emit('openUrls', props.content.webAddress) MyEvent.emit('openUrls', props.content.webAddress)
// 点击显示来源 // 点击显示来源
} }
const handleClickSketch = () => {
MyEvent.emit('openSketch')
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@@ -327,24 +352,42 @@
} }
.thinking { .thinking {
border: 1px solid #ddd; color: #ff7a51;
border-radius: 8px; font-family: 'Medium';
padding: 1rem; margin-bottom: 1.6rem;
background-color: #f9f9f9; border: 0.1rem solid transparent;
border-radius: 0.4rem;
background: linear-gradient(#fffcf4, #fffcf4),
linear-gradient(
119.03deg,
rgba(233, 121, 60, 0.3) 1.61%,
rgba(255, 207, 144, 0.3) 101.01%
);
background-origin: padding-box, border-box;
background-clip: padding-box, border-box;
.thinking-header { .thinking-header {
cursor: pointer; cursor: pointer;
font-weight: bold; padding: 0.8rem 1.2rem;
justify-content: space-between; .think-icon {
margin-right: 0.6rem;
}
.reverse {
transform: rotate(180deg);
transition: transform 0.3s ease-in-out;
}
} }
.thinking-content { .thinking-content {
margin-top: 0.5rem; padding: 0 1.4rem 1.6rem;
pre { pre {
color: #f6a478;
margin: 0;
border-left: 0.035rem solid #f6a478;
white-space: pre-wrap; white-space: pre-wrap;
font-family: inherit; font-family: inherit;
font-size: 1.2rem; font-size: 1.2rem;
color: #666; padding-left: 1.2rem;
} }
} }
} }

View File

@@ -32,7 +32,8 @@
watch( watch(
() => props.messageList, () => props.messageList,
() => { (val) => {
console.log('messageList',val)
scrollToBottom() scrollToBottom()
}, },
{ deep: true } { deep: true }

View File

@@ -5,7 +5,6 @@
> >
<template v-if="type === 'sketch'"> <template v-if="type === 'sketch'">
<div <div
v-show="!showLoading"
class="sketch-item" class="sketch-item"
v-for="(item, index) in sketchList" v-for="(item, index) in sketchList"
:key="'sketch-item-' + index" :key="'sketch-item-' + index"
@@ -41,14 +40,16 @@
<div>Edit</div> <div>Edit</div>
<img src="@/assets/images/arrow-top-right.png" /> <img src="@/assets/images/arrow-top-right.png" />
</div> </div>
<!-- 已加载完成的 sketch 显示实际图片 -->
<img <img
:src="getImageSrc(item, index)" v-show="!pendingSketchIndexes.includes(index)"
:alt="'sketch-' + index" v-img-loading="getImageSrc(item, index)"
@load="handleImageLoad(index)" @load="handleImageLoad(index)"
/> />
</div> <!-- 正在加载的 sketch 显示 loading gif overlay -->
<div v-show="showLoading" class="sketch-item loading-gif"> <div v-if="pendingSketchIndexes.includes(index)" class="loading-wrapper">
<img src="@/assets/images/sketch-loading.gif" alt="loading" /> <img src="@/assets/images/sketch-loading.gif" alt="loading" />
</div>
</div> </div>
</template> </template>
<template v-else-if="type === 'url'"> <template v-else-if="type === 'url'">
@@ -113,7 +114,10 @@
const emits = defineEmits(['deleteSketch']) const emits = defineEmits(['deleteSketch'])
// 存储每个图片的加载状态 // 存储每个图片的加载状态
const loadedStatus = ref<boolean>(false) const loadedStatus = ref<boolean[]>([])
// 存储正在加载的 sketch 索引
const pendingSketchIndexes = ref<number[]>([])
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@@ -176,8 +180,14 @@
// 图片加载完成时触发 // 图片加载完成时触发
const handleImageLoad = (index: number) => { const handleImageLoad = (index: number) => {
loadedStatus[index] = true loadedStatus.value[index] = true
showLoading.value = false pendingSketchIndexes.value = pendingSketchIndexes.value.filter((i) => i !== index)
}
// 图片加载失败时触发
const handleImageError = (index: number) => {
pendingSketchIndexes.value = pendingSketchIndexes.value.filter((i) => i !== index)
console.error(`Failed to load sketch at index ${index}`)
} }
// 获取当前显示的图片源 // 获取当前显示的图片源
@@ -235,23 +245,42 @@
} }
const showLoading = ref(false) const showLoading = ref(false)
const handleLoadingSketch = () => { const handleLoadingSketch = (sketchIndex?: number) => {
showLoading.value = true showLoading.value = true
// 记录正在加载的 sketch 索引
if (sketchIndex !== undefined) {
pendingSketchIndexes.value.push(sketchIndex)
}
} }
const handleClickUrl = (item: { url: string, title: string }) => { const handleClickUrl = (item: { url: string; title: string }) => {
window.open(item.url, '_blank') window.open(item.url, '_blank')
} }
// watch( const vImgLoading = {
// () => props.sketchList, mounted(el, binding) {
// (val) => { // 1. 设置初始状态:显示 Loading 图(或者你可以从 binding.arg 传进来)
// if (val.length > 0) { const loadingUrl = LoadingImg
// showLoading.value = false const finalSrc = binding.value // 真正要加载的图
// }
// }, el.src = loadingUrl
// { deep: true }
// ) // 2. 预加载真实图片
const img = new Image()
img.src = finalSrc
img.onload = () => {
// 3. 加载完成后替换
el.src = finalSrc
el.style.opacity = 1
}
}
// 关键:如果图片地址是动态变化的,需要监听更新
// updated(el, binding) {
// if (binding.value !== binding.oldValue) {
// // 重复上面的加载逻辑...
// }
// }
}
onMounted(() => { onMounted(() => {
MyEvent.add('loading-sketch', handleLoadingSketch) MyEvent.add('loading-sketch', handleLoadingSketch)
}) })
@@ -284,6 +313,19 @@
height: 100%; height: 100%;
border-radius: 1.6rem; border-radius: 1.6rem;
} }
.loading-wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 1.6rem;
img {
width: 100%;
height: 100%;
border-radius: 1.6rem;
}
}
:deep(.menu-btn) { :deep(.menu-btn) {
position: absolute; position: absolute;
top: 2.1rem; top: 2.1rem;

View File

@@ -1,15 +1,15 @@
<template> <template>
<div class="report-card" :class="{ 'is-url': isUrl }"> <div class="report-card" :class="{ 'is-url': isUrl, 'is-sketch': isSketch }">
<div class="report-card-header"> <div class="report-card-header">
<span v-if="!isUrl">{{ title }}</span> <span v-if="!isUrl && !isSketch">{{ report.title }}</span>
<div v-else class="web-sources flex align-center"> <div v-else class="web-sources flex align-center">
<span>Web Sources</span> <span>{{ report.title }}</span>
<img src="@/assets/images/link.png" class="link-icon" /> <img src="@/assets/images/link.png" class="link-icon" />
</div> </div>
</div> </div>
<div class="report-card-content"> <div class="report-card-content">
<span v-if="!isUrl">markdown.md</span> <span v-if="!isUrl && !isSketch">{{ report.content || 'markdown.md' }}</span>
<span v-else>Destination URL</span> <span v-else>{{ report.content }}</span>
</div> </div>
</div> </div>
</template> </template>
@@ -25,11 +25,17 @@
title?: string title?: string
content?: string content?: string
isUrl?: boolean isUrl?: boolean
isSketch?: boolean
report: {
title: ''
content: ''
}
}>(), }>(),
{ {
isUrl: false, isUrl: false,
title: '', title: '',
content: '' content: '',
isSketch: false
} }
) )
</script> </script>
@@ -48,6 +54,10 @@
background: url('@/assets/images/link-card.png') no-repeat; background: url('@/assets/images/link-card.png') no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
} }
&.is-sketch {
background: url('@/assets/images/sketch-card.png') no-repeat;
background-size: 100% 100%;
}
// &:first-of-type{ // &:first-of-type{
// margin-top: 0; // margin-top: 0;
// } // }

View File

@@ -0,0 +1,10 @@
<template>
<ReportCard is-sketch :report="{title: 'Sketches Results', content: 'JPG file'}"/>
</template>
<script setup lang="ts">
import ReportCard from './ReportCard.vue'
</script>
<style lang="less" scoped>
</style>

View File

@@ -58,6 +58,9 @@ const setVersionsList = (res)=>{
} }
traverseArray(res,'',(item,i,father)=>{ traverseArray(res,'',(item,i,father)=>{
item.versionId = father?`${father.versionId}-${i+1}`:'1' item.versionId = father?`${father.versionId}-${i+1}`:'1'
if(item.id == projectStore.state.nodeId){
selectItem.value = {...item}
}
}) })
versionsList.value = res versionsList.value = res
} }
@@ -110,10 +113,6 @@ const versionDelete = (versionDetail)=>{
treeKey.value++ treeKey.value++
} }
watch(()=>projectStore.state.nodeId,(newVal,oldVal)=>{
if(!newVal || newVal === selectItem?.value?.id)return
selectItem.value = {id:newVal}
})
let data = reactive({}) let data = reactive({})
// onMounted(() => {setVersionsList('')}) // onMounted(() => {setVersionsList('')})

View File

@@ -465,7 +465,7 @@
// 打字机效果显示placeholder文本 // 打字机效果显示placeholder文本
const placeholderText = const placeholderText =
'Generate a furniture trending report for 2025, including popular styles and design directions.' 'Generate a furniture trending report for 2026, including popular styles and design directions.'
typeWriterEffect(placeholderSpan, placeholderText) typeWriterEffect(placeholderSpan, placeholderText)
const removePlaceholderOnInput = () => { const removePlaceholderOnInput = () => {
@@ -1378,6 +1378,7 @@
.agent-modal { .agent-modal {
// width: 14.6rem; // width: 14.6rem;
// height: 8.5rem; // height: 8.5rem;
row-gap: 1.2rem; row-gap: 1.2rem;
font-family: 'Medium'; font-family: 'Medium';
font-weight: 500; font-weight: 500;
@@ -1388,6 +1389,7 @@
box-shadow: 0px 6.53px 32.63px 0px #0000000d; box-shadow: 0px 6.53px 32.63px 0px #0000000d;
border-radius: 1rem; border-radius: 1rem;
padding: 1.2rem 1.4rem; padding: 1.2rem 1.4rem;
transform: translateX(calc(50% - 1.6rem));
.c-svg { .c-svg {
width: initial; width: initial;
width: 1rem; width: 1rem;