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

// cookies

// 创建routes
const routes = [
    {
        // 重定向
        path: "/home",
        redirect: "/",
    },
    {
        // 产品图片上传（PDA）
        path: "/",
        component: () => import("@/views/CheckImageUpload.vue"),
        meta: { title: "产品图片上传" },
        children: [],
    },
    {
        // 磨合转序管理（PC）
        path: "/ri",
        component: () => import("@/views/RunningInManagement.vue"),
        meta: { title: "磨合转序管理" },
        children: [],
    },
    {
        // 产品图片上传（PDA）
        path: "/iu",
        component: () => import("@/views/CheckImageUpload.vue"),
        meta: { title: "产品图片上传" },
        children: [],
    }
];

//History路由模型
const router = createRouter({
    history: createWebHashHistory('./'),
    routes,
});

// 路由守卫：自动更新浏览器标题
router.beforeEach((to, from, next) => {
    if (to.meta && to.meta.title) {
        document.title = to.meta.title;
    }
    next();
});

export default router;
