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