refactor(web): migrate anthropic quota notice storage (#36922)

Co-authored-by: lmlm <7487674+popsiclelmlm@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
This commit is contained in:
lmlm 2026-06-02 12:05:15 +08:00 committed by GitHub
parent e35d23c3cb
commit 1ff4d75084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View File

@ -5146,9 +5146,6 @@
} }
}, },
"web/context/provider-context-provider.tsx": { "web/context/provider-context-provider.tsx": {
"no-restricted-globals": {
"count": 2
},
"ts/no-explicit-any": { "ts/no-explicit-any": {
"count": 1 "count": 1
} }

View File

@ -15,6 +15,7 @@ import {
ModelTypeEnum, ModelTypeEnum,
} from '@/app/components/header/account-setting/model-provider-page/declarations' } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { ZENDESK_FIELD_IDS } from '@/config' import { ZENDESK_FIELD_IDS } from '@/config'
import { useLocalStorage } from '@/hooks/use-local-storage'
import { fetchCurrentPlanInfo } from '@/service/billing' import { fetchCurrentPlanInfo } from '@/service/billing'
import { import {
useModelListByType, useModelListByType,
@ -38,6 +39,8 @@ const unlimitedMemberInviteLimit: MemberInviteLimit = {
limit: 0, limit: 0,
} }
const ANTHROPIC_QUOTA_NOTICE_STORAGE_KEY = 'anthropic_quota_notice'
const resolveMemberInviteLimit = (data: Awaited<ReturnType<typeof fetchCurrentPlanInfo>>): MemberInviteLimit => { const resolveMemberInviteLimit = (data: Awaited<ReturnType<typeof fetchCurrentPlanInfo>>): MemberInviteLimit => {
if (!data) if (!data)
return unlimitedMemberInviteLimit return unlimitedMemberInviteLimit
@ -154,8 +157,14 @@ export const ProviderContextProvider = ({
// #endregion Zendesk conversation fields // #endregion Zendesk conversation fields
const { t } = useTranslation() const { t } = useTranslation()
const [anthropicQuotaNotice, setAnthropicQuotaNotice] = useLocalStorage<string>(
ANTHROPIC_QUOTA_NOTICE_STORAGE_KEY,
'false',
{ raw: true },
)
useEffect(() => { useEffect(() => {
if (localStorage.getItem('anthropic_quota_notice') === 'true') if (anthropicQuotaNotice === 'true')
return return
if (dayjs().isAfter(dayjs('2025-03-17'))) if (dayjs().isAfter(dayjs('2025-03-17')))
@ -166,14 +175,14 @@ export const ProviderContextProvider = ({
if (anthropic && anthropic.system_configuration.current_quota_type === CurrentSystemQuotaTypeEnum.trial) { if (anthropic && anthropic.system_configuration.current_quota_type === CurrentSystemQuotaTypeEnum.trial) {
const quota = anthropic.system_configuration.quota_configurations.find(item => item.quota_type === anthropic.system_configuration.current_quota_type) const quota = anthropic.system_configuration.quota_configurations.find(item => item.quota_type === anthropic.system_configuration.current_quota_type)
if (quota && quota.is_valid && quota.quota_used < quota.quota_limit) { if (quota && quota.is_valid && quota.quota_used < quota.quota_limit) {
localStorage.setItem('anthropic_quota_notice', 'true') setAnthropicQuotaNotice('true')
toast.info(t('provider.anthropicHosted.trialQuotaTip', { ns: 'common' }), { toast.info(t('provider.anthropicHosted.trialQuotaTip', { ns: 'common' }), {
timeout: 60000, timeout: 60000,
}) })
} }
} }
} }
}, [providersData, t]) }, [anthropicQuotaNotice, providersData, setAnthropicQuotaNotice, t])
return ( return (
<ProviderContext.Provider value={{ <ProviderContext.Provider value={{