chore: watch api

This commit is contained in:
jialin
2024-06-28 17:14:34 +08:00
parent 871bca1916
commit cf0113e8d8
35 changed files with 1171 additions and 627 deletions
+6 -20
View File
@@ -9,11 +9,14 @@ let currentUserInfo: any = {};
// 全局初始化数据配置,用于 Layout 用户信息和权限初始化
// 更多信息见文档:https://umijs.org/docs/api/runtime-config#getinitialstate
export async function getInitialState() {
export async function getInitialState(): Promise<{
fetchUserInfo: () => Promise<Global.UserInfo>;
currentUser?: Global.UserInfo;
}> {
// 如果不是登录页面,执行
const { location } = history;
const fetchUserInfo = async () => {
const fetchUserInfo = async (): Promise<Global.UserInfo> => {
try {
const data = await queryCurrentUserState({
skipErrorHandler: true
@@ -22,7 +25,7 @@ export async function getInitialState() {
} catch (error) {
history.push(loginPath);
}
return undefined;
return {} as Global.UserInfo;
};
if (![loginPath].includes(location.pathname)) {
@@ -40,23 +43,6 @@ export async function getInitialState() {
};
}
// export const patchClientRoutes = async (params: { routes: any[] }) => {
// const { routes } = params;
// console.log('routes============999', routes);
// const data = await queryCurrentUserState({
// skipErrorHandler: true
// });
// routes.unshift({
// path: '/',
// element: data?.is_admin ? (
// <Navigate to="/dashboard" replace />
// ) : (
// <Navigate to="/playground" replace />
// )
// });
// };
export const request: RequestConfig = {
baseURL: ' /v1',
...requestConfig