-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
318 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
interface Permissions { | ||
[key: string]: { | ||
[key: string]: string; | ||
}; | ||
} | ||
|
||
const modulesPermissionFiles = require.context('./', true, /\.ts$/); | ||
/** | ||
* 根据接口路径生成接口权限码, eg: sys/user/add => sys:user:add | ||
* @param str 接口路径 | ||
* @returns {string} | ||
*/ | ||
export const generatePermCode = (str: string) => str.replace(/\//g, ':'); | ||
|
||
const filterDirs = ['/index.ts', './types.ts']; | ||
|
||
/** | ||
* @description 权限列表 | ||
*/ | ||
export const permissions: Permissions = modulesPermissionFiles | ||
.keys() | ||
.reduce((modules, modulePath) => { | ||
if (filterDirs.some((n) => modulePath.includes(n))) return modules; | ||
// set './app.js' => 'app' | ||
// set './sys/app.js' => 'sysApp' | ||
const moduleName = modulePath | ||
.replace(/^\.\/(.*)\.\w+$/, '$1') | ||
.replace(/[-_/][a-z]/gi, (s) => s.substring(1).toUpperCase()); | ||
const value = modulesPermissionFiles(modulePath).default; | ||
|
||
// pass sys/user/add => sys:user:add | ||
const permissionModule = Object.keys(value).reduce((obj, key) => { | ||
obj[key] = generatePermCode(value[key]); | ||
return obj; | ||
}, {}); | ||
|
||
modules[moduleName] = permissionModule; | ||
// console.log('permissions modules', modules); | ||
return modules; | ||
}, {}); | ||
console.log('permissions', permissions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { NetdiskMangePerms } from './manage'; | ||
|
||
export type NetdiskPermissionType = NetdiskMangePerms; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
export default { | ||
export const sysDept = { | ||
/** 获取部门列表 */ | ||
list: 'sys/dept/list', | ||
/** 移动部门 */ | ||
move: 'sys/dept/move', | ||
/** 更新部门 */ | ||
update: 'sys/dept/update', | ||
delete: 'sys/dept/delete', | ||
add: 'sys/dept/add', | ||
info: 'sys/dept/info', | ||
transfer: 'sys/dept/transfer', | ||
}; | ||
} as const; | ||
|
||
export const values = Object.values(sysDept); | ||
|
||
export type SysDeptPerms = typeof values[number]; | ||
|
||
export default sysDept; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { SysLogPerms } from './log'; | ||
import { SysDeptPerms } from './dept'; | ||
import { SysMenuPerms } from './menu'; | ||
import { SysOnlinePerms } from './online'; | ||
import { SysRolePerms } from './role'; | ||
import { SysTaskPerms } from './task'; | ||
import { SysUserPerms } from './user'; | ||
|
||
export type SysPermissionType = | ||
| SysLogPerms | ||
| SysDeptPerms | ||
| SysMenuPerms | ||
| SysOnlinePerms | ||
| SysRolePerms | ||
| SysTaskPerms | ||
| SysUserPerms; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
export default { | ||
export const sysLog = { | ||
req: 'sys/log/req/page', | ||
login: 'sys/log/login/page', | ||
task: 'sys/log/task/page', | ||
}; | ||
} as const; | ||
|
||
export const values = Object.values(sysLog); | ||
|
||
export type SysLogPerms = typeof values[number]; | ||
|
||
export default sysLog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
export default { | ||
export const sysMenu = { | ||
list: 'sys/menu/list', | ||
add: 'sys/menu/add', | ||
update: 'sys/menu/update', | ||
info: 'sys/menu/info', | ||
delete: 'sys/menu/delete', | ||
}; | ||
} as const; | ||
|
||
export const deptValues = Object.values(sysMenu); | ||
|
||
export type SysMenuPerms = typeof deptValues[number]; | ||
|
||
export default sysMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
export default { | ||
export const sysOnline = { | ||
list: 'sys/online/list', | ||
kick: 'sys/online/kick', | ||
}; | ||
} as const; | ||
|
||
export const values = Object.values(sysOnline); | ||
|
||
export type SysOnlinePerms = typeof values[number]; | ||
|
||
export default sysOnline; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
export default { | ||
export const sysRole = { | ||
list: 'sys/role/list', | ||
page: 'sys/role/page', | ||
add: 'sys/role/add', | ||
update: 'sys/role/update', | ||
delete: 'sys/role/delete', | ||
info: 'sys/role/info', | ||
}; | ||
} as const; | ||
|
||
export const values = Object.values(sysRole); | ||
|
||
export type SysRolePerms = typeof values[number]; | ||
|
||
export default sysRole; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.