| const searchParams = useSearchParams() | const searchParams = useSearchParams() | ||||
| const consoleToken = searchParams.get('console_token') | const consoleToken = searchParams.get('console_token') | ||||
| const consoleTokenFromLocalStorage = localStorage?.getItem('console_token') | const consoleTokenFromLocalStorage = localStorage?.getItem('console_token') | ||||
| const utm = { | |||||
| utm_source: searchParams.get('utm_source') || '', | |||||
| utm_medium: searchParams.get('utm_medium') || '', | |||||
| utm_campaign: searchParams.get('utm_campaign') || '', | |||||
| utm_content: searchParams.get('utm_content') || '', | |||||
| utm_term: searchParams.get('utm_term') || '', | |||||
| } | |||||
| localStorage?.setItem('utm', JSON.stringify(utm)) | |||||
| const [init, setInit] = useState(false) | const [init, setInit] = useState(false) | ||||
| useEffect(() => { | useEffect(() => { | ||||
| if (consoleToken) { | if (consoleToken) { | ||||
| localStorage?.setItem('console_token', consoleToken!) | localStorage?.setItem('console_token', consoleToken!) | ||||
| router.replace('/apps', { forceOptimisticNavigation: false }) | |||||
| router.replace('/apps', { forceOptimisticNavigation: false } as any) | |||||
| } | } | ||||
| setInit(true) | setInit(true) | ||||
| }, []) | }, []) |
| fetchModelList, | fetchModelList, | ||||
| fetchModelProviders, | fetchModelProviders, | ||||
| fetchSupportRetrievalMethods, | fetchSupportRetrievalMethods, | ||||
| operationUtm, | |||||
| } from '@/service/common' | } from '@/service/common' | ||||
| import { | import { | ||||
| ModelFeatureEnum, | ModelFeatureEnum, | ||||
| const [isFetchedPlan, setIsFetchedPlan] = useState(false) | const [isFetchedPlan, setIsFetchedPlan] = useState(false) | ||||
| const [enableBilling, setEnableBilling] = useState(true) | const [enableBilling, setEnableBilling] = useState(true) | ||||
| const [enableReplaceWebAppLogo, setEnableReplaceWebAppLogo] = useState(false) | const [enableReplaceWebAppLogo, setEnableReplaceWebAppLogo] = useState(false) | ||||
| const handleOperateUtm = () => { | |||||
| let utm | |||||
| try { | |||||
| utm = JSON.parse(localStorage?.getItem('utm') || '{}') | |||||
| } | |||||
| catch (e) { | |||||
| utm = { | |||||
| utm_source: '', | |||||
| utm_medium: '', | |||||
| utm_campaign: '', | |||||
| utm_content: '', | |||||
| utm_term: '', | |||||
| } | |||||
| } | |||||
| operationUtm({ url: '/operation/utm', body: utm }) | |||||
| } | |||||
| useEffect(() => { | useEffect(() => { | ||||
| (async () => { | (async () => { | ||||
| const data = await fetchCurrentPlanInfo() | const data = await fetchCurrentPlanInfo() | ||||
| setEnableReplaceWebAppLogo(data.can_replace_logo) | setEnableReplaceWebAppLogo(data.can_replace_logo) | ||||
| if (enabled) { | if (enabled) { | ||||
| setPlan(parseCurrentPlan(data)) | setPlan(parseCurrentPlan(data)) | ||||
| // setPlan(parseCurrentPlan({ | |||||
| // ...data, | |||||
| // annotation_quota_limit: { | |||||
| // ...data.annotation_quota_limit, | |||||
| // limit: 10, | |||||
| // }, | |||||
| // })) | |||||
| handleOperateUtm() | |||||
| setIsFetchedPlan(true) | setIsFetchedPlan(true) | ||||
| } | } | ||||
| })() | })() |
| text: string | text: string | ||||
| } | } | ||||
| ) => Promise<ModerateResponse> | ) => Promise<ModerateResponse> | ||||
| export type Utm = { | |||||
| utm_source?: string | |||||
| utm_medium?: string | |||||
| utm_campaign?: string | |||||
| utm_term?: string | |||||
| utm_content?: string | |||||
| } |
| ProviderAzureToken, | ProviderAzureToken, | ||||
| SetupStatusResponse, | SetupStatusResponse, | ||||
| UserProfileOriginResponse, | UserProfileOriginResponse, | ||||
| Utm, | |||||
| } from '@/models/common' | } from '@/models/common' | ||||
| import type { | import type { | ||||
| UpdateOpenAIKeyResponse, | UpdateOpenAIKeyResponse, | ||||
| export const fetchSupportRetrievalMethods: Fetcher<RetrievalMethodsRes, string> = (url) => { | export const fetchSupportRetrievalMethods: Fetcher<RetrievalMethodsRes, string> = (url) => { | ||||
| return get<RetrievalMethodsRes>(url) | return get<RetrievalMethodsRes>(url) | ||||
| } | } | ||||
| export const operationUtm: Fetcher<CommonResponse, { url: string; body: Utm }> = ({ url, body }) => { | |||||
| return post(url, { body }) as Promise<CommonResponse> | |||||
| } |