diff --git a/packages/plugins/@nocobase/plugin-acl/src/client/SwitchRole.tsx b/packages/plugins/@nocobase/plugin-acl/src/client/SwitchRole.tsx index 1af19a04e2..433fe17f30 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/client/SwitchRole.tsx +++ b/packages/plugins/@nocobase/plugin-acl/src/client/SwitchRole.tsx @@ -16,6 +16,7 @@ import { SelectWithTitle, useCurrentRoleMode, } from '@nocobase/client'; +import { Divider } from 'antd'; export const SwitchRole = () => { const { t } = useTranslation(); @@ -36,7 +37,22 @@ export const SwitchRole = () => { label: 'title', value: 'name', }} - options={roles} + options={roles.reduce((acc, role) => { + acc.push(role); + if (role.name === '__union__') { + acc.push({ + name: 'divider', + title: , + disabled: true, + style: { + minHeight: 0, + height: 'auto', + padding: 0, + }, + }); + } + return acc; + }, [])} defaultValue={currentRole || roles[0].name} onChange={async (roleName) => { api.auth.setRole(roleName); diff --git a/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/setCurrentRole.ts b/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/setCurrentRole.ts index 47b6e7d599..49b8acaf14 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/setCurrentRole.ts +++ b/packages/plugins/@nocobase/plugin-acl/src/server/middlewares/setCurrentRole.ts @@ -58,10 +58,11 @@ export async function setCurrentRole(ctx: Context, next) { ctx.state.currentRoles = userRoles.map((role) => role.name); return next(); } else if (roleMode === SystemRoleMode.allowUseUnion) { - ctx.state.currentUser.roles = userRoles.concat({ + userRoles.unshift({ name: UNION_ROLE_KEY, title: ctx.t('Full permissions', { ns: 'acl' }), }); + ctx.state.currentUser.roles = userRoles; } if (currentRole === UNION_ROLE_KEY) {