From e3a28ebf252b309f2c27c1c3597845d7dde0b8f9 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Thu, 27 Jun 2024 13:49:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E5=A2=9E=E5=8A=A0=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E8=A7=92=E8=89=B2=E4=B8=8D=E5=90=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/RBAC 权限.sql | 10 ++++++++++ src/stores/Auth.js | 15 +++++++++++++++ src/views/Login.jsx | 7 +++---- src/views/account/Management.jsx | 6 +++--- src/views/account/RoleList.jsx | 1 + 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/doc/RBAC 权限.sql b/doc/RBAC 权限.sql index b463af5..3118103 100644 --- a/doc/RBAC 权限.sql +++ b/doc/RBAC 权限.sql @@ -74,6 +74,16 @@ VALUES ('审核价格', '/products/offer/audit', 'products') INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category]) VALUES ('录入价格', '/products/offer/put', 'products') +-- 默认页面 +INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category]) +VALUES ('最新计划', 'route=/reservation/newest', 'page') +INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category]) +VALUES ('机票订票', 'route=/airticket', 'page') +INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category]) +VALUES ('产品管理(客服)', 'route=/products', 'page') +INSERT INTO [dbo].[auth_resource] ([res_name] ,[res_pattern], [res_category]) +VALUES ('产品管理(供应商)', 'route=/products?from', 'page') + INSERT INTO [dbo].[auth_permission] ([role_id] ,[res_id]) VALUES (1, 1) INSERT INTO [dbo].[auth_permission] ([role_id] ,[res_id]) diff --git a/src/stores/Auth.js b/src/stores/Auth.js index 8374151..41b8899 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -60,6 +60,8 @@ const useAuthStore = create(obervseLifecycle((set, get) => ({ loginStatus: 0, + defaltRoute: '', + permissionList: [], isPermitted: (perm) => { @@ -98,13 +100,26 @@ const useAuthStore = create(obervseLifecycle((set, get) => ({ setStorage(KEY_USER_ID, userDetail.LMI_SN) setStorage(KEY_TRAVEL_AGENCY_ID, userDetail.LMI_VEI_SN) appendRequestParams('token', loginToken) + appendRequestParams('lmi_sn', userDetail.LMI_SN) // loadPageSpy(`${json.Result.VName}-${json.Result.LoginName}`) startTokenInterval() }, loadUserPermission: async(userId) => { + let deaultPage = '/' const permissionResult = await fetchPermissionListByUserId(userId) + const pageList = permissionResult.filter(p => { + return p.res_category === 'page' + }) + if (pageList.length > 0) { + const resPattern = pageList[0].res_pattern + const splitResult = resPattern.split('=') + if (splitResult.length > 1) + deaultPage = splitResult[1] + } + set(() => ({ + defaultRoute: deaultPage, permissionList: permissionResult.map(p => p.res_pattern) })) }, diff --git a/src/views/Login.jsx b/src/views/Login.jsx index f9c3008..a994d2d 100644 --- a/src/views/Login.jsx +++ b/src/views/Login.jsx @@ -6,9 +6,8 @@ import useAuthStore from '@/stores/Auth' import useNoticeStore from '@/stores/Notice' function Login() { - const [validateUserPassword, loginStatus] = - useAuthStore((state) => [state.validateUserPassword, state.loginStatus]) - const getBulletinUnReadCount = useNoticeStore((state) => state.getBulletinUnReadCount) + const [validateUserPassword, loginStatus, defaultRoute] = + useAuthStore((state) => [state.validateUserPassword, state.loginStatus, state.defaultRoute]) const { t, i18n } = useTranslation() const { notification } = App.useApp() @@ -17,7 +16,7 @@ function Login() { useEffect (() => { if (loginStatus === 302) { - navigate('/') + navigate(defaultRoute) } }, [loginStatus]) diff --git a/src/views/account/Management.jsx b/src/views/account/Management.jsx index 5496997..9fd988c 100644 --- a/src/views/account/Management.jsx +++ b/src/views/account/Management.jsx @@ -185,7 +185,7 @@ function Management() { } const showResetPasswordConfirm = (account) => { - const randomPassword = account.username + (Math.floor(Math.random() * 900) + 100) + const randomPassword = account.username + '@' + (Math.floor(Math.random() * 900) + 100) modal.confirm({ title: 'Do you want to reset password?', icon: , @@ -194,8 +194,8 @@ function Management() { resetAccountPassword(account.userId, randomPassword) .then(() => { notification.info({ - message: '新密码:' + randomPassword, - description: `请复制密码给 [${account.realname}]`, + message: `请复制新密码给 [${account.realname}]`, + description: '新密码:' + randomPassword, placement: 'top', duration: 60, }) diff --git a/src/views/account/RoleList.jsx b/src/views/account/RoleList.jsx index 71909f1..463ba60 100644 --- a/src/views/account/RoleList.jsx +++ b/src/views/account/RoleList.jsx @@ -69,6 +69,7 @@ function RoleList() { ['domestic', '国内供应商'], ['air-ticket', '机票供应商'], ['products', '产品价格'], + ['page', '默认页面'], ]); const permissionTree = []