mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-15 07:31:19 +00:00

* refactor: permission role * refactor: permission type * fix: permission manage * fix: group owner cannot be deleted * chore: common per map * chore: openapi * chore: rename * fix: type error * chore: app chat log permission * chore: add initv4112
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import {
|
|
NullRoleVal,
|
|
CommonPerKeyEnum,
|
|
CommonRoleList,
|
|
CommonPerList,
|
|
CommonRolePerMap
|
|
} from '../constant';
|
|
import type { PermissionListType, PermissionValueType, RolePerMapType } from '../type';
|
|
import { type RoleListType } from '../type';
|
|
import { i18nT } from '../../../../web/i18n/utils';
|
|
import { sumPer } from '../utils';
|
|
|
|
export enum AppPermissionKeyEnum {
|
|
ReadChatLog = 'readChatLog'
|
|
}
|
|
|
|
export const AppPerList: PermissionListType<AppPermissionKeyEnum> = {
|
|
...CommonPerList,
|
|
readChatLog: 0b1000
|
|
};
|
|
|
|
export const AppRoleList: RoleListType<AppPermissionKeyEnum> = {
|
|
[CommonPerKeyEnum.read]: {
|
|
...CommonRoleList[CommonPerKeyEnum.read],
|
|
description: i18nT('app:permission.des.read')
|
|
},
|
|
[CommonPerKeyEnum.write]: {
|
|
...CommonRoleList[CommonPerKeyEnum.write],
|
|
description: i18nT('app:permission.des.write')
|
|
},
|
|
[CommonPerKeyEnum.manage]: {
|
|
...CommonRoleList[CommonPerKeyEnum.manage],
|
|
description: i18nT('app:permission.des.manage')
|
|
},
|
|
[AppPermissionKeyEnum.ReadChatLog]: {
|
|
value: 0b1000,
|
|
checkBoxType: 'multiple',
|
|
name: i18nT('app:permission.name.readChatLog'),
|
|
description: i18nT('app:permission.des.readChatLog')
|
|
}
|
|
};
|
|
|
|
export const AppRolePerMap: RolePerMapType = new Map([
|
|
...CommonRolePerMap,
|
|
[
|
|
AppRoleList[AppPermissionKeyEnum.ReadChatLog].value,
|
|
sumPer(
|
|
CommonPerList[CommonPerKeyEnum.read],
|
|
AppPerList[AppPermissionKeyEnum.ReadChatLog]
|
|
) as PermissionValueType
|
|
]
|
|
]);
|
|
|
|
export const AppDefaultRoleVal = NullRoleVal;
|
|
export const AppReadChatLogPerVal = AppPerList[AppPermissionKeyEnum.ReadChatLog];
|
|
export const AppReadChatLogRoleVal = AppRoleList[AppPermissionKeyEnum.ReadChatLog].value;
|