Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
dj-scrm-wx-work-main
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 174595a5
authored
Apr 27, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
测试回退空白页问题
1 parent
a38bf74b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
src/router/router.js
src/router/router.js
View file @
174595a
...
@@ -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
...
@@ -34,6 +34,10 @@ function createRouter() {
...
@@ -34,6 +34,10 @@ 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
)
// let mark = to.fullPath.indexOf('code')
// if (mark !== -1 && from.fullPath === '/') {
// wx.closeWindow()
// }
/* 路由发生变化修改页面title */
/* 路由发生变化修改页面title */
store
.
dispatch
(
'setPageMeta'
,
to
.
meta
)
store
.
dispatch
(
'setPageMeta'
,
to
.
meta
)
/* 路由发生变化修改页面背景色 */
/* 路由发生变化修改页面背景色 */
...
@@ -44,9 +48,9 @@ router.beforeEach((to, from, next) => {
...
@@ -44,9 +48,9 @@ router.beforeEach((to, from, next) => {
store
.
dispatch
(
'navigation'
,
to
)
store
.
dispatch
(
'navigation'
,
to
)
}
}
next
()
next
()
})
})
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export
function
resetRouter
()
{
export
function
resetRouter
()
{
const
newRouter
=
createRouter
()
const
newRouter
=
createRouter
()
router
.
matcher
=
newRouter
.
matcher
// reset router
router
.
matcher
=
newRouter
.
matcher
// reset router
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment