mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
fix(client): continue rendering the page after the authentication check is completed (#6020)
This commit is contained in:
parent
a9d30fe330
commit
5f0bceb261
@ -11,7 +11,7 @@ import React, { createContext, useContext, useMemo } from 'react';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
import { useACLRoleContext } from '../acl';
|
||||
import { ReturnTypeOfUseRequest, useRequest } from '../api-client';
|
||||
import { useLocationNoUpdate } from '../application';
|
||||
import { useAppSpin, useLocationNoUpdate } from '../application';
|
||||
import { useCompile } from '../schema-component';
|
||||
|
||||
export const CurrentUserContext = createContext<ReturnTypeOfUseRequest>(null);
|
||||
@ -39,10 +39,15 @@ export const useCurrentRoles = () => {
|
||||
};
|
||||
|
||||
export const CurrentUserProvider = (props) => {
|
||||
const { render } = useAppSpin();
|
||||
const result = useRequest<any>({
|
||||
url: 'auth:check',
|
||||
});
|
||||
|
||||
if (result.loading) {
|
||||
return render();
|
||||
}
|
||||
|
||||
return <CurrentUserContext.Provider value={result}>{props.children}</CurrentUserContext.Provider>;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user