fix meilisearch
This commit is contained in:
@@ -10,6 +10,18 @@ function isAuthenticated(): boolean {
|
||||
}
|
||||
await getSettings()
|
||||
|
||||
const routes = await getRoutes()
|
||||
let newRoutes = []
|
||||
for (let r of routes) {
|
||||
const component = () => import(/* @vite-ignore */ `..${r.component}`)
|
||||
newRoutes.push({
|
||||
path: r.path,
|
||||
component,
|
||||
name: r.name,
|
||||
meta: r.meta ? JSON.parse(r.meta) : {},
|
||||
})
|
||||
}
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.VITE_BASE_URL),
|
||||
routes: [
|
||||
@@ -21,8 +33,9 @@ const router = createRouter({
|
||||
path: '/:locale',
|
||||
name: 'locale',
|
||||
children: [
|
||||
...newRoutes,
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
path: ':pathMatch(.*)*',
|
||||
component: () => import('@/views/NotFoundView.vue'),
|
||||
name: 'not-found-child',
|
||||
},
|
||||
@@ -36,25 +49,6 @@ const router = createRouter({
|
||||
],
|
||||
})
|
||||
|
||||
await getRoutes().then(routes => {
|
||||
const modules = import.meta.glob('/src/**/**/*.vue')
|
||||
routes.forEach(item => {
|
||||
const component = modules[`/src${item.Component}`]
|
||||
|
||||
if (!component) {
|
||||
console.error('Component not found:', item.Component)
|
||||
return
|
||||
}
|
||||
|
||||
router.addRoute('locale', {
|
||||
path: item.Path,
|
||||
component,
|
||||
name: item.Name,
|
||||
meta: item.Meta ? JSON.parse(item.Meta) : {}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
router.beforeEach((to, from) => {
|
||||
const locale = to.params.locale as string
|
||||
const localeLang = langs.find((x) => x.iso_code === locale)
|
||||
|
||||
@@ -10,7 +10,7 @@ export const getMenu = async () => {
|
||||
|
||||
|
||||
export const getRoutes = async () => {
|
||||
const resp = await useFetchJson<Route[]>('/api/v1/restricted/menu/get-routes');
|
||||
const resp = await useFetchJson<Route[]>('/api/v1/public/menu/get-routes');
|
||||
|
||||
return resp.items
|
||||
|
||||
|
||||
Reference in New Issue
Block a user