import { pinia } from '@/stores'
import { createRouter, createWebHistory } from 'vue-router'
import { useSystemStore } from '@/stores/modules/systemStore'
import { systemRoutes } from './system'
import { whitelistRoutes } from './whitelist'
import { createRouterGuards } from './router.guards.js'


const systemStore = useSystemStore(pinia)


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [ 
    ...systemRoutes,
    ...whitelistRoutes
  ],
})


export async function setupRouter(app) { 
  app.use(router)
  // 创建路由守卫
  createRouterGuards(router, systemStore)
}

export default router;