mirror of
https://github.com/xiangshu233/vue3-vant4-mobile.git
synced 2025-08-08 03:02:05 +08:00
- Fixed spelling error in useRouteStoreWidthOut -> useRouteStoreWithOut - Fixed spelling error in useUserStoreWidthOut -> useUserStoreWithOut - Updated all imports and usage across affected files - Improved code semantic correctness and consistency
33 lines
951 B
TypeScript
33 lines
951 B
TypeScript
import type { App } from 'vue'
|
|
import type { RouteRecordRaw } from 'vue-router'
|
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
import { createRouterGuards } from './router-guards'
|
|
import routeModuleList from './modules'
|
|
import { ErrorPageRoute, LoginRoute, RootRoute } from '@/router/base'
|
|
import { useRouteStoreWithOut } from '@/store/modules/route'
|
|
|
|
// 菜单
|
|
|
|
// 普通路由
|
|
export const constantRouter: RouteRecordRaw[] = [LoginRoute, RootRoute, ErrorPageRoute]
|
|
|
|
const routeStore = useRouteStoreWithOut()
|
|
|
|
routeStore.setMenus(routeModuleList)
|
|
routeStore.setRouters(constantRouter.concat(routeModuleList))
|
|
|
|
const router = createRouter({
|
|
history: createWebHashHistory(''),
|
|
routes: constantRouter.concat(...routeModuleList),
|
|
strict: true,
|
|
scrollBehavior: () => ({ left: 0, top: 0 }),
|
|
})
|
|
|
|
export function setupRouter(app: App) {
|
|
app.use(router)
|
|
// 创建路由守卫
|
|
createRouterGuards(router)
|
|
}
|
|
|
|
export default router
|