diff --git a/frontend/src/components/account/BulkEditAccountModal.vue b/frontend/src/components/account/BulkEditAccountModal.vue
index 22f6f3e788..7acd3ac79b 100644
--- a/frontend/src/components/account/BulkEditAccountModal.vue
+++ b/frontend/src/components/account/BulkEditAccountModal.vue
@@ -343,6 +343,7 @@
{{ t('admin.accounts.selectedModels', { count: allowedModels.length }) }}
{{
@@ -779,7 +779,7 @@
{{ t('admin.accounts.selectedModels', { count: allowedModels.length }) }}
{{
@@ -991,7 +991,7 @@
{{ t('admin.accounts.selectedModels', { count: allowedModels.length }) }}
{{
@@ -1213,7 +1213,7 @@
{{ t('admin.accounts.selectedModels', { count: allowedModels.length }) }}
{{ t('admin.accounts.supportsAllModels') }}
diff --git a/frontend/src/components/account/ModelWhitelistSelector.vue b/frontend/src/components/account/ModelWhitelistSelector.vue
index 5f359ccca1..d1e7e557cb 100644
--- a/frontend/src/components/account/ModelWhitelistSelector.vue
+++ b/frontend/src/components/account/ModelWhitelistSelector.vue
@@ -159,6 +159,7 @@ const { t } = useI18n()
const props = defineProps<{
modelValue: string[]
+ modelMappings?: { from: string; to: string }[]
platform?: string
platforms?: string[]
accountId?: number
@@ -274,6 +275,11 @@ const addCustom = () => {
appStore.showInfo(t('admin.accounts.modelExists'))
return
}
+ const conflict = props.modelMappings?.find(mapping => mapping.from.trim() === model && mapping.to.trim() && mapping.to.trim() !== model)
+ if (conflict) {
+ appStore.showInfo(t('admin.accounts.modelMappingConflict', { from: model, to: conflict.to.trim() }))
+ return
+ }
emit('update:modelValue', [...props.modelValue, model])
customModel.value = ''
}
diff --git a/frontend/src/components/account/__tests__/EditAccountModal.spec.ts b/frontend/src/components/account/__tests__/EditAccountModal.spec.ts
index 7b104410c1..92274571a6 100644
--- a/frontend/src/components/account/__tests__/EditAccountModal.spec.ts
+++ b/frontend/src/components/account/__tests__/EditAccountModal.spec.ts
@@ -70,6 +70,7 @@ const BaseDialogStub = defineComponent({
const ModelWhitelistSelectorStub = defineComponent({
name: 'ModelWhitelistSelector',
props: {
+ modelMappings: { type: Array, default: () => [] },
modelValue: {
type: Array,
default: () => []
@@ -330,6 +331,24 @@ describe('EditAccountModal', () => {
afterEach(() => vi.useRealTimers())
+ it('passes existing non-identity mappings to the whitelist selector and preserves them on save', async () => {
+ const account = buildAccount()
+ account.credentials.model_mapping = { 'gpt-5.2': 'gpt-5.2', 'gpt-latest': 'deepseek-chat' }
+ updateAccountMock.mockReset().mockResolvedValue(account)
+ checkMixedChannelRiskMock.mockReset().mockResolvedValue({ has_risk: false })
+ const wrapper = mountModal(account)
+ expect(wrapper.getComponent(ModelWhitelistSelectorStub).props('modelMappings')).toEqual([
+ { from: 'gpt-latest', to: 'deepseek-chat' }
+ ])
+ await wrapper.get('form#edit-account-form').trigger('submit.prevent')
+ expect(updateAccountMock.mock.calls[0]?.[1]?.credentials?.model_mapping).toEqual(account.credentials.model_mapping)
+ await wrapper.setProps({ show: false })
+ await wrapper.setProps({ show: true, account: { ...account } })
+ expect(wrapper.getComponent(ModelWhitelistSelectorStub).props('modelMappings')).toEqual([
+ { from: 'gpt-latest', to: 'deepseek-chat' }
+ ])
+ })
+
it('sets expiry presets from now instead of extending the saved expiry', async () => {
vi.useFakeTimers({ toFake: ['Date'] })
vi.setSystemTime(new Date('2028-02-29T12:34:00'))
diff --git a/frontend/src/components/account/__tests__/ModelWhitelistSelector.spec.ts b/frontend/src/components/account/__tests__/ModelWhitelistSelector.spec.ts
index 97667e3ee4..576df0d0b9 100644
--- a/frontend/src/components/account/__tests__/ModelWhitelistSelector.spec.ts
+++ b/frontend/src/components/account/__tests__/ModelWhitelistSelector.spec.ts
@@ -24,7 +24,7 @@ vi.mock('vue-i18n', async () => {
return {
...actual,
useI18n: () => ({
- t: (key: string) => (key === 'common.copy' ? '复制' : key)
+ t: (key: string, params?: Record