田源
2024-04-01 79f117e8cfb90586753503582dfff2b999d6c436
取消登录鉴权注释代码
已修改4个文件
336 ■■■■ 文件已修改
Source/ProjectWeb/src/page/index/sidebar/sidebarItem.vue 214 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/page/login/userlogin.vue 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/router/axios.js 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/router/page/index.js 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/ProjectWeb/src/page/index/sidebar/sidebarItem.vue
@@ -2,146 +2,146 @@
  <div class="menu-wrapper">
    <template v-for="item in menu">
      <el-menu-item v-if="validatenull(item[childrenKey]) && vaildRoles(item)"
                    :index="item[pathKey]"
                    @click="open(item)"
                    :key="item[labelKey]"
                    :class="{'is-active':vaildActive(item)}">
                    :class="{'is-active':vaildActive(item)}"
                    :index="item[pathKey]"
                    @click="open(item)">
        <i :class="item[iconKey]"></i>
        <span slot="title"
              :alt="item[pathKey]">{{generateTitle(item)}}</span>
              :alt="item[pathKey]">{{ generateTitle(item) }}</span>
      </el-menu-item>
      <el-submenu v-else-if="!validatenull(item[childrenKey])&&vaildRoles(item)"
                  :index="item[pathKey]"
                  :key="item[labelKey]">
                  :key="item[labelKey]"
                  :index="item[pathKey]">
        <template slot="title">
          <i :class="item[iconKey]"></i>
          <span slot="title"
                :class="{'el-menu--display':collapse && first}">{{generateTitle(item)}}</span>
                :class="{'el-menu--display':collapse && first}">{{ generateTitle(item) }}</span>
        </template>
        <template v-for="(child,cindex) in item[childrenKey]">
          <el-menu-item :index="child[pathKey],cindex"
                        @click="open(child)"
          <el-menu-item v-if="validatenull(child[childrenKey])"
                        :key="child[labelKey]"
                        :class="{'is-active':vaildActive(child)}"
                        v-if="validatenull(child[childrenKey])"
                        :key="child[labelKey]">
                        :index="child[pathKey],cindex"
                        @click="open(child)">
            <i :class="child[iconKey]"></i>
            <span slot="title">{{generateTitle(child)}}</span>
            <span slot="title">{{ generateTitle(child) }}</span>
          </el-menu-item>
          <sidebar-item v-else
                        :menu="[child]"
                        :key="cindex"
                        :collapse="collapse"
                        :menu="[child]"
                        :props="props"
                        :screen="screen"
                        :collapse="collapse"></sidebar-item>
                        :screen="screen"></sidebar-item>
        </template>
      </el-submenu>
    </template>
  </div>
</template>
<script>
  import {mapGetters} from "vuex";
  import {isURL, validatenull} from "@/util/validate";
  import config from "./config.js";
