|
|
@ -5,7 +5,7 @@ import { constantRouterMap } from './router.config.js' |
|
|
|
import { checkWxmpRegister, login } from '@/api/user' |
|
|
|
import { title } from '@/config' |
|
|
|
|
|
|
|
const whiteList = ['/login'] |
|
|
|
const whiteList = ['/login', '/register', '/errorPage'] |
|
|
|
const originalPush = Router.prototype.push |
|
|
|
Router.prototype.push = function push(location, onResolve, onReject) { |
|
|
|
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject) |
|
|
@ -54,10 +54,16 @@ router.beforeEach((to, from, next) => { |
|
|
|
if (urlParams.appId) { |
|
|
|
store.commit('SET_APP_ID', urlParams.appId) |
|
|
|
localStorage.setItem('appId', urlParams.appId) |
|
|
|
if (localStorage.getItem('appId') && urlParams.appId !== localStorage.getItem('appId')) { |
|
|
|
localStorage.removeItem('token') |
|
|
|
location.reload() |
|
|
|
} |
|
|
|
} else { |
|
|
|
store.commit('SET_APP_ID', localStorage.getItem('appId')) |
|
|
|
} |
|
|
|
console.log(store.state.app.appId, 'store.state.app.appId') |
|
|
|
if (!localStorage.getItem('appId') && to.path !== '/errorPage') { |
|
|
|
next('/errorPage') |
|
|
|
} else { |
|
|
|
if (to.params.type) { |
|
|
|
document.title = to.params.type === 'edit' ? '编辑' : '注册' |
|
|
|
} else { |
|
|
@ -71,7 +77,12 @@ router.beforeEach((to, from, next) => { |
|
|
|
if (res) { |
|
|
|
next() |
|
|
|
} else { |
|
|
|
next('/register') |
|
|
|
if (to.path === '/register') { |
|
|
|
next() |
|
|
|
} else { |
|
|
|
console.log(to) |
|
|
|
next({ path: '/register', query: { redirect: to.path, params: JSON.stringify(to.query) } }) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
@ -103,7 +114,6 @@ router.beforeEach((to, from, next) => { |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 账号密码登录
|
|
|
|
if (whiteList.includes(to.path)) { |
|
|
|
next() |
|
|
|
} else { |
|
|
@ -111,6 +121,7 @@ router.beforeEach((to, from, next) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
function getQueryParams() { |
|
|
|