Commit 174595a5 by 李伟康

测试回退空白页问题

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