diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index 6c6bd710f1..40997346fa 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -656,7 +656,7 @@ v-model="ollamaMonthlyCreditUsdInput" type="number" min="0" - step="1" + step="any" class="input" :placeholder="t('admin.accounts.ollamaCloud.accountMode.monthlyCreditUsdPlaceholder')" data-testid="ollama-monthly-credit-usd" @@ -4631,7 +4631,8 @@ const submitsViaGenericApiKeyPath = computed( const supportsCreateSchedulingThresholdOverride = computed( () => (SCHEDULING_THRESHOLD_PLATFORMS as readonly string[]).includes(form.platform) && - submitsViaGenericApiKeyPath.value + submitsViaGenericApiKeyPath.value && + !(form.platform === 'ollama_cloud' && ollamaAccountMode.value === 'ollama_credits') ) const genericAccountModes = computed(() => providerAccountModes(form.platform)) // 按模型分流的供应商(OpenCode 等):adaptive 账号携带 protocol_rules。 @@ -4751,6 +4752,8 @@ function selectOllamaCloudPlatform() { ollamaAccountMode.value = 'ollama_legacy' apiKeyBaseUrl.value = defaultCNBaseUrl('ollama_cloud', ollamaAccountMode.value, 'adaptive') resetAdaptiveBaseUrls('ollama_cloud', ollamaAccountMode.value) + modelRestrictionMode.value = 'whitelist' + allowedModels.value = [...getModelsByPlatform('ollama_cloud')] } function selectGenericMultiProtocolPlatform(platform: string) { form.platform = platform @@ -5399,6 +5402,12 @@ watch( modelRestrictionMode.value = 'whitelist' allowedModels.value = ['jev-latest'] } + if (newPlatform === 'ollama_cloud') { + // Ollama Cloud 后端保存期门禁拒绝空映射且无白名单的账号(防静默零计费), + // 默认预填平台已定价模型白名单,使默认建号路径直接满足保存期门禁。 + modelRestrictionMode.value = 'whitelist' + allowedModels.value = [...getModelsByPlatform('ollama_cloud')] + } // Antigravity: 默认使用映射模式并填充默认映射 if (newPlatform === 'antigravity') { antigravityModelRestrictionMode.value = 'mapping' diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue index 447dd8eda0..1eab54094d 100644 --- a/frontend/src/components/account/EditAccountModal.vue +++ b/frontend/src/components/account/EditAccountModal.vue @@ -169,7 +169,7 @@ v-model="editOllamaMonthlyCreditUsd" type="number" min="0" - step="1" + step="any" class="input" :placeholder="t('admin.accounts.ollamaCloud.accountMode.monthlyCreditUsdPlaceholder')" data-testid="edit-ollama-monthly-credit-usd" @@ -4159,8 +4159,8 @@ const tempUnschedEnabled = ref(false) const accountSchedulingThresholdOverrideEnabled = ref(false) const accountSchedulingThresholdOverrideValue = ref(100) const ACCOUNT_SCHEDULING_THRESHOLD_CREDENTIAL_KEY = 'account_scheduling_threshold' -const supportsAccountSchedulingThresholdOverride = computed(() => - supportsAccountSchedulingThresholdOverridePlatform(props.account?.platform) +const supportsAccountSchedulingThresholdOverride = computed( + () => supportsAccountSchedulingThresholdOverridePlatform(props.account?.platform) && !isOllamaCreditsAccount.value ) const tempUnschedRules = ref([]) const getModelMappingKey = createStableObjectKeyResolver('edit-model-mapping') @@ -5410,7 +5410,7 @@ const applyAccountSchedulingThresholdOverridePatch = ( currentCredentials: Record, platform: Account['platform'] | undefined = props.account?.platform ) => { - if (!supportsAccountSchedulingThresholdOverridePlatform(platform)) { + if (!supportsAccountSchedulingThresholdOverridePlatform(platform) || isOllamaCreditsAccount.value) { return } const current = normalizeAccountSchedulingThresholdOverride( diff --git a/frontend/src/components/account/OllamaCloudUsageCell.vue b/frontend/src/components/account/OllamaCloudUsageCell.vue index 9935f0a94b..bbf33115cd 100644 --- a/frontend/src/components/account/OllamaCloudUsageCell.vue +++ b/frontend/src/components/account/OllamaCloudUsageCell.vue @@ -104,7 +104,10 @@ const isCredits = computed(() => state.value?.mode === 'ollama_credits') const balanceNumber = computed(() => { const raw = snapshot.value?.data?.balance if (!raw) return null - const parsed = Number.parseFloat(raw.replace(/[^0-9.]/g, '')) + const cleaned = raw.replace(/[^0-9.-]/g, '') + const match = cleaned.match(/^-?\d+(?:\.\d+)?/) + if (!match) return null + const parsed = Number.parseFloat(match[0]) return Number.isFinite(parsed) ? parsed : null }) diff --git a/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts b/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts index 15542f3984..7f858cb2a6 100644 --- a/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts +++ b/frontend/src/components/account/__tests__/CreateAccountModal.spec.ts @@ -1249,6 +1249,9 @@ describe('CreateAccountModal Ollama Cloud protocol and quota mode', () => { } }) expect('monthly_credit_usd' in credentials).toBe(false) + // 默认预填平台已定价模型白名单,对齐后端 validateOllamaCloudAccountModelPricingGate 门禁 + expect(credentials?.model_mapping).toBeDefined() + expect(Object.keys(credentials?.model_mapping as Record).length).toBeGreaterThan(0) }) it('prefills the locked anthropic protocol endpoint without the /v1 suffix', async () => {