diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue
index 24ba7aed1c..8478f2056c 100644
--- a/frontend/src/components/account/CreateAccountModal.vue
+++ b/frontend/src/components/account/CreateAccountModal.vue
@@ -581,6 +581,40 @@
+
+
@@ -4164,6 +4198,7 @@ import {
isValidWildcardPattern
} from '@/composables/useModelWhitelist'
import { adminAPI } from '@/api/admin'
+import { SCHEDULING_THRESHOLD_PLATFORMS } from '@/api/admin/settings'
import { useQuotaNotifyState } from '@/composables/useQuotaNotifyState'
import {
useAccountOAuth,
@@ -4479,6 +4514,14 @@ const isGenericMultiProtocolPlatform = computed(
const extraMultiProtocolPlatforms = computed(() =>
listPlatforms().filter(spec => !!spec.multi_protocol && !isCNProviderPlatform(spec.id) && spec.id !== 'opencode_go')
)
+// 账号级自动停调阈值覆盖(创建时可选):写入 credentials.account_scheduling_threshold。
+// 仅对后端白名单平台显示;关闭/留空 = 跟随系统平台阈值。
+const ACCOUNT_SCHEDULING_THRESHOLD_CREDENTIAL_KEY = 'account_scheduling_threshold'
+const createSchedulingThresholdOverrideEnabled = ref(false)
+const createSchedulingThresholdOverrideValue = ref(100)
+const supportsCreateSchedulingThresholdOverride = computed(() =>
+ (SCHEDULING_THRESHOLD_PLATFORMS as readonly string[]).includes(form.platform)
+)
const genericAccountModes = computed(() => providerAccountModes(form.platform))
// 按模型分流的供应商(OpenCode 等):adaptive 账号携带 protocol_rules。
const routesByModel = computed(() => providerRoutesByModel(form.platform))
@@ -6241,6 +6284,17 @@ const handleSubmit = async () => {
}
}
+ // 账号级自动停调阈值覆盖:仅白名单平台、勾选且值在 1..99 时写入
+ // (100 = 禁用当前账号自动停调,不写则跟随系统平台阈值)。
+ if (
+ supportsCreateSchedulingThresholdOverride.value &&
+ createSchedulingThresholdOverrideEnabled.value
+ ) {
+ const numeric = Math.trunc(Number(createSchedulingThresholdOverrideValue.value) || 100)
+ const clamped = Math.min(100, Math.max(1, numeric))
+ credentials[ACCOUNT_SCHEDULING_THRESHOLD_CREDENTIAL_KEY] = clamped
+ }
+
// Add model mapping if configured(OpenAI 开启自动透传时不应用)
if (!isOpenAIModelRestrictionDisabled.value) {
const modelMapping = buildModelMappingObject(modelRestrictionMode.value, allowedModels.value, modelMappings.value)
diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue
index e1e50ec52a..15a1836ef0 100644
--- a/frontend/src/components/account/EditAccountModal.vue
+++ b/frontend/src/components/account/EditAccountModal.vue
@@ -3422,6 +3422,7 @@ import { useI18n } from 'vue-i18n'
import { useAppStore } from '@/stores/app'
import { adminAPI } from '@/api/admin'
+import { SCHEDULING_THRESHOLD_PLATFORMS } from '@/api/admin/settings'
import { useQuotaNotifyState } from '@/composables/useQuotaNotifyState'
import type {
Account,
@@ -5353,7 +5354,10 @@ const applyTempUnschedConfig = (credentials: Record
) => {
function supportsAccountSchedulingThresholdOverridePlatform(platform: Account['platform'] | undefined) {
- return platform === 'openai' || platform === 'anthropic' || platform === 'grok'
+ // 与后端 AllowedSchedulingThresholdPlatforms 共用同一清单(系统设置页也用这份),
+ // 避免前端入口与后端白名单再次漂移。
+ if (!platform) return false
+ return (SCHEDULING_THRESHOLD_PLATFORMS as readonly string[]).includes(platform)
}
function normalizeAccountSchedulingThresholdOverride(value: unknown): number | null {
diff --git a/frontend/src/components/account/__tests__/EditAccountModal.schedulingThreshold.spec.ts b/frontend/src/components/account/__tests__/EditAccountModal.schedulingThreshold.spec.ts
new file mode 100644
index 0000000000..db6052eaa5
--- /dev/null
+++ b/frontend/src/components/account/__tests__/EditAccountModal.schedulingThreshold.spec.ts
@@ -0,0 +1,189 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { defineComponent } from 'vue'
+import { flushPromises, mount } from '@vue/test-utils'
+
+// 账号级自动停调阈值覆盖:GLM / MiniMax / OpenCode / Command Code 等
+// 套餐平台现在都能在账号编辑页设置该覆盖(此前仅 openai/anthropic/grok)。
+
+const { updateAccountMock, checkMixedChannelRiskMock, authIsSimpleMode } = vi.hoisted(() => ({
+ updateAccountMock: vi.fn(),
+ checkMixedChannelRiskMock: vi.fn(),
+ authIsSimpleMode: { value: true }
+}))
+
+vi.mock('@/stores/app', () => ({
+ useAppStore: () => ({
+ showError: vi.fn(),
+ showSuccess: vi.fn(),
+ showInfo: vi.fn()
+ })
+}))
+
+vi.mock('@/stores/auth', () => ({
+ useAuthStore: () => ({
+ get isSimpleMode() {
+ return authIsSimpleMode.value
+ }
+ })
+}))
+
+vi.mock('@/api/admin', () => ({
+ adminAPI: {
+ accounts: {
+ update: updateAccountMock,
+ checkMixedChannelRisk: checkMixedChannelRiskMock,
+ previewUpstreamGroup: vi.fn()
+ },
+ settings: {
+ getWebSearchEmulationConfig: vi.fn().mockResolvedValue({ enabled: false, providers: [] }),
+ getSettings: vi.fn().mockResolvedValue({})
+ },
+ tlsFingerprintProfiles: {
+ list: vi.fn().mockResolvedValue([])
+ }
+ }
+}))
+
+vi.mock('@/api/admin/accounts', () => ({
+ getAntigravityDefaultModelMapping: vi.fn()
+}))
+
+vi.mock('vue-i18n', async () => {
+ const actual = await vi.importActual('vue-i18n')
+ return {
+ ...actual,
+ useI18n: () => ({ t: (key: string) => key })
+ }
+})
+
+import EditAccountModal from '../EditAccountModal.vue'
+
+const BaseDialogStub = defineComponent({
+ name: 'BaseDialog',
+ props: { show: { type: Boolean, default: false } },
+ template: '
'
+})
+
+const GroupSelectorStub = defineComponent({
+ name: 'GroupSelector',
+ props: { modelValue: { type: Array, default: () => [] } },
+ emits: ['update:modelValue'],
+ template: ''
+})
+
+const ModelWhitelistSelectorStub = defineComponent({
+ name: 'ModelWhitelistSelector',
+ props: { modelMappings: { type: Array, default: () => [] }, modelValue: { type: Array, default: () => [] } },
+ emits: ['update:modelValue'],
+ template: ''
+})
+
+const SelectStub = defineComponent({
+ name: 'SelectStub',
+ props: {
+ modelValue: { type: [String, Number, Boolean, null], default: '' },
+ options: { type: Array, default: () => [] }
+ },
+ emits: ['update:modelValue'],
+ template: `
+
+ `
+})
+
+function buildAccount(platform: string, credentials: Record = {}) {
+ return {
+ id: 1,
+ name: `account-${platform}`,
+ notes: '',
+ platform,
+ type: 'apikey',
+ credentials: { api_key: 'key-test', base_url: '', ...credentials },
+ extra: {},
+ proxy_id: null,
+ concurrency: 1,
+ priority: 1,
+ rate_multiplier: 1,
+ status: 'active',
+ group_ids: [],
+ expires_at: null,
+ auto_pause_on_expired: false
+ } as any
+}
+
+function mountModal(account: any) {
+ return mount(EditAccountModal, {
+ props: { show: true, account, proxies: [], groups: [] },
+ global: {
+ stubs: {
+ BaseDialog: BaseDialogStub,
+ Select: SelectStub,
+ Icon: true,
+ ProxySelector: true,
+ GroupSelector: GroupSelectorStub,
+ ModelWhitelistSelector: ModelWhitelistSelectorStub
+ }
+ }
+ })
+}
+
+describe('EditAccountModal 账号自动停调阈值覆盖(套餐平台)', () => {
+ beforeEach(() => {
+ authIsSimpleMode.value = true
+ updateAccountMock.mockReset()
+ checkMixedChannelRiskMock.mockReset().mockResolvedValue({ has_risk: false })
+ })
+
+ it.each(['zhipu', 'minimax', 'opencode_go', 'command_code'])(
+ '%s 账号显示阈值覆盖区块并能提交 account_scheduling_threshold',
+ async (platform) => {
+ const account = buildAccount(platform, {
+ account_mode: platform === 'zhipu' ? 'coding' : 'payg'
+ })
+ updateAccountMock.mockResolvedValue(account)
+ const wrapper = mountModal(account)
+
+ expect(wrapper.find('[data-testid="account-scheduling-threshold-section"]').exists()).toBe(true)
+
+ await wrapper.get('[data-testid="account-scheduling-threshold-override-enabled"]').setValue(true)
+ await wrapper.get('[data-testid="account-scheduling-threshold-override-value"]').setValue('50')
+ await wrapper.get('form#edit-account-form').trigger('submit.prevent')
+ await flushPromises()
+
+ expect(updateAccountMock).toHaveBeenCalledTimes(1)
+ expect(updateAccountMock.mock.calls[0]?.[1]?.credentials?.account_scheduling_threshold).toBe(50)
+ wrapper.unmount()
+ }
+ )
+
+ it('deepseek(余额型)不显示阈值覆盖区块', async () => {
+ const account = buildAccount('deepseek', { account_mode: 'payg' })
+ updateAccountMock.mockResolvedValue(account)
+ const wrapper = mountModal(account)
+ expect(wrapper.find('[data-testid="account-scheduling-threshold-section"]').exists()).toBe(false)
+ wrapper.unmount()
+ })
+
+ it('关闭覆盖后把 account_scheduling_threshold 置空(回退系统阈值)', async () => {
+ const account = buildAccount('zhipu', {
+ account_mode: 'coding',
+ account_scheduling_threshold: 50
+ })
+ updateAccountMock.mockResolvedValue(account)
+ const wrapper = mountModal(account)
+
+ const enabled = wrapper.get('[data-testid="account-scheduling-threshold-override-enabled"]')
+ expect(enabled.element.checked).toBe(true)
+ const value = wrapper.get('[data-testid="account-scheduling-threshold-override-value"]')
+ expect(value.element.value).toBe('50')
+
+ await enabled.setValue(false)
+ await wrapper.get('form#edit-account-form').trigger('submit.prevent')
+ await flushPromises()
+
+ expect(updateAccountMock).toHaveBeenCalledTimes(1)
+ expect(updateAccountMock.mock.calls[0]?.[1]?.credentials?.account_scheduling_threshold).toBeNull()
+ wrapper.unmount()
+ })
+})
diff --git a/frontend/src/i18n/locales/en/admin/accounts.ts b/frontend/src/i18n/locales/en/admin/accounts.ts
index bfdfec7f55..6da92454f7 100644
--- a/frontend/src/i18n/locales/en/admin/accounts.ts
+++ b/frontend/src/i18n/locales/en/admin/accounts.ts
@@ -154,6 +154,7 @@ export default {
example: 'Example: …/organization/org-0610bE2D…/projects/proj_0798F20…/api_keys → org-0610bE2D… goes into "Organization ID", proj_0798F20… into "Project ID"',
},
},
+ schedulingThresholdCreateHint: 'Optional: override the platform auto-pause threshold for this account (upstream usage-window percent). Leave unchecked to follow the system setting.',
balance: 'Balance --',
window5h: '5h',
windowWeekly: '7d',
diff --git a/frontend/src/i18n/locales/zh/admin/accounts.ts b/frontend/src/i18n/locales/zh/admin/accounts.ts
index 0d35c23776..4cb68a4bb7 100644
--- a/frontend/src/i18n/locales/zh/admin/accounts.ts
+++ b/frontend/src/i18n/locales/zh/admin/accounts.ts
@@ -367,6 +367,7 @@ export default {
example: '示例:…/organization/org-0610bE2D…/projects/proj_0798F20…/api_keys → org-0610bE2D… 填「组织 ID」,proj_0798F20… 填「项目 ID」',
},
},
+ schedulingThresholdCreateHint: '可选:为该账号覆盖平台级自动停调阈值(按上游原生窗口百分比)。不勾选则跟随系统设置。',
balance: '余额 --',
window5h: '5h',
windowWeekly: '7d',