功能:同步小程序流程
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Purpose: MANAGE_MODULES supports permission.js by holding or executing the manage modules page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const MANAGE_MODULES = [
|
||||
{
|
||||
key: 'users',
|
||||
@@ -62,9 +66,29 @@ const MANAGE_MODULES = [
|
||||
path: '/pages/permissions/index',
|
||||
permissionCodes: ['permission:view'],
|
||||
requiresShopContext: false
|
||||
},
|
||||
{
|
||||
key: 'systemMessages',
|
||||
title: '系统消息',
|
||||
description: '发布消息、查看弹窗配置和业务跳转信息',
|
||||
path: '/pages/system-messages/index',
|
||||
permissionCodes: ['message:view'],
|
||||
requiresShopContext: false
|
||||
},
|
||||
{
|
||||
key: 'securityAudit',
|
||||
title: '审计日志',
|
||||
description: '查看高危操作的成功、失败原因与操作者',
|
||||
path: '/pages/security-audit/index',
|
||||
permissionCodes: ['security:audit:view'],
|
||||
requiresShopContext: false
|
||||
}
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: getPermissionCodes supports permission.js by holding or executing the get permission codes page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function getPermissionCodes(source) {
|
||||
const list = Array.isArray(source) ? source : []
|
||||
|
||||
@@ -78,6 +102,10 @@ function getPermissionCodes(source) {
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: hasPermission supports permission.js by holding or executing the has permission page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function hasPermission(source, permissionCode) {
|
||||
if (!permissionCode) {
|
||||
return true
|
||||
@@ -87,6 +115,10 @@ function hasPermission(source, permissionCode) {
|
||||
return codes.includes(permissionCode)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: hasAnyPermission supports permission.js by holding or executing the has any permission page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function hasAnyPermission(source, permissionCodes) {
|
||||
const codes = Array.isArray(permissionCodes) ? permissionCodes : []
|
||||
if (!codes.length) {
|
||||
@@ -96,6 +128,10 @@ function hasAnyPermission(source, permissionCodes) {
|
||||
return codes.some(code => hasPermission(source, code))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: hasAllPermissions supports permission.js by holding or executing the has all permissions page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function hasAllPermissions(source, permissionCodes) {
|
||||
const codes = Array.isArray(permissionCodes) ? permissionCodes : []
|
||||
if (!codes.length) {
|
||||
@@ -105,18 +141,34 @@ function hasAllPermissions(source, permissionCodes) {
|
||||
return codes.every(code => hasPermission(source, code))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isPlatformAdmin supports permission.js by holding or executing the is platform admin page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function isPlatformAdmin(userInfo) {
|
||||
return Number(userInfo && userInfo.type) === 4
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isShopManager supports permission.js by holding or executing the is shop manager page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function isShopManager(userInfo) {
|
||||
return Number(userInfo && userInfo.type) === 2
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isNailArtist supports permission.js by holding or executing the is nail artist page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function isNailArtist(userInfo) {
|
||||
return Number(userInfo && userInfo.type) === 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: getRoleLabel supports permission.js by holding or executing the get role label page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function getRoleLabel(type) {
|
||||
const value = Number(type)
|
||||
if (value === 4) {
|
||||
@@ -131,6 +183,10 @@ function getRoleLabel(type) {
|
||||
return '用户'
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: groupPermissionsByGroup supports permission.js by holding or executing the group permissions by group page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function groupPermissionsByGroup(permissions) {
|
||||
return (Array.isArray(permissions) ? permissions : []).reduce((result, item) => {
|
||||
const group = item && item.permissionGroup ? item.permissionGroup : '未分组'
|
||||
@@ -142,6 +198,10 @@ function groupPermissionsByGroup(permissions) {
|
||||
}, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: checkModuleAccess supports permission.js by holding or executing the check module access page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function checkModuleAccess(module, userInfo, permissionCodes, currentShop) {
|
||||
if (!hasAnyPermission(permissionCodes, module.permissionCodes)) {
|
||||
return {
|
||||
@@ -171,6 +231,10 @@ function checkModuleAccess(module, userInfo, permissionCodes, currentShop) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: getManageModules supports permission.js by holding or executing the get manage modules page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function getManageModules(userInfo, permissionCodes, currentShop) {
|
||||
return MANAGE_MODULES.map(module => {
|
||||
const access = checkModuleAccess(module, userInfo, permissionCodes, currentShop)
|
||||
|
||||
Reference in New Issue
Block a user