feat: 参数标签逻辑修改&对话列表显示标签
This commit is contained in:
@@ -71,11 +71,12 @@
|
||||
import {
|
||||
createSettingOptions,
|
||||
createStyleOptions,
|
||||
createTypeOptions
|
||||
createTypeOptions,
|
||||
optionTagOrder
|
||||
} from './input/options'
|
||||
import { useInputEditor } from './input/useInputEditor'
|
||||
import { useInputImages } from './input/useInputImages'
|
||||
import type { OptionItem, SettingOption } from './input/types'
|
||||
import type { OptionItem, OptionTagKind, ParameterTag, SettingOption } from './input/types'
|
||||
|
||||
const router = useRouter()
|
||||
const agentStore = useAgentStore()
|
||||
@@ -113,6 +114,7 @@
|
||||
const {
|
||||
inputValue,
|
||||
reportTags,
|
||||
optionTagKinds,
|
||||
showPlaceholder,
|
||||
setEditorElement,
|
||||
focusEditor,
|
||||
@@ -175,6 +177,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
const getTranslatedOptionLabel = (options: OptionItem[], value: string) => {
|
||||
const option = options.find((item) => item.value === value)
|
||||
return option ? translate(option.label) : value
|
||||
}
|
||||
|
||||
const getParameterTagLabel = (kind: OptionTagKind) => {
|
||||
if (kind === 'type') {
|
||||
return getTranslatedOptionLabel(typeOptions.value, typeValue.value)
|
||||
}
|
||||
if (kind === 'area') {
|
||||
return getTranslatedOptionLabel(areaOptions.value, areaValue.value)
|
||||
}
|
||||
|
||||
const option = styleOptions.value.find((item) => item.value === styleValue.value)
|
||||
return option?.label || styleValue.value
|
||||
}
|
||||
|
||||
const hasParameterValue = (kind: OptionTagKind) => {
|
||||
if (kind === 'type') return Boolean(typeValue.value)
|
||||
if (kind === 'area') return Boolean(areaValue.value)
|
||||
return Boolean(styleValue.value)
|
||||
}
|
||||
|
||||
const selectedParameterTags = computed<ParameterTag[]>(() => {
|
||||
const currentKinds = optionTagKinds.value.filter(hasParameterValue)
|
||||
const missingKinds = optionTagOrder.filter((kind) => {
|
||||
return hasParameterValue(kind) && !currentKinds.includes(kind)
|
||||
})
|
||||
|
||||
return [...currentKinds, ...missingKinds].map((kind) => ({
|
||||
kind,
|
||||
label: getParameterTagLabel(kind)
|
||||
}))
|
||||
})
|
||||
|
||||
watch(inputValue, () => {
|
||||
nextTick(() => {
|
||||
autoResizeEditor()
|
||||
@@ -218,12 +255,14 @@
|
||||
images: any[]
|
||||
tempImages: typeof uploadedImages.value
|
||||
quoteList: string[]
|
||||
parameterTags: ParameterTag[]
|
||||
useReport?: boolean
|
||||
} = {
|
||||
text: inputValue.value.trim(),
|
||||
images: imageUrlList,
|
||||
tempImages: uploadedImages.value,
|
||||
quoteList: quoteList.value
|
||||
quoteList: quoteList.value,
|
||||
parameterTags: selectedParameterTags.value
|
||||
}
|
||||
if (reportTags.value.length > 0) {
|
||||
payload.useReport = true
|
||||
@@ -257,6 +296,7 @@
|
||||
tempImages: uploadedImages.value,
|
||||
needSuggestion: false,
|
||||
quoteList: quoteList.value,
|
||||
parameterTags: selectedParameterTags.value,
|
||||
...params
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user