feat: 完善 Prompt 管理与生成流程配置
This commit is contained in:
32
RuoYi-Vue/tmp-logs/qing-ui-preview/src/utils/dict.js
Normal file
32
RuoYi-Vue/tmp-logs/qing-ui-preview/src/utils/dict.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const dictData = {}
|
||||
|
||||
const emptyDict = []
|
||||
|
||||
function normalizeOptions(options) {
|
||||
if (!Array.isArray(options)) {
|
||||
return emptyDict
|
||||
}
|
||||
return options.map((option) => {
|
||||
const label = option.label || option.name || option.value
|
||||
const value = option.value || label
|
||||
return {
|
||||
...option,
|
||||
label,
|
||||
name: option.name || label,
|
||||
value
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
getDictDataByType(type) {
|
||||
return normalizeOptions(dictData[type])
|
||||
},
|
||||
getDictLabel(type, value) {
|
||||
if (value === undefined || value === null || value === "") {
|
||||
return "-"
|
||||
}
|
||||
const matched = normalizeOptions(dictData[type]).find((option) => String(option.value) === String(value))
|
||||
return matched ? matched.label : value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user