|
|
|
|
@ -34,6 +34,7 @@ const ProviderContext = createContext<{
|
|
|
|
|
}
|
|
|
|
|
isFetchedPlan: boolean
|
|
|
|
|
enableBilling: boolean
|
|
|
|
|
onPlanInfoChanged: () => void
|
|
|
|
|
enableReplaceWebAppLogo: boolean
|
|
|
|
|
}>({
|
|
|
|
|
modelProviders: [],
|
|
|
|
|
@ -58,6 +59,7 @@ const ProviderContext = createContext<{
|
|
|
|
|
},
|
|
|
|
|
isFetchedPlan: false,
|
|
|
|
|
enableBilling: false,
|
|
|
|
|
onPlanInfoChanged: () => { },
|
|
|
|
|
enableReplaceWebAppLogo: false,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@ -98,7 +100,6 @@ export const ProviderContextProvider = ({
|
|
|
|
|
const [isFetchedPlan, setIsFetchedPlan] = useState(false)
|
|
|
|
|
const [enableBilling, setEnableBilling] = useState(true)
|
|
|
|
|
const [enableReplaceWebAppLogo, setEnableReplaceWebAppLogo] = useState(false)
|
|
|
|
|
|
|
|
|
|
const handleOperateUtm = () => {
|
|
|
|
|
let utm
|
|
|
|
|
try {
|
|
|
|
|
@ -116,8 +117,7 @@ export const ProviderContextProvider = ({
|
|
|
|
|
if (utm.utm_source || utm.utm_medium || utm.utm_campaign || utm.utm_content || utm.utm_term)
|
|
|
|
|
operationUtm({ url: '/operation/utm', body: utm })
|
|
|
|
|
}
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
(async () => {
|
|
|
|
|
const fetchPlan = async () => {
|
|
|
|
|
const data = await fetchCurrentPlanInfo()
|
|
|
|
|
const enabled = data.billing.enabled
|
|
|
|
|
setEnableBilling(enabled)
|
|
|
|
|
@ -127,7 +127,9 @@ export const ProviderContextProvider = ({
|
|
|
|
|
handleOperateUtm()
|
|
|
|
|
setIsFetchedPlan(true)
|
|
|
|
|
}
|
|
|
|
|
})()
|
|
|
|
|
}
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
fetchPlan()
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
@ -140,6 +142,7 @@ export const ProviderContextProvider = ({
|
|
|
|
|
plan,
|
|
|
|
|
isFetchedPlan,
|
|
|
|
|
enableBilling,
|
|
|
|
|
onPlanInfoChanged: fetchPlan,
|
|
|
|
|
enableReplaceWebAppLogo,
|
|
|
|
|
}}>
|
|
|
|
|
{children}
|
|
|
|
|
|