From 5a5cdbdcde2d04f4a4596e4fc60a7478c8e8cb26 Mon Sep 17 00:00:00 2001 From: Zyy Date: Wed, 16 Sep 2026 02:52:55 +0800 Subject: [PATCH] fix(ui): refine account settings and key displays Show all batch account settings by default while updating only edited fields. Add ellipsis and full-text titles to API key names and labels, and adjust the token usage summary icon size and alignment. Co-authored-by: Codex --- .../components/AccountBatchEditModal.vue | 7 +- .../components/AccountSettingsFields.vue | 81 +++++++++---------- .../composables/useAccountBatchEditor.ts | 40 +++++---- frontend/src/views/accounts/index.vue | 4 +- .../key-usage/components/KeyUsageSummary.vue | 4 +- .../keys/components/ApiKeyIdentityCell.vue | 6 +- 6 files changed, 72 insertions(+), 70 deletions(-) diff --git a/frontend/src/views/accounts/components/AccountBatchEditModal.vue b/frontend/src/views/accounts/components/AccountBatchEditModal.vue index ca0bc8aae..e923550d7 100644 --- a/frontend/src/views/accounts/components/AccountBatchEditModal.vue +++ b/frontend/src/views/accounts/components/AccountBatchEditModal.vue @@ -2,7 +2,6 @@ import type { AccountGroup, AccountModelAccess } from '@/api' import BaseButton from '@/components/base/BaseButton.vue' -import BaseCheckbox from '@/components/base/BaseCheckbox.vue' import BaseModal from '@/components/base/BaseModal/index.vue' import AccountSettingsFields from './AccountSettingsFields.vue' @@ -12,6 +11,7 @@ defineProps<{ groups: AccountGroup[] groupsLoading: boolean saving: boolean + hasChanges: boolean }>() const emit = defineEmits<{ @@ -22,7 +22,6 @@ const open = defineModel({ required: true }) const enabled = defineModel('enabled', { required: true }) const concurrencyLimit = defineModel('concurrencyLimit', { required: true }) const modelAccess = defineModel('modelAccess', { required: true }) -const updateScheduling = defineModel('updateScheduling', { required: true }) const weight = defineModel('weight', { required: true }) const proxyMode = defineModel('proxyMode', { required: true }) const proxyId = defineModel('proxyId', { required: true }) @@ -38,7 +37,6 @@ const selectedGroupIds = defineModel('selectedGroupIds', { required: t :dismissible="!saving" >
- ('selectedGroupIds', { required: t v-model:proxy-mode="proxyMode" v-model:proxy-id="proxyId" preserve-model-access - :model-only="!updateScheduling" :account-id="catalogAccountId" :groups="groups" :groups-loading="groupsLoading" @@ -63,7 +60,7 @@ const selectedGroupIds = defineModel('selectedGroupIds', { required: t 保存更改 diff --git a/frontend/src/views/accounts/components/AccountSettingsFields.vue b/frontend/src/views/accounts/components/AccountSettingsFields.vue index fa3eb300f..326697342 100644 --- a/frontend/src/views/accounts/components/AccountSettingsFields.vue +++ b/frontend/src/views/accounts/components/AccountSettingsFields.vue @@ -15,7 +15,6 @@ withDefaults(defineProps<{ accountId?: string preserveProxy?: boolean preserveModelAccess?: boolean - modelOnly?: boolean proxyError?: string }>(), { preserveProxy: true }) @@ -31,50 +30,48 @@ const selectedGroupIds = defineModel('selectedGroupIds', { required: t diff --git a/frontend/src/views/accounts/composables/useAccountBatchEditor.ts b/frontend/src/views/accounts/composables/useAccountBatchEditor.ts index 1f906422e..65680c814 100644 --- a/frontend/src/views/accounts/composables/useAccountBatchEditor.ts +++ b/frontend/src/views/accounts/composables/useAccountBatchEditor.ts @@ -1,7 +1,7 @@ import type { Ref } from 'vue' import type { AccountModelAccess, getAccounts } from '@/api' -import { ref, shallowRef, watch } from 'vue' +import { computed, ref, shallowRef, watch } from 'vue' import { batchUpdateAccounts } from '@/api' import { toast } from '@/components/base/BaseToast' import { useAsyncAction } from '@/composables/useAsyncAction' @@ -22,13 +22,25 @@ export function useAccountBatchEditor(options: { const concurrencyLimit = shallowRef('') const weight = shallowRef('1') const modelAccess = ref() - const updateScheduling = shallowRef(false) + const editedFields = ref(new Set<'enabled' | 'concurrencyLimit' | 'weight' | 'groupIds'>()) const catalogAccountId = shallowRef() const proxyMode = shallowRef('preserve') const proxyId = shallowRef('') const selectedGroupIds = ref([]) const saveAction = useAsyncAction() const saving = saveAction.loading + const hasChanges = computed(() => Boolean(modelAccess.value) || editedFields.value.size > 0 || proxyMode.value !== 'preserve') + + // 未操作的字段保持每个账号原值,避免展开表单就覆盖混合设置。 + watch([schedulingEnabled, concurrencyLimit, weight, selectedGroupIds], (values, previous) => { + if (!showBatchEditModal.value || saving.value) + return + const fields = ['enabled', 'concurrencyLimit', 'weight', 'groupIds'] as const + fields.forEach((field, index) => { + if (values[index] !== previous[index]) + editedFields.value.add(field) + }) + }, { flush: 'sync' }) function open() { const accounts = selectedAccounts() @@ -36,7 +48,7 @@ export function useAccountBatchEditor(options: { return modelAccess.value = undefined - updateScheduling.value = false + editedFields.value.clear() catalogAccountId.value = accounts[0]?.id schedulingEnabled.value = accounts.every(account => account.enabled) proxyMode.value = 'preserve' @@ -55,12 +67,12 @@ export function useAccountBatchEditor(options: { toast.warning(modelError) return } - if (!updateScheduling.value && !modelAccess.value) { + if (!hasChanges.value) { toast.warning('请选择需要更新的设置') return } - const scheduling = parseAccountSchedulingForm(updateScheduling.value ? concurrencyLimit.value : '', updateScheduling.value ? weight.value : '1') - if (updateScheduling.value && proxyMode.value === 'proxy' && !proxyId.value.trim()) { + const scheduling = parseAccountSchedulingForm(editedFields.value.has('concurrencyLimit') ? concurrencyLimit.value : '', editedFields.value.has('weight') ? weight.value : '1') + if (proxyMode.value === 'proxy' && !proxyId.value.trim()) { toast.warning('请选择已通过测试的代理') return } @@ -74,15 +86,11 @@ export function useAccountBatchEditor(options: { await batchUpdateAccounts({ accountIds, modelAccess: modelAccess.value, - ...(updateScheduling.value - ? { - outboundProxyId: proxyMode.value === 'preserve' ? undefined : proxyMode.value === 'direct' ? '' : proxyId.value.trim(), - enabled: schedulingEnabled.value, - concurrencyLimit: scheduling.values.concurrencyLimit, - weight: scheduling.values.weight, - groupIds: [...new Set(selectedGroupIds.value)], - } - : {}), + outboundProxyId: proxyMode.value === 'preserve' ? undefined : proxyMode.value === 'direct' ? '' : proxyId.value.trim(), + enabled: editedFields.value.has('enabled') ? schedulingEnabled.value : undefined, + concurrencyLimit: editedFields.value.has('concurrencyLimit') ? scheduling.values.concurrencyLimit : undefined, + weight: editedFields.value.has('weight') ? scheduling.values.weight : undefined, + groupIds: editedFields.value.has('groupIds') ? [...new Set(selectedGroupIds.value)] : undefined, }) showBatchEditModal.value = false options.selectedIds.value = new Set() @@ -132,7 +140,7 @@ export function useAccountBatchEditor(options: { concurrencyLimit, weight, modelAccess, - updateScheduling, + hasChanges, catalogAccountId, proxyMode, proxyId, diff --git a/frontend/src/views/accounts/index.vue b/frontend/src/views/accounts/index.vue index 33b4bd9c5..edab3d7bb 100644 --- a/frontend/src/views/accounts/index.vue +++ b/frontend/src/views/accounts/index.vue @@ -129,7 +129,7 @@ const { concurrencyLimit: batchConcurrencyLimit, weight: batchWeight, modelAccess: batchModelAccess, - updateScheduling: batchUpdateScheduling, + hasChanges: batchHasChanges, catalogAccountId: batchCatalogAccountId, proxyMode: batchProxyMode, proxyId: batchProxyId, @@ -375,7 +375,6 @@ const { v-model:concurrency-limit="batchConcurrencyLimit" v-model:weight="batchWeight" v-model:model-access="batchModelAccess" - v-model:update-scheduling="batchUpdateScheduling" v-model:proxy-mode="batchProxyMode" v-model:proxy-id="batchProxyId" v-model:selected-group-ids="batchGroupIds" @@ -384,6 +383,7 @@ const { :groups="groups" :groups-loading="groupsLoading" :saving="savingBatchEdit" + :has-changes="batchHasChanges" @save="saveBatchEdit" /> diff --git a/frontend/src/views/key-usage/components/KeyUsageSummary.vue b/frontend/src/views/key-usage/components/KeyUsageSummary.vue index f19b93623..818d41050 100644 --- a/frontend/src/views/key-usage/components/KeyUsageSummary.vue +++ b/frontend/src/views/key-usage/components/KeyUsageSummary.vue @@ -25,8 +25,8 @@ const metrics = computed(() => [
-