浏览代码

优化

wulanhaote
liuminjian 4 年前
父节点
当前提交
55c739999c
共有 2 个文件被更改,包括 19 次插入13 次删除
  1. +7
    -2
      src/permission.js
  2. +12
    -11
      src/utils/request.js

+ 7
- 2
src/permission.js 查看文件

@@ -27,7 +27,6 @@ const whiteList = [
'/policyDetail',
'/attestationDetail',
'/noticeDetail',
'/homestead/index',
'/homestead/login',


@@ -69,7 +68,13 @@ router.beforeEach((to, from, next) => {
// 在免登录白名单,直接进入
next()
} else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
if ('/homestead/index'.indexOf(to.path) !== -1) {
next(`/homestead/login?redirect=${to.fullPath}`)
} else {
next(`/login?redirect=${to.fullPath}`)
}

// // 否则全部重定向到登录页
//next('/index');
NProgress.done()
}


+ 12
- 11
src/utils/request.js 查看文件

@@ -61,18 +61,19 @@ service.interceptors.response.use(res => {
// 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) {
console.log(this.$route.path)

Dialog.confirm({
title: '系统提示',
message: '登录状态已过期,您可以继续留在该页面,或者重新登录',
confirmButtonText: '重新登录',
cancelButtonText: '取消'
})
.then(() => {
store.dispatch('LogOut').then(() => {
location.href = '/index';
})
})
// Dialog.confirm({
// title: '系统提示',
// message: '登录状态已过期,您可以继续留在该页面,或者重新登录',
// confirmButtonText: '重新登录',
// cancelButtonText: '取消'
// })
// .then(() => {
// store.dispatch('LogOut').then(() => {
// location.href = '/index';
// })
// })
} else if (code === 500) {
Dialog.alert({ type: 'warning', message: msg });
return Promise.reject(new Error(msg))


正在加载...
取消
保存