import type { Router } from 'vue-router' import guards from '@af-mobile-client-vue3/router/guards' import { useSettingStore } from '@af-mobile-client-vue3/stores/modules/setting' import { loadGuards, loadRoutes } from '@af-mobile-client-vue3/utils/routerUtil' type GuardFunction = (to: any, from: any, next?: any) => void interface Guards { beforeEach?: GuardFunction[] afterEach?: GuardFunction[] } async function bootstrap(router: Router, customGuard: Guards = {}) { // 加载路由 loadRoutes() // 加载路由守卫 loadGuards({ ...guards, ...customGuard }, router) // 初始化时先加载webMobileConfig,防止登录页拿不到配置信息 try { await useSettingStore().init() } catch (e) { console.error(e) } } export default bootstrap