zuozhengqing
2023-11-06 19aea05abd63fdc327afe19840f1e83dcb729b6d
退出动态跳转到登录页
1个文件已修改
24 ■■■■■ 已修改文件
src/components/layout/components/appHeader/index.vue 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layout/components/appHeader/index.vue
@@ -24,6 +24,27 @@
    return {}
  },
  methods: {
    environmentType(){
      let type
      if (location.href.includes('192.168.20.119')) {
          type = 'test'
      } else if (location.href.includes('192.168') || location.href.includes('localhost')) {
          type = 'dev'
      } else {
          type = 'prod'
      }
      return type
    },
    getApsPage(){
      // 首页部署在各个环境的端口
      const loginPathMap = {
          prod:`//${window.location.hostname}:9080`,
          test:`//192.168.20.119:9080`,
          // 想跳到本地启动的登录页的话需要把dev改成你本地项目路径
          dev: `//192.168.8.112:8082`
      }
      return loginPathMap[this.environmentType()]
    },
    handleCommand(command) {
      console.log(command)
      if (command === "logout") {
@@ -35,7 +56,8 @@
          type: 'warning'
        }).then(() => {
          Cookies.remove('token')
          window.location.href = 'http://localhost:8080/login'; //本地的智慧工厂-登录页
          // window.location.href = 'http://localhost:8080/login'; //本地的智慧工厂-登录页
          window.location.href = 'http:'+this.getApsPage()+'/login';
          this.$message({
            type: 'success',
            message: '注销成功!'