diff --git a/web/.umirc.ts b/web/.umirc.ts index 4ecbc3c52bf9ee80953604a39536a7f8cabb35fb..6c72be6c7fb0e5714171efdcd10c4871ddf50a63 100644 --- a/web/.umirc.ts +++ b/web/.umirc.ts @@ -21,6 +21,7 @@ export default defineConfig({ hack: `true; @import "~@/less/index.less";`, }, }, + devtool: 'source-map', proxy: { '/v1': { target: 'http://123.60.95.134:9380/', diff --git a/web/src/hooks/authHook.ts b/web/src/hooks/authHook.ts index 75b2d26f46c7a3509a2bd46cb05c6e94bd7a70aa..d4bf85fc1b2aff319faefa3d8f6fd0e66492610c 100644 --- a/web/src/hooks/authHook.ts +++ b/web/src/hooks/authHook.ts @@ -1,6 +1,7 @@ import authorizationUtil from '@/utils/authorizationUtil'; import { message } from 'antd'; import { useEffect, useMemo, useState } from 'react'; +import { Nullable } from 'typings'; import { useNavigate, useSearchParams } from 'umi'; export const useLoginWithGithub = () => { @@ -32,10 +33,10 @@ export const useLoginWithGithub = () => { export const useAuth = () => { const auth = useLoginWithGithub(); - const [isLogin, setIsLogin] = useState(true); + const [isLogin, setIsLogin] = useState<Nullable<boolean>>(null); useEffect(() => { - setIsLogin(!!auth || !!authorizationUtil.getAuthorization()); + setIsLogin(!!authorizationUtil.getAuthorization() || !!auth); }, [auth]); return { isLogin }; diff --git a/web/src/wrappers/auth.tsx b/web/src/wrappers/auth.tsx index 2f0b80376080355bcf079f631ca305916cb6909d..f12ebaff1651486971588c2a43a36c4eb4a32732 100644 --- a/web/src/wrappers/auth.tsx +++ b/web/src/wrappers/auth.tsx @@ -3,9 +3,11 @@ import { Navigate, Outlet } from 'umi'; export default () => { const { isLogin } = useAuth(); - if (isLogin) { + if (isLogin === true) { return <Outlet />; - } else { + } else if (isLogin === false) { return <Navigate to="/login" />; } + + return <></>; };