feat: new ui

This commit is contained in:
archer
2023-05-04 23:30:59 +08:00
parent 4d043e0e46
commit 014fb504a4
133 changed files with 2426 additions and 1696 deletions

View File

@@ -2,7 +2,6 @@ import React from 'react';
import { useRouter } from 'next/router';
import { useToast } from '@chakra-ui/react';
import { useUserStore } from '@/store/user';
import { useGlobalStore } from '@/store/global';
import { useQuery } from '@tanstack/react-query';
const unAuthPage: { [key: string]: boolean } = {
@@ -19,15 +18,13 @@ const Auth = ({ children }: { children: JSX.Element }) => {
status: 'warning'
});
const { userInfo, initUserInfo } = useUserStore();
const { setLoading } = useGlobalStore();
useQuery(
[router.pathname, userInfo],
[router.pathname],
() => {
if (unAuthPage[router.pathname] === true || userInfo) {
return setLoading(false);
return null;
} else {
setLoading(true);
return initUserInfo();
}
},
@@ -38,9 +35,6 @@ const Auth = ({ children }: { children: JSX.Element }) => {
`/login?lastRoute=${encodeURIComponent(location.pathname + location.search)}`
);
toast();
},
onSettled() {
setLoading(false);
}
}
);