mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix: roleMode
This commit is contained in:
parent
0740fd646c
commit
a93620b1e8
@ -12,7 +12,7 @@ import { useACLRoleContext } from '../acl';
|
||||
import { ReturnTypeOfUseRequest, useAPIClient, useRequest } from '../api-client';
|
||||
import { useAppSpin } from '../application';
|
||||
import { useCompile } from '../schema-component';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useSystemSettings } from '../system-settings';
|
||||
|
||||
export const CurrentUserContext = createContext<ReturnTypeOfUseRequest & { roleMode?: { data: { roleMode } } }>(null);
|
||||
CurrentUserContext.displayName = 'CurrentUserContext';
|
||||
@ -39,8 +39,8 @@ export const useCurrentRoles = () => {
|
||||
};
|
||||
|
||||
export const useCurrentRoleMode = () => {
|
||||
const { roleMode } = useCurrentUserContext();
|
||||
return roleMode?.data;
|
||||
const ctx = useSystemSettings();
|
||||
return ctx?.data?.data?.roleMode;
|
||||
};
|
||||
|
||||
export const CurrentUserProvider = (props) => {
|
||||
@ -55,16 +55,10 @@ export const CurrentUserProvider = (props) => {
|
||||
.then((res) => res?.data),
|
||||
);
|
||||
|
||||
const { loading: roleModeLoading, data } = useRequest(() => api.resource('roles').getSystemRoleMode(), {
|
||||
onSuccess: (res) => {
|
||||
return res.data.data.roleMode;
|
||||
},
|
||||
});
|
||||
const { render } = useAppSpin();
|
||||
|
||||
if (result.loading || roleModeLoading) {
|
||||
if (result.loading) {
|
||||
return render();
|
||||
}
|
||||
result['roleMode'] = data?.['data'];
|
||||
return <CurrentUserContext.Provider value={result}>{props.children}</CurrentUserContext.Provider>;
|
||||
};
|
||||
|
@ -7,12 +7,11 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { Flex, message, Select, Space, theme, Tooltip } from 'antd';
|
||||
import { useACLTranslation } from './locale';
|
||||
import { useRequest } from 'ahooks';
|
||||
import { useAPIClient, useCurrentRoleMode } from '@nocobase/client';
|
||||
import { useRequest } from 'ahooks';
|
||||
import { Flex, message, Select, theme, Tooltip } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||
import { useACLTranslation } from './locale';
|
||||
|
||||
export const RoleModeSelect = () => {
|
||||
const { t } = useACLTranslation();
|
||||
|
Loading…
x
Reference in New Issue
Block a user