import {createRouter, createWebHashHistory} from "vue-router";


const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: '/login',
            name: 'login',
            component: () => import('@/views/login/index.vue'),
            meta: {title: '登录'},
        }, {
            path: '/manage',
            name: 'manage',
            alias: '/',
            component: () => import('@/views/manage/index.vue'),
            meta: {title: '管理后台'},
            children: [
                {
                    path: 'air_route',
                    name: 'air_route',
                    alias: '/',
                    component: () => import('@/views/manage/air_route/index.vue'),
                    meta: {title: '航线规划'},
                }
            ]
        }, {
            path: '/:catchAll(.*)',
            name: 'NotFound',
            component: () => import("@/router/NotFound/index.vue"),
        }
    ]
});
router.beforeEach(async (to) => {
    if (to.meta?.title) {
        document.title = import.meta.env.VITE_APP_TITLE + ' - ' + to.meta.title
    }
})


export default router;