zengh
2021-09-17 049430b1619b44a21c0fae1c86c6e5bcb0b02f03
拦截其他用户查看页面
7 files modified
56 ■■■■ changed files
src/page/index/tags.vue 31 ●●●●● patch | view | raw | blame | history
src/page/index/top/top-menu.vue 4 ●●●● patch | view | raw | blame | history
src/router/views/index.js 11 ●●●●● patch | view | raw | blame | history
src/store/getters.js 1 ●●●● patch | view | raw | blame | history
src/store/modules/user.js 4 ●●●● patch | view | raw | blame | history
src/views/article/article.vue 3 ●●●●● patch | view | raw | blame | history
src/views/util/test.vue 2 ●●● patch | view | raw | blame | history
src/page/index/tags.vue
@@ -65,6 +65,35 @@
    },
    mounted() {
      this.setActive();
      this.tagList.forEach((item, index) => {
        if (item.label == "首页" && (this.userInfo.role_name == "policeAdmin" || this.userInfo.role_name == "administrator")){
          this.$store.commit("set_hideHome", false);
        }else if (item.label == "首页" && (this.userInfo.role_name == "操作员")) {
          this.tagList.splice(index, 1);
          this.$store.commit("set_hideHome", true);
          var d = this.$router.options.routes,
            path = "";
          for (var k in d) {
            if (d[k].peixun == true) {
              // console.log(d[k]);
              path = d[k].path;
            }
          }
          this.$router.push({ path: path });
        } else {
          this.tagList.splice(index, 1);
          this.$store.commit("set_hideHome", true);
          var d = this.$router.options.routes,
            path = "";
          for (var k in d) {
            if (d[k].kby == true) {
              // console.log(d[k]);
              path = d[k].path;
            }
          }
          this.$router.push({ path: path });
        }
      });
    },
    watch: {
      tag() {
@@ -75,7 +104,7 @@
      }
    },
    computed: {
      ...mapGetters(["tagWel", "tagList", "tag", "website"]),
      ...mapGetters(["tagWel", "tagList", "tag", "website", "userInfo"]),
      ...mapState({
        showTag: state => state.common.showTag
      }),
src/page/index/top/top-menu.vue
@@ -1,7 +1,7 @@
<template>
  <div class="top-menu">
    <el-menu :default-active="activeIndex" mode="horizontal" text-color="#333">
      <el-menu-item index="0" @click.native="openHome(homeItem)" key="0">
      <el-menu-item index="0" @click.native="openHome(homeItem)" key="0" v-if="!hideHome">
        <template slot="title">
          <i
            style="font-size: 20px !important"
@@ -117,7 +117,7 @@
    ...mapState({
      showMenu: (state) => state.dataL.showdataL,
    }),
    ...mapGetters(["tagCurrent", "menu"]),
    ...mapGetters(["tagCurrent", "menu", "hideHome"]),
  },
  methods: {
    openHome(itemHome) {
src/router/views/index.js
@@ -12,6 +12,15 @@
    },
    component: () =>
      import ( /* webpackChunkName: "views" */ '@/views/wel/home')
  }, {
    path: 'dashboard',
    name: '控制台',
    meta: {
      i18n: 'dashboard',
      menu: false,
    },
    component: () =>
      import( /* webpackChunkName: "views" */ '@/views/article/article')
  }]
},
@@ -55,6 +64,7 @@
  {
    path: '/test',
    component: Layout,
    kby:true,
    redirect: '/test/index',
    children: [{
      path: 'index',
@@ -313,6 +323,7 @@
  }, {
    path: '/article',
    component: Layout,
    peixun: true,
    redirect: '/article/index',
    children: [{
      path: 'index',
src/store/getters.js
@@ -19,6 +19,7 @@
  roles: state => state.user.roles,
  permission: state => state.user.permission,
  menu: state => state.user.menu,
  hideHome: state => state.user.hideHome,
  menuId: state => state.user.menuId,
  menuAll: state => state.user.menuAll,
  logsList: state => state.logs.logsList,
src/store/modules/user.js
@@ -43,6 +43,7 @@
    menuAll: getStore({name: 'menuAll'}) || [],
    token: getStore({name: 'token'}) || '',
    refreshToken: getStore({name: 'refreshToken'}) || '',
    hideHome: false,
  },
  actions: {
    //根据用户名登录
@@ -207,6 +208,9 @@
    },
  },
  mutations: {
    set_hideHome: (state, val) => {
      state.hideHome = val;
    },
    SET_TOKEN: (state, token) => {
      setToken(token);
      state.token = token;
src/views/article/article.vue
@@ -177,9 +177,6 @@
            {
              label: "发布时间",
              prop: "createTime",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              type: "date",
              format: "yyyy-MM-dd HH:mm:ss",
              valueFormat: "yyyy-MM-dd HH:mm:ss",
src/views/util/test.vue
@@ -1,6 +1,6 @@
<template>
  <div>
    <basic-container>测试页</basic-container>
    <basic-container></basic-container>
  </div>
</template>