Commit 174595a5 by 李伟康

测试回退空白页问题

1 parent a38bf74b
......@@ -12,7 +12,7 @@ import routes from './routes'
import store from '@/store'
// hack router push callback
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
Router.prototype.push = function push (location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
......@@ -21,11 +21,11 @@ Vue.use(Router)
const router = createRouter()
function createRouter() {
function createRouter () {
return new Router({
// mode: 'history', // 如果是 history模式 需要配置vue.config.js publicPath
base: process.env.BASE_URL,
scrollBehavior: function(to, from, savedPosition) {
scrollBehavior: function (to, from, savedPosition) {
return savedPosition || { x: 0, y: 0 }
},
routes
......@@ -33,20 +33,24 @@ function createRouter() {
}
// http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main/
router.beforeEach((to, from, next) => {
if (to.name != 'common.accountList') store.commit('SET_LAST_PATH', to.name)
/* 路由发生变化修改页面title */
store.dispatch('setPageMeta', to.meta)
/* 路由发生变化修改页面背景色 */
document.documentElement.style.backgroundColor = to.meta.backgroundColor || '#fff'
if (to.matched.some(recode => recode.meta.noAuth)) {
store.state.app.showWindow = true
} else {
store.dispatch('navigation', to)
}
next()
})
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
if (to.name != 'common.accountList') store.commit('SET_LAST_PATH', to.name)
// let mark = to.fullPath.indexOf('code')
// if (mark !== -1 && from.fullPath === '/') {
// wx.closeWindow()
// }
/* 路由发生变化修改页面title */
store.dispatch('setPageMeta', to.meta)
/* 路由发生变化修改页面背景色 */
document.documentElement.style.backgroundColor = to.meta.backgroundColor || '#fff'
if (to.matched.some(recode => recode.meta.noAuth)) {
store.state.app.showWindow = true
} else {
store.dispatch('navigation', to)
}
next()
})
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter () {
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!