feat: 参数标签逻辑修改&对话列表显示标签

This commit is contained in:
2026-05-04 13:47:51 +08:00
parent 89aab7e960
commit 620962b9ee
7 changed files with 239 additions and 24 deletions

View File

@@ -37,8 +37,12 @@
import type { AgentParamsType } from '@/api/agent'
import { useUserInfoStore, useProjectStore, useAgentStore } from '@/stores'
import MyEvent from '@/utils/myEvent'
import { areaList } from '@/utils/area'
import { useI18n } from 'vue-i18n'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import { createStyleOptions, createTypeOptions } from '../../components/input/options'
import type { OptionItem, ParameterTag } from '../../components/input/types'
const { t } = useI18n()
const route = useRoute()
@@ -83,6 +87,59 @@
})
const sketchList = ref([])
const typeOptions = createTypeOptions()
const areaOptions = areaList
const styleOptions = createStyleOptions()
const getTranslatedOptionLabel = (options: OptionItem[], value?: string) => {
if (!value) return ''
const option = options.find((item) => item.value === value)
return option ? t(option.label) : value
}
const getOptionLabel = (options: OptionItem[], value?: string) => {
if (!value) return ''
return options.find((item) => item.value === value)?.label || value
}
const getProjectParameterTags = (project: any): ParameterTag[] => {
const type = project?.type || ''
const region = project?.region || project?.area || ''
const style = project?.style || ''
const tags: ParameterTag[] = []
if (type) {
tags.push({
kind: 'type',
label: getTranslatedOptionLabel(typeOptions, type)
})
}
if (region) {
tags.push({
kind: 'area',
label: getTranslatedOptionLabel(areaOptions, region)
})
}
if (style) {
tags.push({
kind: 'style',
label: getOptionLabel(styleOptions, style)
})
}
return tags
}
const applyProjectParameterTags = (messages: any[], project: any) => {
const parameterTags = getProjectParameterTags(project)
if (parameterTags.length === 0) return
const firstUserMessage = messages.find((item) => item.isUser || item.role === 'user')
if (firstUserMessage) {
firstUserMessage.parameterTags = parameterTags
}
}
watch(
sketchList,
(newVal) => {
@@ -143,7 +200,8 @@
images: initialData.images,
useReport: initialData.useReport,
tempImages: initialData.tempImages,
quoteList: initialData.quoteList
quoteList: initialData.quoteList,
parameterTags: initialData.parameterTags || []
})
// 更新 configParams
@@ -181,6 +239,7 @@
tempImages: any[]
useReport: boolean
quoteList: Array<string>
parameterTags?: Array<{ kind: string; label: string }>
},
skipUserMessage = false
) => {
@@ -199,7 +258,8 @@
id: messageList.value.length + 1,
text: message.text,
isUser: true,
imageUrls: message.tempImages.concat(message.quoteList)
imageUrls: message.tempImages.concat(message.quoteList),
parameterTags: message.parameterTags || []
})
}
@@ -628,7 +688,7 @@
const setChatInfo = (info) => {
const initialData = agentStore.getInitialProjectData
if (isGenerating.value || initialData) return
console.log('---',info)
const data = info.conversation
let project = info.project
if (info.id) {
@@ -641,7 +701,7 @@
if (project) {
params.configParams.type = project.type || ''
params.configParams.region = project.area || ''
params.configParams.region = project.region || project.area || ''
params.configParams.style = project.style || ''
params.configParams.temperature = project.temperature
params.projectID = project.id
@@ -668,6 +728,7 @@
item.text += `<slot slot-name="sketch"></slot>`
}
})
applyProjectParameterTags(ancestorsList, project)
// console.log('ancestorslist', ancestorsList)
messageList.value = [...ancestorsList]
params.versionID = current?.id