fix: 修复批量编辑账号时模型白名单显示与实际不一致的问题 #982

修复批量编辑账号时,UI 显示的是 plain 模型名(如 GPT-5),但实际落库的是 dated 模型名的问题。

核心改动:
1. 批量编辑白名单不再使用 BulkEditAccountModal.vue 中手写的过期模型列表
   - 移除了 allModels 和 presetMappings 的硬编码列表(共 200+ 行)
   - 直接复用 ModelWhitelistSelector.vue 组件

2. ModelWhitelistSelector 组件支持多平台联合过滤
   - 新增 platforms 属性支持传入多个平台
   - 添加 normalizedPlatforms 计算属性统一处理单平台和多平台场景
   - availableOptions 根据选中的多个平台动态联合过滤模型列表
   - fillRelated 功能支持一次性填充多个平台的相关模型

3. 模型映射预设改为动态生成
   - filteredPresets 改用 getPresetMappingsByPlatform 从统一模型源按平台动态生成
   - 不再依赖弹窗中的手写预设列表

现在的行为:
- UI 显示什么模型,勾选什么模型,传给后端的就是什么模型
- 彻底解决了批量编辑链路上"显示与实际不一致"的问题
- 模型列表和映射预设始终与系统定义保持同步
This commit is contained in:
IanShaw027
2026-03-15 16:57:29 +08:00
parent 6fba4ebb13
commit 19d3ecc76f
2 changed files with 58 additions and 246 deletions

View File

@@ -131,7 +131,8 @@ const { t } = useI18n()
const props = defineProps<{
modelValue: string[]
platform: string
platform?: string
platforms?: string[]
}>()
const emit = defineEmits<{
@@ -144,11 +145,36 @@ const showDropdown = ref(false)
const searchQuery = ref('')
const customModel = ref('')
const isComposing = ref(false)
const normalizedPlatforms = computed(() => {
const rawPlatforms =
props.platforms && props.platforms.length > 0
? props.platforms
: props.platform
? [props.platform]
: []
return Array.from(
new Set(
rawPlatforms
.map(platform => platform?.trim())
.filter((platform): platform is string => Boolean(platform))
)
)
})
const availableOptions = computed(() => {
if (props.platform === 'sora') {
return getModelsByPlatform('sora').map(m => ({ value: m, label: m }))
if (normalizedPlatforms.value.length === 0) {
return allModels
}
return allModels
const allowedModels = new Set<string>()
for (const platform of normalizedPlatforms.value) {
for (const model of getModelsByPlatform(platform)) {
allowedModels.add(model)
}
}
return allModels.filter(model => allowedModels.has(model.value))
})
const filteredModels = computed(() => {
@@ -192,10 +218,13 @@ const handleEnter = () => {
}
const fillRelated = () => {
const models = getModelsByPlatform(props.platform)
const newModels = [...props.modelValue]
for (const model of models) {
if (!newModels.includes(model)) newModels.push(model)
for (const platform of normalizedPlatforms.value) {
for (const model of getModelsByPlatform(platform)) {
if (!newModels.includes(model)) {
newModels.push(model)
}
}
}
emit('update:modelValue', newModels)
}