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

// cookies

// 创建routes
const routes = [
    {
        // 重定向
        path: "/home",
        redirect: "/",
    },
    {
        //首页 各页面导航页
        path: "/",
        component: () => import("@/views/index.vue"),
        meta: { title: "系统导航页" },
        children: [],
    },
    {
        //PLCS接口调用记录
        path: "/InterfaceUseLog",
        component: () => import("@/views/InterfaceUseLog.vue"),
        meta: { title: "PLCS接口调用记录" },
        children: [],
    },
    {
        //返修上线工位
        path: "/repairOnline",
        component: () => import("@/views/repairOnline.vue"),
        meta: { title: "PLCS返修上线" },
        children: [],
    },
    {
        // 电检工艺路线返修上线
        path: "/electricRepairOnline",
        component: () => import("@/views/electricRepairOnline.vue"),
        meta: { title: "电检工艺路线返修上线" },
        children: [],
    },
    {
        // 手动静置出库
        path: "/manualStaticOut",
        component: () => import("@/views/manualStaticOut.vue"),
        meta: { title: "手动静置出库" },
        children: [],
    },
    {
        // 返修记录查询
        path: "/repairOnlineSearch",
        component: () => import("@/views/repairOnlineSearch.vue"),
        meta: { title: "返修记录查询" },
        children: [],
    },
    {
        // 首件拍照上传
        path: "/firstPartImageUpload",
        component: () => import("@/views/FirstPartImageUpload.vue"),
        meta: { title: "PLCS首件拍照上传" },
        children: [],
    },
    {
        // 工位异常处理
        path: "/op",
        component: () => import("@/views/OpStatus.vue"),
        meta: { title: "PLCS工位异常处理" },
        children: [],
    },
    {
        // PACK下线三码校验
        path: "/threeCodeVerify",
        component: () => import("@/views/ThreeCodeVerify.vue"),
        meta: { title: "PACK下线三码校验" },
        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;
