You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import type { App } from 'vue'
import type { RouteRecordRaw } from 'vue-router'
import { createRouter , createWebHistory } from 'vue-router'
import remainingRouter from './modules/remaining'
// 创建路由实例
const router = createRouter ( {
history : createWebHistory ( ) , // createWebHashHistory URL带#, createWebHistory URL不带#
strict : true ,
routes : remainingRouter as RouteRecordRaw [ ] ,
scrollBehavior : ( ) = > ( { left : 0 , top : 0 } )
} )
export const resetRouter = ( ) : void = > {
const resetWhiteNameList = [ 'Redirect' , 'Login' , 'NoFind' , 'Root' ]
router . getRoutes ( ) . forEach ( ( route ) = > {
const { name } = route
if ( name && ! resetWhiteNameList . includes ( name as string ) ) {
router . hasRoute ( name ) && router . removeRoute ( name )
}
} )
}
export const setupRouter = ( app : App < Element > ) = > {
app . use ( router )
}
export default router