diff --git a/src/stores/Auth.js b/src/stores/Auth.js
index fe0900e..d2371d7 100644
--- a/src/stores/Auth.js
+++ b/src/stores/Auth.js
@@ -50,6 +50,9 @@ const useAuthStore = create((set, get) => ({
},
isPermitted: (perm) => {
+ // 测试权限使用:
+ // if (perm === '/account/management') return false
+ // if (perm === '/account/role/new') return false
return true
// 以上是 Hardcode 判断
// 以下是权限列表从数据库读取后使用的方法
diff --git a/src/views/App.jsx b/src/views/App.jsx
index 779993c..607dfe3 100644
--- a/src/views/App.jsx
+++ b/src/views/App.jsx
@@ -17,6 +17,8 @@ import useNoticeStore from '@/stores/Notice';
import useAuthStore from '@/stores/Auth'
import { usingStorage } from '@/hooks/usingStorage'
+import { PERM_ACCOUNT_MANAGEMENT, PERM_ROLE_NEW, PERM_OVERSEA, PERM_AIR_TICKET } from '@/config'
+
const { Header, Content, Footer } = Layout;
const { Title } = Typography;
@@ -25,8 +27,8 @@ function App() {
const [password, setPassword] = useState('')
- const [validateUserPassword, tokenTimeout] = useAuthStore(
- (state) => [state.validateUserPassword, state.tokenTimeout])
+ const [validateUserPassword, tokenTimeout, isPermitted] = useAuthStore(
+ (state) => [state.validateUserPassword, state.tokenTimeout, state.isPermitted])
const { loginToken, userDetail } = usingStorage()
@@ -120,11 +122,11 @@ function App() {
mode='horizontal'
selectedKeys={[defaultPath]}
items={[
- { key: 'reservation', label: {t('menu.Reservation')} },
- { key: 'invoice', label: {t('menu.Invoice')} },
- { key: 'feedback', label: {t('menu.Feedback')} },
- { key: 'report', label: {t('menu.Report')} },
- { key: 'airticket', label: {t('menu.Airticket')} },
+ isPermitted(PERM_OVERSEA) ? { key: 'reservation', label: {t('menu.Reservation')} } : null,
+ isPermitted(PERM_OVERSEA) ? { key: 'invoice', label: {t('menu.Invoice')} } : null,
+ isPermitted(PERM_OVERSEA) ? { key: 'feedback', label: {t('menu.Feedback')} } : null,
+ isPermitted(PERM_OVERSEA) ? { key: 'report', label: {t('menu.Report')} } : null,
+ isPermitted(PERM_AIR_TICKET) ? { key: 'airticket', label: {t('menu.Airticket')} } : null,
{
key: 'notice',
label: (
@@ -148,8 +150,8 @@ function App() {
items: [...[
{ label: {t('ChangePassword')}, key: '0' },
{ label: {t('Profile')}, key: '1' },
- { label: {t('account:management.tile')}, key: '3' },
- { label: {t('account:management.roleList')}, key: '4' },
+ isPermitted(PERM_ACCOUNT_MANAGEMENT) ? { label: {t('account:management.tile')}, key: '3' } : null,
+ isPermitted(PERM_ROLE_NEW) ? { label: {t('account:management.roleList')}, key: '4' } : null,
{ type: 'divider' },
{ label: {t('Logout')}, key: '99' },
],