|
@@ -47,12 +47,20 @@ const routes = [
|
|
|
canFullScreen: true,
|
|
|
},
|
|
|
beforeEnter (to, from, next) {
|
|
|
- const audioNode = document.getElementById('global-audio')
|
|
|
- if (audioNode.src !== require(`@/assets/audios/${globalConfig.audioName.swkkView}.mp3`)) {
|
|
|
- audioNode.src = require(`@/assets/audios/${globalConfig.audioName.swkkView}.mp3`)
|
|
|
- audioNode.play()
|
|
|
+ if (from.name === 'HomeView') {
|
|
|
+ // 从首页过来的,需要reload。此时location还没有变。
|
|
|
+ let shabi = to.fullPath
|
|
|
+ location.hash = shabi
|
|
|
+ location.reload()
|
|
|
+ } else {
|
|
|
+ // 无论是从首页还是从不同楼层过来,导致reload。
|
|
|
+ const audioNode = document.getElementById('global-audio')
|
|
|
+ if (audioNode.src !== require(`@/assets/audios/${globalConfig.audioName.swkkView}.mp3`)) {
|
|
|
+ audioNode.src = require(`@/assets/audios/${globalConfig.audioName.swkkView}.mp3`)
|
|
|
+ audioNode.play()
|
|
|
+ }
|
|
|
+ next()
|
|
|
}
|
|
|
- next()
|
|
|
},
|
|
|
},
|
|
|
{
|
|
@@ -147,14 +155,14 @@ const router = new VueRouter({
|
|
|
routes
|
|
|
})
|
|
|
|
|
|
-// router.beforeEach((to, from, next) => {
|
|
|
-// console.log('beforeEach: ', to, from, next)
|
|
|
-// // 强制每次都从首页进入
|
|
|
-// if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView') {
|
|
|
-// next('/')
|
|
|
-// } else {
|
|
|
-// next()
|
|
|
-// }
|
|
|
-// })
|
|
|
+router.beforeEach((to, from, next) => {
|
|
|
+ console.log('beforeEach: ', to, from, next)
|
|
|
+ // 强制每次都从首页进入
|
|
|
+ if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView' && to.name !== 'SwkkView') {
|
|
|
+ next('/')
|
|
|
+ } else {
|
|
|
+ next()
|
|
|
+ }
|
|
|
+})
|
|
|
|
|
|
export default router
|