lixuliang
2024-11-22 e26e02fd97880a30b48a6fe086c1b3298903b970
se-ui/src/permission.js
@@ -16,7 +16,12 @@
    to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
    /* has token*/
    if (to.path === '/login') {
      next({ path: '/' })
      if (process.env.NODE_ENV == 'development') {
        window.location.href = 'http://localhost:8080/login'
      } else if (process.env.NODE_ENV == 'production') {
        window.location.href = window.location.origin + '/sso/login'
      }
      // next({ path: '/' })
      NProgress.done()
    } else if (whiteList.indexOf(to.path) !== -1) {
      next()
@@ -32,11 +37,17 @@
            next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
          })
        }).catch(err => {
            store.dispatch('LogOut').then(() => {
              Message.error(err)
              next({ path: '/' })
            })
          store.dispatch('LogOut').then(() => {
            Message.error(err)
            console.log(process.env.NODE_ENV);
            if (process.env.NODE_ENV == 'development') {
              window.location.href = 'http://localhost:8080/login'
            } else if (process.env.NODE_ENV == 'production') {
              window.location.href = window.location.origin + '/sso/login'
            }
            // next({ path: '/' })
          })
        })
      } else {
        next()
      }
@@ -47,7 +58,11 @@
      // 在免登录白名单,直接进入
      next()
    } else {
      next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页
      if (process.env.NODE_ENV == 'development') {
        window.location.href = 'http://localhost:8080/login'
      } else if (process.env.NODE_ENV == 'production') {
        window.location.href = window.location.origin + '/sso/login'
      }
      NProgress.done()
    }
  }