|
@@ -12,19 +12,14 @@ const modules = import.meta.glob('@/views/**/*.vue')
|
|
|
export const initDynamicRouter = async () => {
|
|
|
const userStore = useUserStore()
|
|
|
const authStore = useAuthStore()
|
|
|
+
|
|
|
try {
|
|
|
if (authStore.isLoaded) return
|
|
|
await authStore.setMenuList()
|
|
|
await authStore.setLoaded()
|
|
|
- if (!authStore.getMenuList.length) {
|
|
|
- userStore.setToken('')
|
|
|
- router.replace(LOGIN_URL)
|
|
|
- return Promise.reject('No permission')
|
|
|
- }
|
|
|
|
|
|
// 3.添加动态路由
|
|
|
authStore.flatMenuListGet.forEach((item: Menu.MenuOptions) => {
|
|
|
- console.log('item', item)
|
|
|
if (item.children) delete item.children
|
|
|
if (item.component && typeof item.component == 'string') {
|
|
|
item.component = modules['/src/views' + item.component + '.vue']
|