Ver código fonte

fix check version api (#520)

tags/0.3.7
zxhlyh 2 anos atrás
pai
commit
2b94545190
Nenhuma conta vinculada ao e-mail do autor do commit
1 arquivos alterados com 13 adições e 11 exclusões
  1. 13
    11
      web/context/app-context.tsx

+ 13
- 11
web/context/app-context.tsx Ver arquivo

useSelector: typeof useSelector useSelector: typeof useSelector
} }


const initialLangeniusVersionInfo = {
current_env: '',
current_version: '',
latest_version: '',
release_date: '',
release_notes: '',
version: '',
can_auto_update: false,
}

const AppContext = createContext<AppContextValue>({ const AppContext = createContext<AppContextValue>({
apps: [], apps: [],
mutateApps: () => { }, mutateApps: () => { },
}, },
mutateUserProfile: () => { }, mutateUserProfile: () => { },
pageContainerRef: createRef(), pageContainerRef: createRef(),
langeniusVersionInfo: {
current_env: '',
current_version: '',
latest_version: '',
release_date: '',
release_notes: '',
version: '',
can_auto_update: false,
},
langeniusVersionInfo: initialLangeniusVersionInfo,
useSelector, useSelector,
}) })


const { data: userProfileResponse, mutate: mutateUserProfile } = useSWR({ url: '/account/profile', params: {} }, fetchUserProfile) const { data: userProfileResponse, mutate: mutateUserProfile } = useSWR({ url: '/account/profile', params: {} }, fetchUserProfile)


const [userProfile, setUserProfile] = useState<UserProfileResponse>() const [userProfile, setUserProfile] = useState<UserProfileResponse>()
const [langeniusVersionInfo, setLangeniusVersionInfo] = useState<LangGeniusVersionResponse>()
const [langeniusVersionInfo, setLangeniusVersionInfo] = useState<LangGeniusVersionResponse>(initialLangeniusVersionInfo)
const updateUserProfileAndVersion = async () => { const updateUserProfileAndVersion = async () => {
if (userProfileResponse && !userProfileResponse.bodyUsed) { if (userProfileResponse && !userProfileResponse.bodyUsed) {
const result = await userProfileResponse.json() const result = await userProfileResponse.json()
updateUserProfileAndVersion() updateUserProfileAndVersion()
}, [userProfileResponse]) }, [userProfileResponse])


if (!appList || !userProfile || !langeniusVersionInfo)
if (!appList || !userProfile)
return <Loading type='app' /> return <Loading type='app' />


return ( return (

Carregando…
Cancelar
Salvar