import { createRouter, createWebHashHistory } from 'vue-router'
import { user } from '~/store'
import routes from 'virtual:generated-pages'

console.log('routes : ', routes)

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes,
})

router.beforeEach((to, from) => {
  if (user.value?.token) {
    return true//todo暂时去掉登录后的权限，整理代码后重构权限功能
  }
  else if (!user.value?.token) {
    if (to.path == '/login' || to.path == "/login/identityConfirm" || to.path == "/login/feedback") {
      return true
    } else {
      return {
        path: '/login'
      }
    }
  }
})



export default router
