Commit 61cd5dda by wangyalan-git

解决登录后跳转login自动跳转首页

parent 26ed68f6
......@@ -8224,6 +8224,11 @@
"set-blocking": "~2.0.0"
}
},
"nprogress": {
"version": "0.2.0",
"resolved": "https://registry.npm.taobao.org/nprogress/download/nprogress-0.2.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnprogress%2Fdownload%2Fnprogress-0.2.0.tgz",
"integrity": "sha1-y480xTIT2JVyP8urkH6UIq28r7E="
},
"nth-check": {
"version": "1.0.2",
"resolved": "https://registry.npm.taobao.org/nth-check/download/nth-check-1.0.2.tgz",
......
......@@ -13,6 +13,7 @@
"element-ui": "^2.13.2",
"js-cookie": "^2.2.1",
"moment": "^2.27.0",
"nprogress": "^0.2.0",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
......
No preview for this file type
......@@ -7,6 +7,7 @@ import ElementUI from 'element-ui'
import '@/assets/scss/common.scss'
import common from '@/utils/validate'
import moment from 'moment'
import '@/permission' // permission control
Vue.prototype.common = common
Vue.prototype.moment = moment
Vue.use(ElementUI)
......
import router from './router'
// import store from './store'
import NProgress from 'nprogress' // Progress 进度条
import 'nprogress/nprogress.css'// Progress 进度条样式
// import { Message } from 'element-ui'
import { getToken } from '@/utils/auth' // 验权
const whiteList = ['/login', '/forget'] // 不重定向白名单
router.beforeEach((to, from, next) => {
NProgress.start()
if (getToken()) {
if (to.path === '/login') {
next({ path: '/' })
NProgress.done()
} else {
next()
}
} else {
if (whiteList.indexOf(to.path) !== -1) {
next()
} else {
next('/login')
NProgress.done()
}
}
})
router.afterEach(() => {
NProgress.done() // 结束Progress
})
......@@ -8,7 +8,7 @@ import { getToken } from '@/utils/auth'
const service = axios.create({
// baseURL: process.env.BASE_API,
withCredentials: true,
baseURL: 'http://192.168.31.127:8401/mall-portal',
baseURL: 'http://192.168.31.116:8401/mall-portal',
// baseURL: 'http://hhg.api.jsonpro.cn:8201/mall-admin',
timeout: 60000 // 请求超时时间
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment