mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-05 16:07:33 +00:00
fix(frontend): 新建 ollama_cloud 账号默认预填白名单并收敛 credits 模式表单细节
This commit is contained in:
1 parent
b89c2c98c7
commit
b54f4f155a
4 files changed
+22
-7
No files matched your search
@@ -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'
|
||||
|
||||
@@ -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<TempUnschedRuleForm[]>([])
|
||||
const getModelMappingKey = createStableObjectKeyResolver<ModelMapping>('edit-model-mapping')
|
||||
@@ -5410,7 +5410,7 @@ const applyAccountSchedulingThresholdOverridePatch = (
|
||||
currentCredentials: Record<string, unknown>,
|
||||
platform: Account['platform'] | undefined = props.account?.platform
|
||||
) => {
|
||||
if (!supportsAccountSchedulingThresholdOverridePlatform(platform)) {
|
||||
if (!supportsAccountSchedulingThresholdOverridePlatform(platform) || isOllamaCreditsAccount.value) {
|
||||
return
|
||||
}
|
||||
const current = normalizeAccountSchedulingThresholdOverride(
|
||||
|
||||
@@ -104,7 +104,10 @@ const isCredits = computed(() => state.value?.mode === 'ollama_credits')
|
||||
const balanceNumber = computed<number | null>(() => {
|
||||
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
|
||||
})
|
||||
|
||||
|
||||
@@ -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<string, string>).length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it('prefills the locked anthropic protocol endpoint without the /v1 suffix', async () => {
|
||||
|
||||
Reference in new issue
Block a user