File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -74,10 +74,24 @@ export const asyncRoutes = [
7474 // ]
7575 // }
7676]
77- const router = new VueRouter ( {
78- // mode: 'history',
77+
78+ const createRouter = ( ) => new VueRouter ( {
79+ // mode: 'history', // require service support
80+ scrollBehavior : ( ) :any => ( { y : 0 } ) ,
7981 base : process . env . BASE_URL ,
8082 routes : constantRoutes
8183} )
8284
85+ const router = createRouter ( )
86+
87+ export function resetRouter ( ) { // 清除路由缓存
88+ const newRouter = createRouter ( ) ;
89+ ( router as any ) . matcher = ( newRouter as any ) . matcher // reset router
90+ }
91+ // const router = new VueRouter({
92+ // // mode: 'history',
93+ // base: process.env.BASE_URL,
94+ // routes: constantRoutes
95+ // })
96+
8397export default router
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { setToken, removeToken } from '@/utils/auth'
44import { LoginInfo , UserInfo } from '@/interface/api/login'
55import { Commit } from 'vuex'
66import { message } from 'ant-design-vue'
7+ import { resetRouter } from '@/router'
78export interface State {
89 user : UserInfo
910 roles : Array < string >
@@ -56,6 +57,7 @@ const user = {
5657 return new Promise ( ( resolve , reject ) => {
5758 try {
5859 message . success ( '退出成功!' )
60+ resetRouter ( )
5961 context . commit ( 'SET_USER_INFO' , '' )
6062 context . commit ( 'SET_TOKEN' , '' )
6163 context . commit ( 'SET_ROLE' , [ ] )
You can’t perform that action at this time.
0 commit comments