diff --git a/src/App.tsx b/src/App.tsx index a07ed7a..d62cbee 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,7 +5,8 @@ import PayPage from './pages/PayPage.tsx' import PayResultPage from './pages/PayResultPage.tsx' import Twins from './pages/Twins.tsx' import PlaceholderPage from './components/PlaceholderPage.tsx' -import { getPackage } from './api/user.ts' +import { getConfig, getPackage } from './api/user.ts' +import { TEMP_TOKEN_STORAGE_KEY } from './utils/request.ts' // http://localhost:5173?token=c3f52a99-c519-427a-af05-364c5f3e59cc function App() { @@ -25,6 +26,12 @@ function App() { navigate('/twins', { replace: true }) } + const { data: config } = await getConfig() + + if (config.token) { + window.sessionStorage.setItem(TEMP_TOKEN_STORAGE_KEY, config.token) + } + const { data: packageInfo } = await getPackage() if (isMounted) { diff --git a/src/pages/Twins.tsx b/src/pages/Twins.tsx index 14236ee..213bcab 100644 --- a/src/pages/Twins.tsx +++ b/src/pages/Twins.tsx @@ -1,6 +1,5 @@ import { useEffect, useState } from 'react' -import { getConfig, getService } from '@/api/user' -import { TEMP_TOKEN_STORAGE_KEY } from '@/utils/request' +import { getService } from '@/api/user' type TwinsProps = { installUrl: string @@ -14,12 +13,6 @@ function Twins({ installUrl }: TwinsProps) { async function initTwinsConfig() { try { - const { data: config } = await getConfig() - - if (config.token) { - window.sessionStorage.setItem(TEMP_TOKEN_STORAGE_KEY, config.token) - } - const { data: service } = await getService() const nextServiceUrl = service['kf.address']