From c41f0e668e1fa17f0cda2b5a3f2cc8e40b66e4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E7=8F=91?= Date: Thu, 28 Aug 2025 18:19:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86permission=E5=AF=B9?= =?UTF-8?q?=E5=B7=A6=E4=BE=A7=E8=8F=9C=E5=8D=95=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .umirc.ts | 13 +++++++------ src/access.ts | 23 ++++++++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.umirc.ts b/.umirc.ts index b2c4aa7..8abb35a 100644 --- a/.umirc.ts +++ b/.umirc.ts @@ -26,7 +26,7 @@ export default defineConfig({ { name: '组织架构', path: '/organiza', - access: 'canSeeSuper', + access: 'canSeeOrganiza', routes: [ { name: '用户管理', @@ -38,6 +38,7 @@ export default defineConfig({ { name: '商品管理', path: '/product', + access: 'canSeeProduct', routes: [ { name: '商品分类', @@ -69,6 +70,7 @@ export default defineConfig({ { name: '库存管理', path: '/stock', + access: 'canSeeStock', routes: [ { name: '库存列表', @@ -100,7 +102,7 @@ export default defineConfig({ { name: '订单管理', path: '/order', - access: 'canSeeAdmin', + access: 'canSeeOrder', routes: [ { name: '订单列表', @@ -117,6 +119,7 @@ export default defineConfig({ { name: '客户管理', path: '/customer', + access: 'canSeeCustomer', routes: [ { name: '客户列表', @@ -128,6 +131,7 @@ export default defineConfig({ { name: '物流管理', path: '/logistics', + access: 'canSeeLogistics', routes: [ { name: '服务商', @@ -149,30 +153,27 @@ export default defineConfig({ { name: '数据统计', path: '/statistics', + access: 'canSeeStatistics', routes: [ { name: '销售统计', path: '/statistics/sales', component: './Statistics/Sales', - access: 'canSeeSuper', }, { name: '订单统计', path: '/statistics/order', component: './Statistics/Order', - access: 'canSeeSuper', }, { name: '订单来源', path: '/statistics/orderSource', component: './Statistics/OrderSource', - access: 'canSeeSuper', }, { name: '客户统计', path: '/statistics/customer', component: './Statistics/Customer', - access: 'canSeeSuper', }, { name: '库存预测', diff --git a/src/access.ts b/src/access.ts index fbe171f..35a8b86 100644 --- a/src/access.ts +++ b/src/access.ts @@ -1,9 +1,22 @@ export default (initialState: any) => { - const canSeeSuper = initialState?.user?.isSuper; - const canSeeAdmin = - initialState?.user?.isSuper || initialState?.user?.isAdmin; + const isSuper = initialState?.user?.isSuper ?? false; + const isAdmin = initialState?.user?.Admin ?? false; + const canSeeOrganiza = (isSuper || isAdmin) || (initialState?.user?.permissions?.includes('organiza') ?? false); + const canSeeProduct = (isSuper || isAdmin) || (initialState?.user?.permissions?.includes('product') ?? false); + const canSeeStock = (isSuper || isAdmin) || (initialState?.user?.permissions?.includes('stock') ?? false); + const canSeeOrder = (isSuper || isAdmin) || + ((initialState?.user?.permissions?.includes('order') ?? false) || (initialState?.user?.permissions?.includes('order-10-days') ?? false)); + const canSeeCustomer = (isSuper || isAdmin) || (initialState?.user?.permissions?.includes('customer') ?? false); + const canSeeLogistics = (isSuper || isAdmin) || (initialState?.user?.permissions?.includes('logistics') ?? false); + const canSeeStatistics = (isSuper || isAdmin) || (initialState?.user?.permissions?.includes('statistics') ?? false); + return { - canSeeSuper, - canSeeAdmin, + canSeeOrganiza, + canSeeProduct, + canSeeStock, + canSeeOrder, + canSeeCustomer, + canSeeLogistics, + canSeeStatistics, }; };