Commit 48e8efe3 authored by erio's avatar erio
Browse files

fix(frontend): hide quota notify toggle when global setting is disabled

QuotaLimitCard now requires quotaNotifyGlobalEnabled prop to control
visibility of QuotaNotifyToggle components. When the global account
quota notification is disabled in admin settings, per-account threshold
toggles are hidden in both Edit and Create account modals.
parent b1875f0b
...@@ -1477,10 +1477,47 @@ ...@@ -1477,10 +1477,47 @@
</div> </div>
</div> </div>
<!-- API Key / Bedrock 账号配额限制 --> <!-- 配额控制 (Anthropic apikey/bedrock: 配额限制 + 亲和) -->
<div v-if="form.type === 'apikey' || form.type === 'bedrock'" class="border-t border-gray-200 pt-4 dark:border-dark-600 space-y-4"> <div
v-if="form.platform === 'anthropic' && (form.type === 'apikey' || form.type === 'bedrock')"
class="border-t border-gray-200 pt-4 dark:border-dark-600 space-y-4"
>
<div class="mb-3">
<h3 class="input-label mb-0 text-base font-semibold">{{ t('admin.accounts.quotaControl.title') }}</h3>
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
{{ t('admin.accounts.quotaControl.hint') }}
</p>
</div>
<QuotaLimitCard
:totalLimit="editQuotaLimit"
:dailyLimit="editQuotaDailyLimit"
:weeklyLimit="editQuotaWeeklyLimit"
:quotaNotifyGlobalEnabled="quotaNotifyGlobalEnabled"
:dailyResetMode="editDailyResetMode"
:dailyResetHour="editDailyResetHour"
:weeklyResetMode="editWeeklyResetMode"
:weeklyResetDay="editWeeklyResetDay"
:weeklyResetHour="editWeeklyResetHour"
:resetTimezone="editResetTimezone"
@update:totalLimit="editQuotaLimit = $event"
@update:dailyLimit="editQuotaDailyLimit = $event"
@update:weeklyLimit="editQuotaWeeklyLimit = $event"
@update:dailyResetMode="editDailyResetMode = $event"
@update:dailyResetHour="editDailyResetHour = $event"
@update:weeklyResetMode="editWeeklyResetMode = $event"
@update:weeklyResetDay="editWeeklyResetDay = $event"
@update:weeklyResetHour="editWeeklyResetHour = $event"
@update:resetTimezone="editResetTimezone = $event"
/>
</div>
<!-- 配额控制 ( Anthropic apikey/bedrock) -->
<div
v-else-if="form.type === 'apikey' || form.type === 'bedrock'"
class="border-t border-gray-200 pt-4 dark:border-dark-600 space-y-4"
>
<div class="mb-3"> <div class="mb-3">
<h3 class="input-label mb-0 text-base font-semibold">{{ t('admin.accounts.quotaLimit') }}</h3> <h3 class="input-label mb-0 text-base font-semibold">{{ t('admin.accounts.quotaControl.title') }}</h3>
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400"> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
{{ t('admin.accounts.quotaLimitHint') }} {{ t('admin.accounts.quotaLimitHint') }}
</p> </p>
...@@ -1489,6 +1526,7 @@ ...@@ -1489,6 +1526,7 @@
:totalLimit="editQuotaLimit" :totalLimit="editQuotaLimit"
:dailyLimit="editQuotaDailyLimit" :dailyLimit="editQuotaDailyLimit"
:weeklyLimit="editQuotaWeeklyLimit" :weeklyLimit="editQuotaWeeklyLimit"
:quotaNotifyGlobalEnabled="quotaNotifyGlobalEnabled"
:dailyResetMode="editDailyResetMode" :dailyResetMode="editDailyResetMode"
:dailyResetHour="editDailyResetHour" :dailyResetHour="editDailyResetHour"
:weeklyResetMode="editWeeklyResetMode" :weeklyResetMode="editWeeklyResetMode"
...@@ -1823,7 +1861,7 @@ ...@@ -1823,7 +1861,7 @@
</div> </div>
</div> </div>
<!-- Quota Control Section (Anthropic OAuth/SetupToken only) --> <!-- 配额控制 (Anthropic OAuth/SetupToken: 亲和 + 窗口费用 + 会话 + RPM ) -->
<div <div
v-if="form.platform === 'anthropic' && accountCategory === 'oauth-based'" v-if="form.platform === 'anthropic' && accountCategory === 'oauth-based'"
class="border-t border-gray-200 pt-4 dark:border-dark-600 space-y-4" class="border-t border-gray-200 pt-4 dark:border-dark-600 space-y-4"
...@@ -3002,11 +3040,16 @@ const codexCLIOnlyEnabled = ref(false) ...@@ -3002,11 +3040,16 @@ const codexCLIOnlyEnabled = ref(false)
const anthropicPassthroughEnabled = ref(false) const anthropicPassthroughEnabled = ref(false)
const webSearchEmulationMode = ref('default') const webSearchEmulationMode = ref('default')
const webSearchGlobalEnabled = ref(false) const webSearchGlobalEnabled = ref(false)
const quotaNotifyGlobalEnabled = ref(false)
// Load web search global state once // Load global feature states once
adminAPI.settings.getWebSearchEmulationConfig().then(cfg => { adminAPI.settings.getWebSearchEmulationConfig().then(cfg => {
webSearchGlobalEnabled.value = cfg?.enabled === true && (cfg?.providers?.length ?? 0) > 0 webSearchGlobalEnabled.value = cfg?.enabled === true && (cfg?.providers?.length ?? 0) > 0
}).catch(() => { webSearchGlobalEnabled.value = false }) }).catch(() => { webSearchGlobalEnabled.value = false })
adminAPI.settings.getSettings().then(settings => {
quotaNotifyGlobalEnabled.value = settings.account_quota_notify_enabled === true
}).catch(() => { quotaNotifyGlobalEnabled.value = false })
const mixedScheduling = ref(false) // For antigravity accounts: enable mixed scheduling const mixedScheduling = ref(false) // For antigravity accounts: enable mixed scheduling
const allowOverages = ref(false) // For antigravity accounts: enable AI Credits overages const allowOverages = ref(false) // For antigravity accounts: enable AI Credits overages
const antigravityAccountType = ref<'oauth' | 'upstream'>('oauth') // For antigravity: oauth or upstream const antigravityAccountType = ref<'oauth' | 'upstream'>('oauth') // For antigravity: oauth or upstream
......
...@@ -1190,6 +1190,7 @@ ...@@ -1190,6 +1190,7 @@
:weeklyResetDay="editWeeklyResetDay" :weeklyResetDay="editWeeklyResetDay"
:weeklyResetHour="editWeeklyResetHour" :weeklyResetHour="editWeeklyResetHour"
:resetTimezone="editResetTimezone" :resetTimezone="editResetTimezone"
:quotaNotifyGlobalEnabled="quotaNotifyGlobalEnabled"
:quotaNotifyDailyEnabled="editQuotaNotifyDailyEnabled" :quotaNotifyDailyEnabled="editQuotaNotifyDailyEnabled"
:quotaNotifyDailyThreshold="editQuotaNotifyDailyThreshold" :quotaNotifyDailyThreshold="editQuotaNotifyDailyThreshold"
:quotaNotifyDailyThresholdType="editQuotaNotifyDailyThresholdType" :quotaNotifyDailyThresholdType="editQuotaNotifyDailyThresholdType"
...@@ -1240,6 +1241,7 @@ ...@@ -1240,6 +1241,7 @@
:weeklyResetDay="editWeeklyResetDay" :weeklyResetDay="editWeeklyResetDay"
:weeklyResetHour="editWeeklyResetHour" :weeklyResetHour="editWeeklyResetHour"
:resetTimezone="editResetTimezone" :resetTimezone="editResetTimezone"
:quotaNotifyGlobalEnabled="quotaNotifyGlobalEnabled"
:quotaNotifyDailyEnabled="editQuotaNotifyDailyEnabled" :quotaNotifyDailyEnabled="editQuotaNotifyDailyEnabled"
:quotaNotifyDailyThreshold="editQuotaNotifyDailyThreshold" :quotaNotifyDailyThreshold="editQuotaNotifyDailyThreshold"
:quotaNotifyDailyThresholdType="editQuotaNotifyDailyThresholdType" :quotaNotifyDailyThresholdType="editQuotaNotifyDailyThresholdType"
...@@ -1991,11 +1993,16 @@ const codexCLIOnlyEnabled = ref(false) ...@@ -1991,11 +1993,16 @@ const codexCLIOnlyEnabled = ref(false)
const anthropicPassthroughEnabled = ref(false) const anthropicPassthroughEnabled = ref(false)
const webSearchEmulationMode = ref('default') const webSearchEmulationMode = ref('default')
const webSearchGlobalEnabled = ref(false) const webSearchGlobalEnabled = ref(false)
const quotaNotifyGlobalEnabled = ref(false)
// Load web search global state once // Load global feature states once
adminAPI.settings.getWebSearchEmulationConfig().then(cfg => { adminAPI.settings.getWebSearchEmulationConfig().then(cfg => {
webSearchGlobalEnabled.value = cfg?.enabled === true && (cfg?.providers?.length ?? 0) > 0 webSearchGlobalEnabled.value = cfg?.enabled === true && (cfg?.providers?.length ?? 0) > 0
}).catch(() => { webSearchGlobalEnabled.value = false }) }).catch(() => { webSearchGlobalEnabled.value = false })
adminAPI.settings.getSettings().then(settings => {
quotaNotifyGlobalEnabled.value = settings.account_quota_notify_enabled === true
}).catch(() => { quotaNotifyGlobalEnabled.value = false })
const editQuotaLimit = ref<number | null>(null) const editQuotaLimit = ref<number | null>(null)
const editQuotaDailyLimit = ref<number | null>(null) const editQuotaDailyLimit = ref<number | null>(null)
const editQuotaWeeklyLimit = ref<number | null>(null) const editQuotaWeeklyLimit = ref<number | null>(null)
......
...@@ -15,6 +15,7 @@ const props = withDefaults(defineProps<{ ...@@ -15,6 +15,7 @@ const props = withDefaults(defineProps<{
weeklyResetDay: number | null weeklyResetDay: number | null
weeklyResetHour: number | null weeklyResetHour: number | null
resetTimezone: string | null resetTimezone: string | null
quotaNotifyGlobalEnabled?: boolean
quotaNotifyDailyEnabled?: boolean | null quotaNotifyDailyEnabled?: boolean | null
quotaNotifyDailyThreshold?: number | null quotaNotifyDailyThreshold?: number | null
quotaNotifyDailyThresholdType?: string | null quotaNotifyDailyThresholdType?: string | null
...@@ -25,6 +26,7 @@ const props = withDefaults(defineProps<{ ...@@ -25,6 +26,7 @@ const props = withDefaults(defineProps<{
quotaNotifyTotalThreshold?: number | null quotaNotifyTotalThreshold?: number | null
quotaNotifyTotalThresholdType?: string | null quotaNotifyTotalThresholdType?: string | null
}>(), { }>(), {
quotaNotifyGlobalEnabled: false,
quotaNotifyDailyEnabled: null, quotaNotifyDailyEnabled: null,
quotaNotifyDailyThreshold: null, quotaNotifyDailyThreshold: null,
quotaNotifyDailyThresholdType: null, quotaNotifyDailyThresholdType: null,
...@@ -234,7 +236,7 @@ const onWeeklyModeChange = (e: Event) => { ...@@ -234,7 +236,7 @@ const onWeeklyModeChange = (e: Event) => {
</p> </p>
<!-- 日配额告警 --> <!-- 日配额告警 -->
<QuotaNotifyToggle <QuotaNotifyToggle
v-if="dailyLimit && dailyLimit > 0" v-if="quotaNotifyGlobalEnabled && dailyLimit && dailyLimit > 0"
:enabled="props.quotaNotifyDailyEnabled" :enabled="props.quotaNotifyDailyEnabled"
:threshold="props.quotaNotifyDailyThreshold" :threshold="props.quotaNotifyDailyThreshold"
:threshold-type="props.quotaNotifyDailyThresholdType" :threshold-type="props.quotaNotifyDailyThresholdType"
...@@ -300,7 +302,7 @@ const onWeeklyModeChange = (e: Event) => { ...@@ -300,7 +302,7 @@ const onWeeklyModeChange = (e: Event) => {
</p> </p>
<!-- 周配额告警 --> <!-- 周配额告警 -->
<QuotaNotifyToggle <QuotaNotifyToggle
v-if="weeklyLimit && weeklyLimit > 0" v-if="quotaNotifyGlobalEnabled && weeklyLimit && weeklyLimit > 0"
:enabled="props.quotaNotifyWeeklyEnabled" :enabled="props.quotaNotifyWeeklyEnabled"
:threshold="props.quotaNotifyWeeklyThreshold" :threshold="props.quotaNotifyWeeklyThreshold"
:threshold-type="props.quotaNotifyWeeklyThresholdType" :threshold-type="props.quotaNotifyWeeklyThresholdType"
...@@ -340,7 +342,7 @@ const onWeeklyModeChange = (e: Event) => { ...@@ -340,7 +342,7 @@ const onWeeklyModeChange = (e: Event) => {
<p class="input-hint">{{ t('admin.accounts.quotaTotalLimitHint') }}</p> <p class="input-hint">{{ t('admin.accounts.quotaTotalLimitHint') }}</p>
<!-- 总配额告警 --> <!-- 总配额告警 -->
<QuotaNotifyToggle <QuotaNotifyToggle
v-if="totalLimit && totalLimit > 0" v-if="quotaNotifyGlobalEnabled && totalLimit && totalLimit > 0"
:enabled="props.quotaNotifyTotalEnabled" :enabled="props.quotaNotifyTotalEnabled"
:threshold="props.quotaNotifyTotalThreshold" :threshold="props.quotaNotifyTotalThreshold"
:threshold-type="props.quotaNotifyTotalThresholdType" :threshold-type="props.quotaNotifyTotalThresholdType"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment