Commit f939900f by 李伟康

feat(router): 添加开发模式开关控制微信工作环境检查

- 在路由守卫中引入 devOff 配置变量
- 当 devOff 为 true 时不执行微信工作环境检查
- 允许在开发环境下绕过微信工作环境限制
1 parent 3973ad61
...@@ -34,6 +34,7 @@ function createRouter () { ...@@ -34,6 +34,7 @@ function createRouter () {
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const ua = navigator.userAgent.toLowerCase() const ua = navigator.userAgent.toLowerCase()
const isWxWork = ua.includes('wxwork') const isWxWork = ua.includes('wxwork')
const { devOff } = window.$fetchConfig
store.commit('SET_LAST_PATH', to.name) store.commit('SET_LAST_PATH', to.name)
/* 路由发生变化修改页面title */ /* 路由发生变化修改页面title */
store.dispatch('setPageMeta', to.meta) store.dispatch('setPageMeta', to.meta)
...@@ -45,7 +46,7 @@ router.beforeEach((to, from, next) => { ...@@ -45,7 +46,7 @@ router.beforeEach((to, from, next) => {
store.state.app.showWindow = true store.state.app.showWindow = true
store.dispatch('registerHttp') store.dispatch('registerHttp')
} else { } else {
if (!isWxWork && to.name !== 'notWxWork') return next('/mobile/notWxWork') if (!isWxWork && to.name !== 'notWxWork' && !devOff) return next('/mobile/notWxWork')
store.dispatch('navigation') store.dispatch('navigation')
} }
next() next()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!