fix: migrations
This commit is contained in:
@@ -13,13 +13,30 @@ await getSettings()
|
||||
|
||||
const routes = await getRoutes()
|
||||
let newRoutes = []
|
||||
|
||||
function getLayoutFromComponent(path: string) {
|
||||
const emptyLayouts = [
|
||||
'LoginView.vue',
|
||||
'RegisterView.vue',
|
||||
'PasswordRecoveryView.vue',
|
||||
'VerifyEmailView.vue',
|
||||
'ResetPasswordForm.vue'
|
||||
]
|
||||
return emptyLayouts.some((name) => path.includes(name)) ? 'empty' : 'default'
|
||||
}
|
||||
|
||||
for (let r of routes) {
|
||||
const component = () => import(/* @vite-ignore */ `..${r.component}`)
|
||||
const parsedMeta = r.meta ? JSON.parse(r.meta) : {}
|
||||
const layout = parsedMeta.layout ?? getLayoutFromComponent(r.component)
|
||||
newRoutes.push({
|
||||
path: r.path,
|
||||
component,
|
||||
name: r.name,
|
||||
meta: r.meta ? JSON.parse(r.meta) : {},
|
||||
meta: {
|
||||
...parsedMeta,
|
||||
layout,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -73,15 +90,21 @@ async function setRoutes() {
|
||||
}
|
||||
|
||||
const importedComponent = (await importer()).default
|
||||
const parsedMeta = item.meta ? JSON.parse(item.meta) : {}
|
||||
const layout = parsedMeta.layout ?? getLayoutFromComponent(item.component)
|
||||
|
||||
router.addRoute('locale', {
|
||||
path: item.path,
|
||||
component: importedComponent,
|
||||
name: item.name,
|
||||
meta: item.meta ? JSON.parse(item.meta) : {}
|
||||
meta: {
|
||||
...parsedMeta,
|
||||
layout,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
console.log(router);
|
||||
// await router.replace(router.currentRoute.value.fullPath)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user