fuliqi
2024-07-16 c4d0466cec9c334d9f0e74fe44576364a019aed3
教师端隐藏管理员列表和教师列表
3个文件已修改
38 ■■■■ 已修改文件
src/store/getters.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/router.js 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/index.vue 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
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,
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>