import {mapGetters} from "vuex";
import {isURL, validatenull} from "@/util/validate";
import config from "./config.js";
  export default {
    name: "sidebarItem",
    data() {
      return {
        config: config
      };
export default {
  name: "sidebarItem",
  data() {
    return {
      config: config
    };
  },
  props: {
    menu: {
      type: Array
    },
    screen: {
      type: Number
    },
    first: {
      type: Boolean,
      default: false
    },
    props: {
      menu: {
        type: Array
      },
      screen: {
        type: Number
      },
      first: {
        type: Boolean,
        default: false
      },
      props: {
        type: Object,
        default: () => {
          return {};
        }
      },
      collapse: {
        type: Boolean
      type: Object,
      default: () => {
        return {};
      }
    },
    created() {
    collapse: {
      type: Boolean
    }
  },
  created() {
  },
  mounted() {
  },
  computed: {
    ...mapGetters(["roles"]),
    labelKey() {
      return this.props.label || this.config.propsDefault.label;
    },
    mounted() {
    pathKey() {
      return this.props.path || this.config.propsDefault.path;
    },
    computed: {
      ...mapGetters(["roles"]),
      labelKey() {
        return this.props.label || this.config.propsDefault.label;
      },
      pathKey() {
        return this.props.path || this.config.propsDefault.path;
      },
      iconKey() {
        return this.props.icon || this.config.propsDefault.icon;
      },
      childrenKey() {
        return this.props.children || this.config.propsDefault.children;
      },
      isOpenKey() {
        return this.props.isOpen || this.config.propsDefault.isOpen;
      },
      nowTagValue() {
        return this.$router.$avueRouter.getValue(this.$route);
    iconKey() {
      return this.props.icon || this.config.propsDefault.icon;
    },
    childrenKey() {
      return this.props.children || this.config.propsDefault.children;
    },
    isOpenKey() {
      return this.props.isOpen || this.config.propsDefault.isOpen;
    },
    nowTagValue() {
      return this.$router.$avueRouter.getValue(this.$route);
    }
  },
  methods: {
    generateTitle(item) {
      return this.$router.$avueRouter.generateTitle(
        item[this.labelKey],
        (item.meta || {}).i18n
      );
    },
    vaildActive(item) {
      if (this.validIsOpen(item)) {
        return false;
      }
      const groupFlag = (item["group"] || []).some(ele =>
        this.$route.path.includes(ele)
      );
      return this.nowTagValue === item[this.pathKey] || groupFlag;
    },
    vaildRoles(item) {
      item.meta = item.meta || {};
      return item.meta.roles ? item.meta.roles.includes(this.roles) : true;
    },
    validatenull(val) {
      return validatenull(val);
    },
    validIsOpen(item) {
      if (item[this.isOpenKey] === 2 && isURL(item[this.pathKey])) {
        return true;
      }
    },
    methods: {
      generateTitle(item) {
        return this.$router.$avueRouter.generateTitle(
          item[this.labelKey],
          (item.meta || {}).i18n
        );
      },
      vaildActive(item) {
        if (this.validIsOpen(item)) {
          return false;
        }
        const groupFlag = (item["group"] || []).some(ele =>
          this.$route.path.includes(ele)
        );
        return this.nowTagValue === item[this.pathKey] || groupFlag;
      },
      vaildRoles(item) {
        item.meta = item.meta || {};
        return item.meta.roles ? item.meta.roles.includes(this.roles) : true;
      },
      validatenull(val) {
        return validatenull(val);
      },
      validIsOpen(item) {
        if (item[this.isOpenKey] === 2 && isURL(item[this.pathKey])) {
          return true;
        }
      },
      open(item) {
        if (this.screen <= 1) this.$store.commit("SET_COLLAPSE");
        if (this.validIsOpen(item)) {
          window.open(item[this.pathKey]);
        } else {
          this.$router.$avueRouter.group = item.group;
          this.$router.$avueRouter.meta = item.meta;
          this.$router.push({
            path: this.$router.$avueRouter.getPath({
              name: item[this.labelKey],
              src: item[this.pathKey]
            }, item.meta),
            query: item.query
          });
        }
    open(item) {
      if (this.screen <= 1) this.$store.commit("SET_COLLAPSE");
      if (this.validIsOpen(item)) {
        window.open(item[this.pathKey]);
      } else {
        this.$router.$avueRouter.group = item.group;
        this.$router.$avueRouter.meta = item.meta;
        this.$router.push({
          path: this.$router.$avueRouter.getPath({
            name: item[this.labelKey],
            src: item[this.pathKey]
          }, item.meta),
          query: item.query
        });
      }
    }
  };
  }
};
</script>
<style lang="scss" scoped>
.el-menu-item:focus, .el-menu-item:hover {
Source/ProjectWeb/src/page/login/userlogin.vue
@@ -165,36 +165,36 @@
        done();
      },
      handleLogin() {
        // this.$router.push({path: this.tagWel.value});
        // this.$refs.loginForm.validate(valid => {
        //   if (valid) {
        //     const loading = this.$loading({
        //       lock: true,
        //       text: '登录中,请稍后。。。',
        //       spinner: "el-icon-loading"
        //     });
        //     this.$store.dispatch("LoginByUsername", this.loginForm).then(() => {
        //       if (this.website.switchMode) {
        //         const deptId = this.userInfo.dept_id;
        //         const roleId = this.userInfo.role_id;
        //         if (deptId.includes(",") || roleId.includes(",")) {
        //           this.loginForm.deptId = deptId;
        //           this.loginForm.roleId = roleId;
        //           this.userBox = true;
        //           this.$store.dispatch("LogOut").then(() => {
        //             loading.close();
        //           });
        //           return false;
        //         }
        //       }
        //       this.$router.push({path: this.tagWel.value});
        //       loading.close();
        //     }).catch(() => {
        //       loading.close();
        //
        //     });
        //   }
        // });
        this.$router.push({path: this.tagWel.value});
        this.$refs.loginForm.validate(valid => {
          if (valid) {
            const loading = this.$loading({
              lock: true,
              text: '登录中,请稍后。。。',
              spinner: "el-icon-loading"
            });
            this.$store.dispatch("LoginByUsername", this.loginForm).then(() => {
              if (this.website.switchMode) {
                const deptId = this.userInfo.dept_id;
                const roleId = this.userInfo.role_id;
                if (deptId.includes(",") || roleId.includes(",")) {
                  this.loginForm.deptId = deptId;
                  this.loginForm.roleId = roleId;
                  this.userBox = true;
                  this.$store.dispatch("LogOut").then(() => {
                    loading.close();
                  });
                  return false;
                }
              }
              this.$router.push({path: this.tagWel.value});
              loading.close();
            }).catch(() => {
              loading.close();
            });
          }
        });
      },
      getTenant() {
        let domain = getTopUrl();
Source/ProjectWeb/src/router/axios.js
@@ -55,30 +55,30 @@
}, error => {
  return Promise.reject(error)
});
// //http response 拦截
// axios.interceptors.response.use(res => {
//   //关闭 progress bar
//   NProgress.done();
//   //获取状态码
//   const status = res.data.code || res.status;
//   const statusWhiteList = website.statusWhiteList || [];
//   const message = res.data.msg || res.data.error_description || '未知错误';
//   //如果在白名单里则自行catch逻辑处理
//   if (statusWhiteList.includes(status)) return Promise.reject(res);
//   //如果是401则跳转到登录页面
//   if (status === 401) store.dispatch('FedLogOut').then(() => router.push({path: '/login'}));
//   // 如果请求为非200否者默认统一处理
//   if (status !== 200) {
//     Message({
//       message: message,
//       type: 'error'
//     });
//     return Promise.reject(new Error(message))
//   }
//   return res;
// }, error => {
//   NProgress.done();
//   return Promise.reject(new Error(error));
// });
//http response 拦截
axios.interceptors.response.use(res => {
  //关闭 progress bar
  NProgress.done();
  //获取状态码
  const status = res.data.code || res.status;
  const statusWhiteList = website.statusWhiteList || [];
  const message = res.data.msg || res.data.error_description || '未知错误';
  //如果在白名单里则自行catch逻辑处理
  if (statusWhiteList.includes(status)) return Promise.reject(res);
  //如果是401则跳转到登录页面
  if (status === 401) store.dispatch('FedLogOut').then(() => router.push({path: '/login'}));
  // 如果请求为非200否者默认统一处理
  if (status !== 200) {
    Message({
      message: message,
      type: 'error'
    });
    return Promise.reject(new Error(message))
  }
  return res;
}, error => {
  NProgress.done();
  return Promise.reject(new Error(error));
});
export default axios;
Source/ProjectWeb/src/router/page/index.js
@@ -77,18 +77,6 @@
    path: '*',
    redirect: '/404'
  },
  // {
  //   path: '/UIContentViewer',
  //   name: 'UI上下文',
  //   component: Layout,
  //   children: [
  //     {
  //       path: '',
  //       component: () => import("@/views/base/UIContentViewer"),
  //       props: true
  //     }
  //   ]
  // },
  {
    path: '/dynamic-form',
    name: '动态表格页面',