From c4d0466cec9c334d9f0e74fe44576364a019aed3 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期二, 16 七月 2024 09:20:46 +0800
Subject: [PATCH] 教师端隐藏管理员列表和教师列表
---
src/views/login/index.vue | 10 +++++-----
src/store/getters.js | 1 +
src/store/modules/router.js | 27 +++++++++++++++++++++++++--
3 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/src/store/getters.js b/src/store/getters.js
index 991023b..56e2c0e 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -4,6 +4,7 @@
visitedViews: state => state.tagsView.visitedViews,
cachedViews: state => state.tagsView.cachedViews,
userName: state => state.user.userName,
+ userInfo: state => state.user.userInfo,
routes: state => state.router.routes
}
export default getters
diff --git a/src/store/modules/router.js b/src/store/modules/router.js
index 747a715..6391a38 100644
--- a/src/store/modules/router.js
+++ b/src/store/modules/router.js
@@ -1,4 +1,5 @@
import { constantRoutes } from '@/router'
+import Cookies from 'js-cookie'
let state = {
routes: constantRoutes
@@ -7,11 +8,33 @@
const mutations = {
initRoutes: (state) => {
state.routes = constantRoutes
+ var adminUserInfoString = Cookies.get('adminUserInfo');
+ if (adminUserInfoString && JSON.parse(adminUserInfoString).role !== 3) {
+ state.routes.forEach(item => {
+ if (item.name === 'UserPage') {
+ item.children.forEach(child => {
+ if (child.name === 'UserTeacherPageList' || child.name === 'UserAdminPageList') {
+ child.hidden = true
+ }
+ })
+ }
+ })
+ }
+ if (adminUserInfoString && JSON.parse(adminUserInfoString).role === 3) {
+ state.routes.forEach(item => {
+ if (item.name === 'UserPage') {
+ item.children.forEach(child => {
+ if (child.name === 'UserTeacherPageList' || child.name === 'UserAdminPageList') {
+ child.hidden = false
+ }
+ })
+ }
+ })
+ }
}
}
-const actions = {
-}
+const actions = {}
export default {
namespaced: true,
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index a194d26..888e086 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -115,8 +115,8 @@
remember: false
},
loginRules: {
- userName: [{ required: true, trigger: 'blur'}],
- password: [{ required: true, trigger: 'blur'}]
+ userName: [{ required: true, trigger: 'blur' }],
+ password: [{ required: true, trigger: 'blur' }]
},
passwordType: 'password',
capsTooltip: false,
@@ -140,7 +140,7 @@
methods: {
updatePassword () {
if (this.updatePasswordForm.newPassword !== this.updatePasswordForm.confirmPassword) {
- this.$message.error("涓ゆ杈撳叆鐨勫瘑鐮佷笉涓�鑷�")
+ this.$message.error('涓ゆ杈撳叆鐨勫瘑鐮佷笉涓�鑷�')
return
}
UserApi.updatePassword(this.updatePasswordForm).then(res => {
@@ -189,6 +189,7 @@
}
if (result && result.code === 1) {
_this.setUserName(_this.loginForm.userName)
+ _this.setUserInfo(result.data)
_this.$router.push({ path: '/dashboard' })
} else {
_this.loading = false
@@ -205,7 +206,7 @@
}
})
},
- ...mapMutations('user', ['setUserName'])
+ ...mapMutations('user', ['setUserName', 'setUserInfo'])
}
}
</script>
@@ -333,4 +334,3 @@
}
}
</style>
-
--
Gitblit v1.8.0