diff --git a/backend/cmd/server/VERSION b/backend/cmd/server/VERSION index f3cd6fef..68dda295 100644 --- a/backend/cmd/server/VERSION +++ b/backend/cmd/server/VERSION @@ -1 +1 @@ -0.1.110.49 +0.1.110.51 diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue index ba7bad51..432fa080 100644 --- a/frontend/src/components/account/CreateAccountModal.vue +++ b/frontend/src/components/account/CreateAccountModal.vue @@ -1493,15 +1493,15 @@ :dailyLimit="editQuotaDailyLimit" :weeklyLimit="editQuotaWeeklyLimit" :quotaNotifyGlobalEnabled="quotaNotifyGlobalEnabled" - :quotaNotifyDailyEnabled="quotaNotifyDailyEnabled" - :quotaNotifyDailyThreshold="quotaNotifyDailyThreshold" - :quotaNotifyDailyThresholdType="quotaNotifyDailyThresholdType" - :quotaNotifyWeeklyEnabled="quotaNotifyWeeklyEnabled" - :quotaNotifyWeeklyThreshold="quotaNotifyWeeklyThreshold" - :quotaNotifyWeeklyThresholdType="quotaNotifyWeeklyThresholdType" - :quotaNotifyTotalEnabled="quotaNotifyTotalEnabled" - :quotaNotifyTotalThreshold="quotaNotifyTotalThreshold" - :quotaNotifyTotalThresholdType="quotaNotifyTotalThresholdType" + :quotaNotifyDailyEnabled="quotaNotifyState.daily.enabled" + :quotaNotifyDailyThreshold="quotaNotifyState.daily.threshold" + :quotaNotifyDailyThresholdType="quotaNotifyState.daily.thresholdType" + :quotaNotifyWeeklyEnabled="quotaNotifyState.weekly.enabled" + :quotaNotifyWeeklyThreshold="quotaNotifyState.weekly.threshold" + :quotaNotifyWeeklyThresholdType="quotaNotifyState.weekly.thresholdType" + :quotaNotifyTotalEnabled="quotaNotifyState.total.enabled" + :quotaNotifyTotalThreshold="quotaNotifyState.total.threshold" + :quotaNotifyTotalThresholdType="quotaNotifyState.total.thresholdType" :dailyResetMode="editDailyResetMode" :dailyResetHour="editDailyResetHour" :weeklyResetMode="editWeeklyResetMode" @@ -1511,15 +1511,15 @@ @update:totalLimit="editQuotaLimit = $event" @update:dailyLimit="editQuotaDailyLimit = $event" @update:weeklyLimit="editQuotaWeeklyLimit = $event" - @update:quotaNotifyDailyEnabled="quotaNotifyDailyEnabled = $event" - @update:quotaNotifyDailyThreshold="quotaNotifyDailyThreshold = $event" - @update:quotaNotifyDailyThresholdType="quotaNotifyDailyThresholdType = $event" - @update:quotaNotifyWeeklyEnabled="quotaNotifyWeeklyEnabled = $event" - @update:quotaNotifyWeeklyThreshold="quotaNotifyWeeklyThreshold = $event" - @update:quotaNotifyWeeklyThresholdType="quotaNotifyWeeklyThresholdType = $event" - @update:quotaNotifyTotalEnabled="quotaNotifyTotalEnabled = $event" - @update:quotaNotifyTotalThreshold="quotaNotifyTotalThreshold = $event" - @update:quotaNotifyTotalThresholdType="quotaNotifyTotalThresholdType = $event" + @update:quotaNotifyDailyEnabled="quotaNotifyState.daily.enabled = $event" + @update:quotaNotifyDailyThreshold="quotaNotifyState.daily.threshold = $event" + @update:quotaNotifyDailyThresholdType="quotaNotifyState.daily.thresholdType = $event" + @update:quotaNotifyWeeklyEnabled="quotaNotifyState.weekly.enabled = $event" + @update:quotaNotifyWeeklyThreshold="quotaNotifyState.weekly.threshold = $event" + @update:quotaNotifyWeeklyThresholdType="quotaNotifyState.weekly.thresholdType = $event" + @update:quotaNotifyTotalEnabled="quotaNotifyState.total.enabled = $event" + @update:quotaNotifyTotalThreshold="quotaNotifyState.total.threshold = $event" + @update:quotaNotifyTotalThresholdType="quotaNotifyState.total.thresholdType = $event" @update:dailyResetMode="editDailyResetMode = $event" @update:dailyResetHour="editDailyResetHour = $event" @update:weeklyResetMode="editWeeklyResetMode = $event" @@ -1545,15 +1545,15 @@ :dailyLimit="editQuotaDailyLimit" :weeklyLimit="editQuotaWeeklyLimit" :quotaNotifyGlobalEnabled="quotaNotifyGlobalEnabled" - :quotaNotifyDailyEnabled="quotaNotifyDailyEnabled" - :quotaNotifyDailyThreshold="quotaNotifyDailyThreshold" - :quotaNotifyDailyThresholdType="quotaNotifyDailyThresholdType" - :quotaNotifyWeeklyEnabled="quotaNotifyWeeklyEnabled" - :quotaNotifyWeeklyThreshold="quotaNotifyWeeklyThreshold" - :quotaNotifyWeeklyThresholdType="quotaNotifyWeeklyThresholdType" - :quotaNotifyTotalEnabled="quotaNotifyTotalEnabled" - :quotaNotifyTotalThreshold="quotaNotifyTotalThreshold" - :quotaNotifyTotalThresholdType="quotaNotifyTotalThresholdType" + :quotaNotifyDailyEnabled="quotaNotifyState.daily.enabled" + :quotaNotifyDailyThreshold="quotaNotifyState.daily.threshold" + :quotaNotifyDailyThresholdType="quotaNotifyState.daily.thresholdType" + :quotaNotifyWeeklyEnabled="quotaNotifyState.weekly.enabled" + :quotaNotifyWeeklyThreshold="quotaNotifyState.weekly.threshold" + :quotaNotifyWeeklyThresholdType="quotaNotifyState.weekly.thresholdType" + :quotaNotifyTotalEnabled="quotaNotifyState.total.enabled" + :quotaNotifyTotalThreshold="quotaNotifyState.total.threshold" + :quotaNotifyTotalThresholdType="quotaNotifyState.total.thresholdType" :dailyResetMode="editDailyResetMode" :dailyResetHour="editDailyResetHour" :weeklyResetMode="editWeeklyResetMode" @@ -1563,15 +1563,15 @@ @update:totalLimit="editQuotaLimit = $event" @update:dailyLimit="editQuotaDailyLimit = $event" @update:weeklyLimit="editQuotaWeeklyLimit = $event" - @update:quotaNotifyDailyEnabled="quotaNotifyDailyEnabled = $event" - @update:quotaNotifyDailyThreshold="quotaNotifyDailyThreshold = $event" - @update:quotaNotifyDailyThresholdType="quotaNotifyDailyThresholdType = $event" - @update:quotaNotifyWeeklyEnabled="quotaNotifyWeeklyEnabled = $event" - @update:quotaNotifyWeeklyThreshold="quotaNotifyWeeklyThreshold = $event" - @update:quotaNotifyWeeklyThresholdType="quotaNotifyWeeklyThresholdType = $event" - @update:quotaNotifyTotalEnabled="quotaNotifyTotalEnabled = $event" - @update:quotaNotifyTotalThreshold="quotaNotifyTotalThreshold = $event" - @update:quotaNotifyTotalThresholdType="quotaNotifyTotalThresholdType = $event" + @update:quotaNotifyDailyEnabled="quotaNotifyState.daily.enabled = $event" + @update:quotaNotifyDailyThreshold="quotaNotifyState.daily.threshold = $event" + @update:quotaNotifyDailyThresholdType="quotaNotifyState.daily.thresholdType = $event" + @update:quotaNotifyWeeklyEnabled="quotaNotifyState.weekly.enabled = $event" + @update:quotaNotifyWeeklyThreshold="quotaNotifyState.weekly.threshold = $event" + @update:quotaNotifyWeeklyThresholdType="quotaNotifyState.weekly.thresholdType = $event" + @update:quotaNotifyTotalEnabled="quotaNotifyState.total.enabled = $event" + @update:quotaNotifyTotalThreshold="quotaNotifyState.total.threshold = $event" + @update:quotaNotifyTotalThresholdType="quotaNotifyState.total.thresholdType = $event" @update:dailyResetMode="editDailyResetMode = $event" @update:dailyResetHour="editDailyResetHour = $event" @update:weeklyResetMode="editWeeklyResetMode = $event" @@ -2903,6 +2903,7 @@ import { } from '@/composables/useModelWhitelist' import { useAuthStore } from '@/stores/auth' import { adminAPI } from '@/api/admin' +import { useQuotaNotifyState } from '@/composables/useQuotaNotifyState' import { useAccountOAuth, type AddMethod, @@ -3076,25 +3077,19 @@ const codexCLIOnlyEnabled = ref(false) const anthropicPassthroughEnabled = ref(false) const webSearchEmulationMode = ref('default') const webSearchGlobalEnabled = ref(false) -const quotaNotifyGlobalEnabled = ref(false) -const quotaNotifyDailyEnabled = ref(null) -const quotaNotifyDailyThreshold = ref(null) -const quotaNotifyDailyThresholdType = ref(null) -const quotaNotifyWeeklyEnabled = ref(null) -const quotaNotifyWeeklyThreshold = ref(null) -const quotaNotifyWeeklyThresholdType = ref(null) -const quotaNotifyTotalEnabled = ref(null) -const quotaNotifyTotalThreshold = ref(null) -const quotaNotifyTotalThresholdType = ref(null) +const { + globalEnabled: quotaNotifyGlobalEnabled, + state: quotaNotifyState, + loadGlobalState: loadQuotaNotifyGlobal, + writeToExtra: writeQuotaNotifyToExtra, +} = useQuotaNotifyState() // Load global feature states once adminAPI.settings.getWebSearchEmulationConfig().then(cfg => { webSearchGlobalEnabled.value = cfg?.enabled === true && (cfg?.providers?.length ?? 0) > 0 }).catch(() => { webSearchGlobalEnabled.value = false }) -adminAPI.settings.getSettings().then(settings => { - quotaNotifyGlobalEnabled.value = settings.account_quota_notify_enabled === true -}).catch(() => { quotaNotifyGlobalEnabled.value = false }) +loadQuotaNotifyGlobal() const mixedScheduling = ref(false) // For antigravity accounts: enable mixed scheduling const allowOverages = ref(false) // For antigravity accounts: enable AI Credits overages const antigravityAccountType = ref<'oauth' | 'upstream'>('oauth') // For antigravity: oauth or upstream @@ -4199,21 +4194,7 @@ const createAccountAndFinish = async ( quotaExtra.quota_reset_timezone = editResetTimezone.value || 'UTC' } // Quota notify config - if (quotaNotifyDailyEnabled.value) { - quotaExtra.quota_notify_daily_enabled = true - if (quotaNotifyDailyThreshold.value != null) quotaExtra.quota_notify_daily_threshold = quotaNotifyDailyThreshold.value - quotaExtra.quota_notify_daily_threshold_type = quotaNotifyDailyThresholdType.value || 'fixed' - } - if (quotaNotifyWeeklyEnabled.value) { - quotaExtra.quota_notify_weekly_enabled = true - if (quotaNotifyWeeklyThreshold.value != null) quotaExtra.quota_notify_weekly_threshold = quotaNotifyWeeklyThreshold.value - quotaExtra.quota_notify_weekly_threshold_type = quotaNotifyWeeklyThresholdType.value || 'fixed' - } - if (quotaNotifyTotalEnabled.value) { - quotaExtra.quota_notify_total_enabled = true - if (quotaNotifyTotalThreshold.value != null) quotaExtra.quota_notify_total_threshold = quotaNotifyTotalThreshold.value - quotaExtra.quota_notify_total_threshold_type = quotaNotifyTotalThresholdType.value || 'fixed' - } + writeQuotaNotifyToExtra(quotaExtra, 'create') if (Object.keys(quotaExtra).length > 0) { finalExtra = quotaExtra } diff --git a/frontend/src/components/account/EditAccountModal.vue b/frontend/src/components/account/EditAccountModal.vue index 92761b35..e5065d7a 100644 --- a/frontend/src/components/account/EditAccountModal.vue +++ b/frontend/src/components/account/EditAccountModal.vue @@ -1191,15 +1191,15 @@ :weeklyResetHour="editWeeklyResetHour" :resetTimezone="editResetTimezone" :quotaNotifyGlobalEnabled="quotaNotifyGlobalEnabled" - :quotaNotifyDailyEnabled="editQuotaNotifyDailyEnabled" - :quotaNotifyDailyThreshold="editQuotaNotifyDailyThreshold" - :quotaNotifyDailyThresholdType="editQuotaNotifyDailyThresholdType" - :quotaNotifyWeeklyEnabled="editQuotaNotifyWeeklyEnabled" - :quotaNotifyWeeklyThreshold="editQuotaNotifyWeeklyThreshold" - :quotaNotifyWeeklyThresholdType="editQuotaNotifyWeeklyThresholdType" - :quotaNotifyTotalEnabled="editQuotaNotifyTotalEnabled" - :quotaNotifyTotalThreshold="editQuotaNotifyTotalThreshold" - :quotaNotifyTotalThresholdType="editQuotaNotifyTotalThresholdType" + :quotaNotifyDailyEnabled="quotaNotifyState.daily.enabled" + :quotaNotifyDailyThreshold="quotaNotifyState.daily.threshold" + :quotaNotifyDailyThresholdType="quotaNotifyState.daily.thresholdType" + :quotaNotifyWeeklyEnabled="quotaNotifyState.weekly.enabled" + :quotaNotifyWeeklyThreshold="quotaNotifyState.weekly.threshold" + :quotaNotifyWeeklyThresholdType="quotaNotifyState.weekly.thresholdType" + :quotaNotifyTotalEnabled="quotaNotifyState.total.enabled" + :quotaNotifyTotalThreshold="quotaNotifyState.total.threshold" + :quotaNotifyTotalThresholdType="quotaNotifyState.total.thresholdType" @update:totalLimit="editQuotaLimit = $event" @update:dailyLimit="editQuotaDailyLimit = $event" @update:weeklyLimit="editQuotaWeeklyLimit = $event" @@ -1209,15 +1209,15 @@ @update:weeklyResetDay="editWeeklyResetDay = $event" @update:weeklyResetHour="editWeeklyResetHour = $event" @update:resetTimezone="editResetTimezone = $event" - @update:quotaNotifyDailyEnabled="editQuotaNotifyDailyEnabled = $event" - @update:quotaNotifyDailyThreshold="editQuotaNotifyDailyThreshold = $event" - @update:quotaNotifyDailyThresholdType="editQuotaNotifyDailyThresholdType = $event" - @update:quotaNotifyWeeklyEnabled="editQuotaNotifyWeeklyEnabled = $event" - @update:quotaNotifyWeeklyThreshold="editQuotaNotifyWeeklyThreshold = $event" - @update:quotaNotifyWeeklyThresholdType="editQuotaNotifyWeeklyThresholdType = $event" - @update:quotaNotifyTotalEnabled="editQuotaNotifyTotalEnabled = $event" - @update:quotaNotifyTotalThreshold="editQuotaNotifyTotalThreshold = $event" - @update:quotaNotifyTotalThresholdType="editQuotaNotifyTotalThresholdType = $event" + @update:quotaNotifyDailyEnabled="quotaNotifyState.daily.enabled = $event" + @update:quotaNotifyDailyThreshold="quotaNotifyState.daily.threshold = $event" + @update:quotaNotifyDailyThresholdType="quotaNotifyState.daily.thresholdType = $event" + @update:quotaNotifyWeeklyEnabled="quotaNotifyState.weekly.enabled = $event" + @update:quotaNotifyWeeklyThreshold="quotaNotifyState.weekly.threshold = $event" + @update:quotaNotifyWeeklyThresholdType="quotaNotifyState.weekly.thresholdType = $event" + @update:quotaNotifyTotalEnabled="quotaNotifyState.total.enabled = $event" + @update:quotaNotifyTotalThreshold="quotaNotifyState.total.threshold = $event" + @update:quotaNotifyTotalThresholdType="quotaNotifyState.total.thresholdType = $event" /> @@ -1242,15 +1242,15 @@ :weeklyResetHour="editWeeklyResetHour" :resetTimezone="editResetTimezone" :quotaNotifyGlobalEnabled="quotaNotifyGlobalEnabled" - :quotaNotifyDailyEnabled="editQuotaNotifyDailyEnabled" - :quotaNotifyDailyThreshold="editQuotaNotifyDailyThreshold" - :quotaNotifyDailyThresholdType="editQuotaNotifyDailyThresholdType" - :quotaNotifyWeeklyEnabled="editQuotaNotifyWeeklyEnabled" - :quotaNotifyWeeklyThreshold="editQuotaNotifyWeeklyThreshold" - :quotaNotifyWeeklyThresholdType="editQuotaNotifyWeeklyThresholdType" - :quotaNotifyTotalEnabled="editQuotaNotifyTotalEnabled" - :quotaNotifyTotalThreshold="editQuotaNotifyTotalThreshold" - :quotaNotifyTotalThresholdType="editQuotaNotifyTotalThresholdType" + :quotaNotifyDailyEnabled="quotaNotifyState.daily.enabled" + :quotaNotifyDailyThreshold="quotaNotifyState.daily.threshold" + :quotaNotifyDailyThresholdType="quotaNotifyState.daily.thresholdType" + :quotaNotifyWeeklyEnabled="quotaNotifyState.weekly.enabled" + :quotaNotifyWeeklyThreshold="quotaNotifyState.weekly.threshold" + :quotaNotifyWeeklyThresholdType="quotaNotifyState.weekly.thresholdType" + :quotaNotifyTotalEnabled="quotaNotifyState.total.enabled" + :quotaNotifyTotalThreshold="quotaNotifyState.total.threshold" + :quotaNotifyTotalThresholdType="quotaNotifyState.total.thresholdType" @update:totalLimit="editQuotaLimit = $event" @update:dailyLimit="editQuotaDailyLimit = $event" @update:weeklyLimit="editQuotaWeeklyLimit = $event" @@ -1260,15 +1260,15 @@ @update:weeklyResetDay="editWeeklyResetDay = $event" @update:weeklyResetHour="editWeeklyResetHour = $event" @update:resetTimezone="editResetTimezone = $event" - @update:quotaNotifyDailyEnabled="editQuotaNotifyDailyEnabled = $event" - @update:quotaNotifyDailyThreshold="editQuotaNotifyDailyThreshold = $event" - @update:quotaNotifyDailyThresholdType="editQuotaNotifyDailyThresholdType = $event" - @update:quotaNotifyWeeklyEnabled="editQuotaNotifyWeeklyEnabled = $event" - @update:quotaNotifyWeeklyThreshold="editQuotaNotifyWeeklyThreshold = $event" - @update:quotaNotifyWeeklyThresholdType="editQuotaNotifyWeeklyThresholdType = $event" - @update:quotaNotifyTotalEnabled="editQuotaNotifyTotalEnabled = $event" - @update:quotaNotifyTotalThreshold="editQuotaNotifyTotalThreshold = $event" - @update:quotaNotifyTotalThresholdType="editQuotaNotifyTotalThresholdType = $event" + @update:quotaNotifyDailyEnabled="quotaNotifyState.daily.enabled = $event" + @update:quotaNotifyDailyThreshold="quotaNotifyState.daily.threshold = $event" + @update:quotaNotifyDailyThresholdType="quotaNotifyState.daily.thresholdType = $event" + @update:quotaNotifyWeeklyEnabled="quotaNotifyState.weekly.enabled = $event" + @update:quotaNotifyWeeklyThreshold="quotaNotifyState.weekly.threshold = $event" + @update:quotaNotifyWeeklyThresholdType="quotaNotifyState.weekly.thresholdType = $event" + @update:quotaNotifyTotalEnabled="quotaNotifyState.total.enabled = $event" + @update:quotaNotifyTotalThreshold="quotaNotifyState.total.threshold = $event" + @update:quotaNotifyTotalThresholdType="quotaNotifyState.total.thresholdType = $event" /> @@ -1844,6 +1844,7 @@ import { useI18n } from 'vue-i18n' import { useAppStore } from '@/stores/app' import { useAuthStore } from '@/stores/auth' import { adminAPI } from '@/api/admin' +import { useQuotaNotifyState } from '@/composables/useQuotaNotifyState' import type { Account, Proxy, AdminGroup, CheckMixedChannelResponse } from '@/types' import BaseDialog from '@/components/common/BaseDialog.vue' import ConfirmDialog from '@/components/common/ConfirmDialog.vue' @@ -1993,16 +1994,21 @@ const codexCLIOnlyEnabled = ref(false) const anthropicPassthroughEnabled = ref(false) const webSearchEmulationMode = ref('default') const webSearchGlobalEnabled = ref(false) -const quotaNotifyGlobalEnabled = ref(false) +const { + globalEnabled: quotaNotifyGlobalEnabled, + state: quotaNotifyState, + loadGlobalState: loadQuotaNotifyGlobal, + loadFromExtra: loadQuotaNotifyFromExtra, + writeToExtra: writeQuotaNotifyToExtra, + reset: resetQuotaNotify, +} = useQuotaNotifyState() // Load global feature states once adminAPI.settings.getWebSearchEmulationConfig().then(cfg => { webSearchGlobalEnabled.value = cfg?.enabled === true && (cfg?.providers?.length ?? 0) > 0 }).catch(() => { webSearchGlobalEnabled.value = false }) -adminAPI.settings.getSettings().then(settings => { - quotaNotifyGlobalEnabled.value = settings.account_quota_notify_enabled === true -}).catch(() => { quotaNotifyGlobalEnabled.value = false }) +loadQuotaNotifyGlobal() const editQuotaLimit = ref(null) const editQuotaDailyLimit = ref(null) const editQuotaWeeklyLimit = ref(null) @@ -2012,15 +2018,6 @@ const editWeeklyResetMode = ref<'rolling' | 'fixed' | null>(null) const editWeeklyResetDay = ref(null) const editWeeklyResetHour = ref(null) const editResetTimezone = ref(null) -const editQuotaNotifyDailyEnabled = ref(null) -const editQuotaNotifyDailyThreshold = ref(null) -const editQuotaNotifyDailyThresholdType = ref(null) -const editQuotaNotifyWeeklyEnabled = ref(null) -const editQuotaNotifyWeeklyThreshold = ref(null) -const editQuotaNotifyWeeklyThresholdType = ref(null) -const editQuotaNotifyTotalEnabled = ref(null) -const editQuotaNotifyTotalThreshold = ref(null) -const editQuotaNotifyTotalThresholdType = ref(null) const openAIWSModeOptions = computed(() => [ { value: OPENAI_WS_MODE_OFF, label: t('admin.accounts.openai.wsModeOff') }, // TODO: ctx_pool 选项暂时隐藏,待测试完成后恢复 @@ -2229,15 +2226,7 @@ const syncFormFromAccount = (newAccount: Account | null) => { editWeeklyResetHour.value = (extra?.quota_weekly_reset_hour as number) ?? null editResetTimezone.value = (extra?.quota_reset_timezone as string) || null // Load quota notify config - editQuotaNotifyDailyEnabled.value = (extra?.quota_notify_daily_enabled as boolean) ?? null - editQuotaNotifyDailyThreshold.value = (extra?.quota_notify_daily_threshold as number) ?? null - editQuotaNotifyDailyThresholdType.value = (extra?.quota_notify_daily_threshold_type as string) ?? null - editQuotaNotifyWeeklyEnabled.value = (extra?.quota_notify_weekly_enabled as boolean) ?? null - editQuotaNotifyWeeklyThreshold.value = (extra?.quota_notify_weekly_threshold as number) ?? null - editQuotaNotifyWeeklyThresholdType.value = (extra?.quota_notify_weekly_threshold_type as string) ?? null - editQuotaNotifyTotalEnabled.value = (extra?.quota_notify_total_enabled as boolean) ?? null - editQuotaNotifyTotalThreshold.value = (extra?.quota_notify_total_threshold as number) ?? null - editQuotaNotifyTotalThresholdType.value = (extra?.quota_notify_total_threshold_type as string) ?? null + loadQuotaNotifyFromExtra(extra) } else { editQuotaLimit.value = null editQuotaDailyLimit.value = null @@ -2248,12 +2237,7 @@ const syncFormFromAccount = (newAccount: Account | null) => { editWeeklyResetDay.value = null editWeeklyResetHour.value = null editResetTimezone.value = null - editQuotaNotifyDailyEnabled.value = null - editQuotaNotifyDailyThreshold.value = null - editQuotaNotifyWeeklyEnabled.value = null - editQuotaNotifyWeeklyThreshold.value = null - editQuotaNotifyTotalEnabled.value = null - editQuotaNotifyTotalThreshold.value = null + resetQuotaNotify() } // Load antigravity model mapping (Antigravity 只支持映射模式) @@ -2369,12 +2353,7 @@ const syncFormFromAccount = (newAccount: Account | null) => { editQuotaDailyLimit.value = typeof bedrockExtra.quota_daily_limit === 'number' ? bedrockExtra.quota_daily_limit : null editQuotaWeeklyLimit.value = typeof bedrockExtra.quota_weekly_limit === 'number' ? bedrockExtra.quota_weekly_limit : null // Load quota notify for bedrock - editQuotaNotifyDailyEnabled.value = (bedrockExtra.quota_notify_daily_enabled as boolean) ?? null - editQuotaNotifyDailyThreshold.value = (bedrockExtra.quota_notify_daily_threshold as number) ?? null - editQuotaNotifyWeeklyEnabled.value = (bedrockExtra.quota_notify_weekly_enabled as boolean) ?? null - editQuotaNotifyWeeklyThreshold.value = (bedrockExtra.quota_notify_weekly_threshold as number) ?? null - editQuotaNotifyTotalEnabled.value = (bedrockExtra.quota_notify_total_enabled as boolean) ?? null - editQuotaNotifyTotalThreshold.value = (bedrockExtra.quota_notify_total_threshold as number) ?? null + loadQuotaNotifyFromExtra(bedrockExtra) // Load model mappings for bedrock const existingMappings = bedrockCreds.model_mapping as Record | undefined @@ -3291,45 +3270,7 @@ const handleSubmit = async () => { delete newExtra.quota_reset_timezone } // Quota notify config - if (editQuotaNotifyDailyEnabled.value) { - newExtra.quota_notify_daily_enabled = true - if (editQuotaNotifyDailyThreshold.value != null) { - newExtra.quota_notify_daily_threshold = editQuotaNotifyDailyThreshold.value - } else { - delete newExtra.quota_notify_daily_threshold - } - newExtra.quota_notify_daily_threshold_type = editQuotaNotifyDailyThresholdType.value || 'fixed' - } else { - delete newExtra.quota_notify_daily_enabled - delete newExtra.quota_notify_daily_threshold - delete newExtra.quota_notify_daily_threshold_type - } - if (editQuotaNotifyWeeklyEnabled.value) { - newExtra.quota_notify_weekly_enabled = true - if (editQuotaNotifyWeeklyThreshold.value != null) { - newExtra.quota_notify_weekly_threshold = editQuotaNotifyWeeklyThreshold.value - } else { - delete newExtra.quota_notify_weekly_threshold - } - newExtra.quota_notify_weekly_threshold_type = editQuotaNotifyWeeklyThresholdType.value || 'fixed' - } else { - delete newExtra.quota_notify_weekly_enabled - delete newExtra.quota_notify_weekly_threshold - delete newExtra.quota_notify_weekly_threshold_type - } - if (editQuotaNotifyTotalEnabled.value) { - newExtra.quota_notify_total_enabled = true - if (editQuotaNotifyTotalThreshold.value != null) { - newExtra.quota_notify_total_threshold = editQuotaNotifyTotalThreshold.value - } else { - delete newExtra.quota_notify_total_threshold - } - newExtra.quota_notify_total_threshold_type = editQuotaNotifyTotalThresholdType.value || 'fixed' - } else { - delete newExtra.quota_notify_total_enabled - delete newExtra.quota_notify_total_threshold - delete newExtra.quota_notify_total_threshold_type - } + writeQuotaNotifyToExtra(newExtra, 'update') updatePayload.extra = newExtra } diff --git a/frontend/src/components/account/QuotaDimensionRow.vue b/frontend/src/components/account/QuotaDimensionRow.vue new file mode 100644 index 00000000..1406faa9 --- /dev/null +++ b/frontend/src/components/account/QuotaDimensionRow.vue @@ -0,0 +1,108 @@ + + + diff --git a/frontend/src/components/account/QuotaLimitCard.vue b/frontend/src/components/account/QuotaLimitCard.vue index 5f0c7c2c..77e437a8 100644 --- a/frontend/src/components/account/QuotaLimitCard.vue +++ b/frontend/src/components/account/QuotaLimitCard.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/composables/useQuotaNotifyState.ts b/frontend/src/composables/useQuotaNotifyState.ts new file mode 100644 index 00000000..1c6705d3 --- /dev/null +++ b/frontend/src/composables/useQuotaNotifyState.ts @@ -0,0 +1,69 @@ +import { reactive, ref } from 'vue' +import { adminAPI } from '@/api/admin' +import { QUOTA_THRESHOLD_TYPE_FIXED } from '@/constants/account' + +export const QUOTA_NOTIFY_DIMS = ['daily', 'weekly', 'total'] as const +export type QuotaNotifyDim = (typeof QUOTA_NOTIFY_DIMS)[number] + +interface DimState { + enabled: boolean | null + threshold: number | null + thresholdType: string | null +} + +export function useQuotaNotifyState() { + const globalEnabled = ref(false) + const state = reactive>({ + daily: { enabled: null, threshold: null, thresholdType: null }, + weekly: { enabled: null, threshold: null, thresholdType: null }, + total: { enabled: null, threshold: null, thresholdType: null }, + }) + + function loadGlobalState() { + adminAPI.settings + .getSettings() + .then((settings) => { + globalEnabled.value = settings.account_quota_notify_enabled === true + }) + .catch(() => { + globalEnabled.value = false + }) + } + + function loadFromExtra(extra: Record | null | undefined) { + for (const d of QUOTA_NOTIFY_DIMS) { + state[d].enabled = (extra?.[`quota_notify_${d}_enabled`] as boolean) ?? null + state[d].threshold = (extra?.[`quota_notify_${d}_threshold`] as number) ?? null + state[d].thresholdType = (extra?.[`quota_notify_${d}_threshold_type`] as string) ?? null + } + } + + function writeToExtra(extra: Record, mode: 'create' | 'update') { + for (const d of QUOTA_NOTIFY_DIMS) { + const s = state[d] + if (s.enabled) { + extra[`quota_notify_${d}_enabled`] = true + if (s.threshold != null) { + extra[`quota_notify_${d}_threshold`] = s.threshold + } else if (mode === 'update') { + delete extra[`quota_notify_${d}_threshold`] + } + extra[`quota_notify_${d}_threshold_type`] = s.thresholdType || QUOTA_THRESHOLD_TYPE_FIXED + } else if (mode === 'update') { + delete extra[`quota_notify_${d}_enabled`] + delete extra[`quota_notify_${d}_threshold`] + delete extra[`quota_notify_${d}_threshold_type`] + } + } + } + + function reset() { + for (const d of QUOTA_NOTIFY_DIMS) { + state[d].enabled = null + state[d].threshold = null + state[d].thresholdType = null + } + } + + return { globalEnabled, state, loadGlobalState, loadFromExtra, writeToExtra, reset } +} diff --git a/frontend/src/views/admin/orders/AdminPaymentPlansView.vue b/frontend/src/views/admin/orders/AdminPaymentPlansView.vue index 639b4f66..28b82da5 100644 --- a/frontend/src/views/admin/orders/AdminPaymentPlansView.vue +++ b/frontend/src/views/admin/orders/AdminPaymentPlansView.vue @@ -29,7 +29,7 @@ @@ -67,86 +67,14 @@ - -
-
-
- - -
-
- - -
-
- - -
-
- -
-
-
{{ t('payment.admin.dailyLimit') }}: {{ selectedGroupInfo.daily_limit_usd != null ? '$' + selectedGroupInfo.daily_limit_usd : t('payment.admin.unlimited') }}
-
{{ t('payment.admin.weeklyLimit') }}: {{ selectedGroupInfo.weekly_limit_usd != null ? '$' + selectedGroupInfo.weekly_limit_usd : t('payment.admin.unlimited') }}
-
{{ t('payment.admin.monthlyLimit') }}: {{ selectedGroupInfo.monthly_limit_usd != null ? '$' + selectedGroupInfo.monthly_limit_usd : t('payment.admin.unlimited') }}
-
-
- -
-
-
-
-
-
-
-
-
-

{{ t('payment.admin.featuresHint') }}

-
-
- - -
- - - +