feat: 图片引用

This commit is contained in:
2026-03-24 16:57:40 +08:00
parent b1bf290c06
commit 0428783f5c
9 changed files with 79 additions and 28 deletions

View File

@@ -64,7 +64,8 @@
region: '',
style: ''
},
imageUrlList: []
imageUrlList: [],
quotaUrl: []
})
const sketchList = ref([])
@@ -110,7 +111,8 @@
text: initialData.text,
images: initialData.images,
useReport: initialData.useReport,
tempImages: initialData.tempImages
tempImages: initialData.tempImages,
quoteList: initialData.quoteList
})
// 更新 configParams
@@ -125,6 +127,7 @@
images: Array<{ url: string; name: string }>
tempImages: any[]
useReport: boolean
quoteList: Array<string>
},
skipUserMessage = false
) => {
@@ -136,14 +139,14 @@
}
params.imageUrlList = message.images || []
params.quotaUrl = message.quoteList || []
// 如果不是重新生成模式,则添加用户消息到列表
if (!skipUserMessage) {
messageList.value.push({
id: messageList.value.length + 1,
text: message.text,
isUser: true,
imageUrls: message.tempImages
imageUrls: message.tempImages.concat(message.quoteList)
})
}
@@ -223,6 +226,8 @@
let hasReportStarted = false // 标记 report 是否已经开始
let hasSketchEvent = false
let hasReportEvent = false
try {
let flag = true
while (flag) {
@@ -231,6 +236,9 @@
if (hasSketchEvent) {
aiMessage.text += `<slot slot-name="sketch"></slot>`
}
if (hasReportEvent) {
aiMessage.text += `<slot slot-name="card" title="Report" content="Report"></slot>`
}
aiMessage.streaming = false
aiMessage.loading = false
@@ -256,7 +264,8 @@
if (!hasReportStarted && eventName === 'report') {
isGeneratingReport.value = true
contentBody += `<slot slot-name="card" title="Report" content="Report"></slot>`
hasReportEvent = true
// contentBody += `<slot slot-name="card" title="Report" content="Report"></slot>`
hasReportStarted = true
}
@@ -588,7 +597,7 @@
nextTick(() => {
ancestorsList.forEach((item) => {
if (item.image_url) {
if (item.image_url && item.role !== 'user') {
item.text += `<slot slot-name="sketch"></slot>`
}
})

View File

@@ -129,7 +129,7 @@
}>()
// watch(
// () => props.content,
// () => props,
// (newVal) => {
// console.log('newVal-----', newVal)
// },
@@ -139,8 +139,12 @@
const emit = defineEmits(['regenerate'])
const imageList = computed(() => {
const { imageUrls } = props.content
const { imageUrls, role } = props.content
const list = []
if (role === 'user') {
const quotaList = props.content.image_url ?? []
list.push(...quotaList)
}
if (!imageUrls || imageUrls.length === 0) return list
imageUrls.forEach((item) => {
if (typeof item === 'string') {

View File

@@ -13,12 +13,15 @@
<Menu />
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item class="sketch-item flex align-center">
<el-dropdown-item
class="sketch-item flex align-center"
@click="handleClickQuote(item)"
>
<img
src="@/assets/images/restore-sketch.png"
class="dropdown-icon restore"
/>
<span class="dropdown-txt">Quote</span>
<span class="dropdown-txt">{{ $t('agent.quote') }}</span>
</el-dropdown-item>
<el-dropdown-item
class="sketch-item flex align-center"
@@ -28,7 +31,7 @@
src="@/assets/images/delete.png"
class="dropdown-icon delete"
/>
<span class="dropdown-txt del">Delete</span>
<span class="dropdown-txt del">{{ $t('agent.delete') }}</span>
</el-dropdown-item>
</el-dropdown-menu>
</template>
@@ -37,7 +40,7 @@
class="edit-btn flex align-center space-between"
@click="handleClickEdit(item)"
>
<div>Edit</div>
<div>{{ $t('agent.edit') }}</div>
<img src="@/assets/images/arrow-top-right.png" />
</div>
<!-- 已加载完成的 sketch 显示实际图片 -->
@@ -218,6 +221,12 @@
myEvent.emit('openFlowCanvas', { url, imgId, nodeId })
}
const handleClickQuote = (item) => {
console.log(item)
const url = Object.values(item)[0]
MyEvent.emit('quote', url)
}
const handleClickDelete = (item: string | Object) => {
deleteSketchFlowCanvas({
id: Object.keys(item)[0],

View File

@@ -48,8 +48,12 @@
}
&.is-sketch {
background: url('@/assets/images/sketch-card.png') no-repeat;
background-size: contain;
padding: 2rem 3rem;
max-width: 52.5rem;
height: 8rem;
box-sizing: border-box;
background-size: 100% 100%;
min-height: initial;
.report-card-header {
margin-bottom: 0;
}

View File

@@ -7,9 +7,5 @@
</script>
<style lang="less" scoped>
:deep(.report-card) {
width: 52.5rem;
height: 8rem;
box-sizing: border-box;
}
</style>