import { createRouter, createWebHistory } from "vue-router";
/* Layout */
import Layout from "@/layout";
import basicInfo from "../views/admin/enterprise/account/basicInfo.vue";
import i18n from "@/i18n";

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * roles: ['admin', 'common']       // 访问路由的角色权限
 * permissions: ['a:a:a', 'b:b:b']  // 访问路由的菜单权限
 * meta : {
 noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
 title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
 icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
 breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
 activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
 }
 */
const { t } = i18n.global;
// 公共路由
export const constantRoutes = [
  {
    path: "/",
    name: "Home",
    component: () => import("../views/website/website-layout.vue"),
    hidden: true,
    children: [
      {
        path: "login",
        name: "login",
        component: () => import("@/views/website/login/index.vue"),
        children: [],
      },
      {
        path: "",
        component: () => import("../views/website/home/index.vue"),
      },
      {
        path: "searchList/enterprise",
        component: () => import("../views/website/searchList/enterprise.vue"),
        meta: {
          searchType: 1,
        },
      },
      {
        path: "searchList/enterprise/detail/:id",
        component: () =>
          import("../views/website/searchList/enterpriseDetail.vue"),
        meta: {
          searchType: 1,
        },
      },
      {
        path: "searchList/achievement",
        component: () => import("../views/website/searchList/achievement.vue"),
        meta: {
          searchType: 2,
        },
      },
      {
        path: "searchList/achievement/detail/:id",
        component: () =>
          import("../views/website/searchList/achievementDetail.vue"),
        meta: {
          searchType: 2,
        },
      },
      {
        path: "searchList/product/detail/:id",
        component: () =>
          import("../views/website/searchList/productDetail.vue"),
        meta: {
          searchType: 2,
        },
      },
      {
        path: "searchList/lab",
        component: () => import("../views/website/searchList/lab.vue"),
        meta: {
          searchType: 8,
        },
      },
      {
        path: "searchList/lab/detail/:id",
        component: () =>
          import("../views/website/searchList/laboratoryDetail.vue"),
        meta: {
          searchType: 8,
        },
      },
      {
        path: "searchList/patent",
        component: () => import("../views/website/searchList/patent.vue"),
        meta: {
          searchType: 4,
        },
      },
      {
        path: "searchList/patent/detail/:id",
        component: () => import("../views/website/searchList/patentDetail.vue"),
        meta: {
          searchType: 4,
        },
      },
      {
        path: "searchList/expert",
        component: () => import("../views/website/searchList/expert.vue"),
        meta: {
          searchType: 5,
        },
      },
      {
        path: "searchList/expert/detail/:id",
        component: () => import("../views/website/searchList/expertDetail.vue"),
        meta: {
          searchType: 5,
        },
      },
      {
        path: "searchList/serviceDemand",
        component: () =>
          import("../views/website/searchList/serviceDemand.vue"),
        meta: {
          searchType: 7,
        },
      },
      {
        path: "searchList/serviceDemand/detail/:id",
        component: () =>
          import("../views/website/searchList/serviceDemandDetail.vue"),
        meta: {
          searchType: 7,
        },
      },
      {
        path: "searchList/technologyDemand",
        component: () =>
          import("../views/website/searchList/technologyDemand.vue"),
        meta: {
          searchType: 6,
        },
      },
      {
        path: "searchList/technologyDemand/detail/:id",
        component: () =>
          import("../views/website/searchList/technologyDemandDetail.vue"),
        meta: {
          searchType: 6,
        },
      },
      {
        path: "solution/:mode",
        name: "solution",
        component: () => import("../views/website/solution/solution.vue"),
      },
      {
        path: "solution/detail/:id",
        name: "solutionDetail",
        component: () => import("../views/website/solution/detail.vue"),
      },
      {
        path: "/innovate",
        name: "innovate",
        component: () => import("../views/website/innovate/innovate.vue"),
      },
      {
        path: "innovate/detail/:id",
        name: "innovateDetail",
        component: () => import("../views/website/innovate/detail.vue"),
      },
      {
        path: "activity",
        name: "activity",
        component: () => import("../views/website/activity/activity.vue"), // children: [
        //   {
        //     path: '',
        //     name: 'activityList',
        //     component: () => import('../views/website/activity/list.vue'),
        //   },
        //   {
        //     path: 'detail/:id',
        //     name: 'activityDetail',
        //     component: () => import('../views/website/activity/detail.vue'),
        //   },
        // ]
      },
      {
        path: "about",
        name: "about",
        component: () => import("../views/website/about/about.vue"),
      },
    ],
  },

  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index.vue"),
      },
    ],
  }, // {
  //   path: "/login",
  //   component: () => import("@/views/login"),
  //   hidden: true,
  // },
  // {
  //   path: "/register",
  //   component: () => import("@/views/register"),
  //   hidden: true,
  // },
  {
    path: "/:pathMatch(.*)*",
    component: () => import("@/views/error/404"),
    hidden: true,
  },
  {
    path: "/401",
    component: () => import("@/views/error/401"),
    hidden: true,
  },

  {
    path: "/identity",
    component: () => import("@/views/identity/layout"),
    hidden: true,
    children: [
      {
        path: "index",
        component: () => import("@/views/identity/index"),
        name: "index",
        meta: { title: "身份选择" },
      },
      {
        path: "enterprise",
        component: () => import("@/views/identity/enterprise"),
        name: "enterprise",
        meta: { title: "企业入驻" },
      },
      {
        path: "expert",
        component: () => import("@/views/identity/expert"),
        name: "expert",
        meta: { title: "专家入驻" },
      },
      {
        path: "research",
        component: () => import("@/views/identity/research"),
        name: "research",
        meta: { title: "研究机构入驻" },
      },
      {
        path: "laboratory",
        component: () => import("@/views/identity/laboratory"),
        name: "laboratory",
        meta: { title: "实验室入驻" },
      },
      {
        path: "agent",
        component: () => import("@/views/identity/agent"),
        name: "agent",
        meta: { title: "科技经纪人入驻" },
      },
    ],
  }, //TODO:

  // {
  //   path: '',
  //   component: Layout,
  //   redirect: '/index',
  //   children: [
  //     {
  //       path: '/index',
  //       component: () => import('@/views/index'),
  //       name: 'Index',
  //       meta: { title: '首页', icon: 'dashboard', affix: true }
  //     }
  //   ]
  // },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "profile",
        component: () => import("@/views/system/user/profile/index"),
        name: "Profile",
        meta: { title: "个人中心", icon: "user" },
      },
    ],
  },
];

// 企业后台路由表
export const enterpriseRoutes = [
  {
    path: "/admin",
    component: Layout,
    redirect: "/admin/index",
    children: [
      {
        path: "index",
        component: () => import("@/views/admin/enterprise/index"),
        name: "Index",
        meta: {
          title: "首页",
          i18nStr: "routes.company.home",
          icon: "dashboard",
          affix: true,
        },
      },
    ],
  },
  {
    path: "/account",
    component: Layout,
    meta: {
      title: "账号管理",
      icon: "dashboard",
      i18nStr: "routes.company.accountManagement",
    },
    alwaysShow: true,
    redirect: "/account/basicInfo",
    children: [
      {
        path: "basicInfo",
        component: basicInfo,
        name: "basicInfo",
        meta: {
          title: "基本资料",
          i18nStr: "routes.company.basicInformation",
          icon: "list",
        },
      },
      {
        path: "joinMembership",
        component: () =>
          import("@/views/admin/enterprise/account/joinMembership"),
        name: "joinMembership",
        meta: {
          title: "开通会员",
          icon: "list",
          i18nStr: "routes.company.openMember",
        },
      },
      {
        path: "bill",
        component: () => import("@/views/admin/enterprise/account/bill"),
        name: "Bill",
        meta: {
          title: "账单列表",
          icon: "list",
          i18nStr: "routes.company.billList",
        },
      }, // {
      //   path: "record",
      //   component: () => import("@/views/admin/enterprise/account/record"),
      //   name: "Record",
      //   meta: { title: "创新币兑换记录", icon: "list" },
      // },
    ],
  },
  {
    path: "/extension",
    component: Layout,
    meta: {
      title: "产品推广",
      icon: "dashboard",
      i18nStr: "routes.company.productPromotion",
    },
    alwaysShow: true,
    redirect: "/extension/product",
    children: [
      {
        path: "product",
        component: () => import("@/views/admin/enterprise/extension/product"),
        name: "Product",
        meta: {
          title: "产品列表",
          icon: "list",
          i18nStr: "routes.company.productList",
        },
      },
      {
        path: "release",
        component: () => import("@/views/admin/enterprise/extension/release"),
        hidden: true,
        name: "Release",
        meta: {
          title: "发布产品",
          icon: "list",
          i18nStr: "routes.company.publishProduct",
        },
      },
      {
        path: "results",
        component: () => import("@/views/admin/enterprise/extension/results"),
        hidden: true,
        name: "Results",
        meta: {
          title: "匹配结果",
          icon: "list",
          isMatch: true,
          i18nStr: "routes.company.matchingResults",
        },
      },
      {
        path: "business",
        component: () => import("@/views/admin/enterprise/extension/business"),
        hidden: true,
        name: "Business",
        meta: {
          title: "浏览信息",
          icon: "list",
          i18nStr: "routes.company.browseInformation",
        },
      },
    ],
  },
  {
    path: "/demand",
    component: Layout,
    meta: {
      title: "需求管理",
      icon: "dashboard",
      i18nStr: "routes.company.demandManagement",
    },
    alwaysShow: true,
    redirect: "/demand/serviceDemand",
    children: [
      {
        path: "serviceDemand",
        component: () =>
          import("@/views/admin/enterprise/demand/serviceDemand"),
        name: "serviceDemand",
        meta: {
          title: "服务需求",
          icon: "list",
          i18nStr: "routes.company.serviceDemand",
        },
      },
      {
        path: "releaseService",
        component: () =>
          import("@/views/admin/enterprise/demand/releaseService"),
        hidden: true,
        name: "releaseService",
        meta: {
          title: "发布服务需求",
          icon: "list",
          i18nStr: "routes.company.publishServiceDemand",
        },
      },
      {
        path: "technology",
        component: () => import("@/views/admin/enterprise/demand/technology"),
        name: "technology",
        meta: {
          title: "技术需求",
          icon: "list",
          i18nStr: "routes.company.technicalDemand",
        },
      },
      {
        path: "releaseTechnology",
        component: () =>
          import("@/views/admin/enterprise/demand/releaseTechnology"),
        hidden: true,
        name: "releaseTechnology",
        meta: {
          title: "发布技术需求",
          icon: "list",
          i18nStr: "routes.company.publishTechnicalDemand",
        },
      },
      {
        path: "results",
        component: () => import("@/views/admin/enterprise/extension/results"),
        hidden: true,
        name: "results",
        meta: {
          title: "匹配结果",
          icon: "list",
          isMatch: true,
          i18nStr: "routes.company.matchingResults",
        },
      },
    ],
  },
  {
    path: "/activity",
    component: Layout,
    meta: {
      title: "活动管理",
      icon: "dashboard",
      i18nStr: "routes.company.activityManagement",
    },
    alwaysShow: true,
    redirect: "/activity/active",
    children: [
      {
        path: "active",
        component: () => import("@/views/admin/enterprise/activity/active"),
        name: "Active",
        meta: {
          title: "活动列表",
          icon: "list",
          i18nStr: "routes.company.activityList",
        },
      },
    ],
  },
];

// 专家后台路由表
export const expertRoutes = [
  {
    path: "/admin",
    component: Layout,
    redirect: "/admin/index",
    children: [
      {
        path: "index",
        component: () => import("@/views/admin/expert/index"),
        name: "Index",
        meta: {
          title: "首页",
          icon: "dashboard",
          affix: true,
          i18nStr: "routes.expert.home",
        },
      },
    ],
  },
  {
    path: "/account",
    component: Layout,
    meta: {
      title: "账号管理",
      icon: "dashboard",
      i18nStr: "routes.expert.accountManagement",
    },
    alwaysShow: true, // redirect: 'noRedirect',
    redirect: "/account/bill",
    children: [
      // {
      //   path: "bill",
      //   component: () => import("@/views/admin/expert/account/bill"),
      //   name: "Bill",
      //   meta: { title: "账单列表", icon: "list" },
      // },
      // {
      //   path: "exchange",
      //   component: () => import("@/views/admin/expert/account/exchange"),
      //   name: "Exchange",
      //   meta: { title: "兑换记录", icon: "list" },
      // },
      {
        path: "basicInfo",
        component: () => import("@/views/admin/expert/account/basicInfo"),
        name: "basicInfo",
        meta: {
          title: "基本资料",
          icon: "list",
          i18nStr: "routes.expert.basicInformation",
        },
      }, // {
      //   path: "transactionAuth",
      //   component: () => import("@/views/admin/expert/account/transactionAuth"),
      //   name: "transactionAuth",
      //   meta: { title: "交易认证", icon: "list" },
      // },
      // {
      //   path: "profit",
      //   component: () => import("@/views/admin/expert/account/profit"),
      //   name: "profit",
      //   meta: { title: "收益管理", icon: "list" },
      // },
      // {
      //   path: "withdrawal",
      //   component: () => import("@/views/admin/expert/account/withdrawal"),
      //   hidden: true,
      //   name: "Withdrawal",
      //   meta: { title: "提现记录", icon: "list" },
      // },
    ],
  },
  {
    path: "/technology",
    component: Layout,
    meta: {
      title: "技术管理",
      icon: "dashboard",
      i18nStr: "routes.expert.technicalManagement",
    },
    alwaysShow: true,
    redirect: "/technology/achievement",
    children: [
      {
        path: "achievement",
        component: () => import("@/views/admin/expert/technology/achievement"),
        name: "Achievement",
        meta: {
          title: "成果列表",
          icon: "list",
          i18nStr: "routes.expert.achievementList",
        },
      },
      {
        path: "release",
        component: () => import("@/views/admin/expert/technology/release"),
        hidden: true,
        name: "Release",
        meta: {
          title: "发布成果",
          icon: "list",
          i18nStr: "routes.expert.publishAchievement",
        },
      },
      {
        path: "results", // component: () => import("@/views/admin/expert/technology/results"),
        component: () => import("@/views/admin/enterprise/extension/results"),
        hidden: true,
        name: "Results",
        meta: {
          title: "匹配结果",
          icon: "list",
          isMatch: false,
          i18nStr: "routes.expert.matchingResults",
        },
      },
      {
        path: "patent",
        component: () => import("@/views/admin/expert/technology/patent"),
        name: "patent",
        meta: {
          title: "专利列表",
          icon: "list",
          i18nStr: "routes.expert.patentList",
        },
      },
      {
        path: "claimPatent",
        component: () => import("@/views/admin/expert/technology/claimPatent"),
        hidden: true,
        name: "claimPatent",
        meta: {
          title: "认领专利",
          icon: "list",
          i18nStr: "routes.expert.claimPatent",
        },
      },
      {
        path: "paper",
        component: () => import("@/views/admin/expert/technology/paper"),
        name: "Paper",
        meta: {
          title: "论文列表",
          icon: "list",
          i18nStr: "routes.expert.paperList",
        },
      },
      {
        path: "research",
        component: () => import("@/views/admin/expert/technology/research"),
        name: "Research",
        meta: {
          title: "科研项目列表",
          icon: "list",
          i18nStr: "routes.expert.researchProjectList",
        },
      },
    ],
  },
  {
    path: "/demand",
    component: Layout,
    meta: {
      title: "需求管理",
      icon: "dashboard",
      i18nStr: "routes.expert.demandManagement",
    },
    alwaysShow: true,
    redirect: "/demand/serviceDemand",
    children: [
      {
        path: "serviceDemand",
        component: () => import("@/views/admin/expert/demand/serviceDemand"),
        name: "serviceDemand",
        meta: {
          title: "服务需求",
          icon: "list",
          i18nStr: "routes.expert.serviceDemand",
        },
      },
      {
        path: "release",
        component: () => import("@/views/admin/expert/demand/release"),
        hidden: true,
        name: "release",
        meta: {
          title: "发布需求",
          icon: "list",
          i18nStr: "routes.expert.publishDemand",
        },
      },
      {
        path: "already",
        component: () => import("@/views/admin/expert/demand/already"),
        name: "already",
        meta: {
          title: "已合作企业",
          icon: "list",
          i18nStr: "routes.expert.cooperatedCompany",
        },
      },
      {
        path: "think",
        component: () => import("@/views/admin/expert/demand/think"),
        name: "think",
        meta: {
          title: "想合作企业",
          icon: "list",
          i18nStr: "routes.expert.wantCooperateCompany",
        },
      },
    ],
  },

  {
    path: "/activity",
    component: Layout,
    meta: {
      title: "活动管理",
      icon: "dashboard",
      i18nStr: "routes.expert.activityManagement",
    },
    alwaysShow: true,
    redirect: "/activity/active",
    children: [
      {
        path: "active",
        component: () => import("@/views/admin/expert/activity/active"),
        name: "Active",
        meta: {
          title: "活动列表",
          icon: "list",
          i18nStr: "routes.expert.activityList",
        },
      },
    ],
  },
];

export const laboratoryRoutes = [
  {
    path: "/admin",
    component: Layout,
    redirect: "/admin/index",
    children: [
      {
        path: "index",
        component: () => import("@/views/admin/laboratory/index"),
        name: "Index",
        meta: {
          title: "首页",
          icon: "dashboard",
          affix: true,
          i18nStr: "routes.lab.home",
        },
      },
    ],
  },
  {
    path: "/admin/account",
    component: Layout,
    meta: {
      title: "账号管理",
      icon: "dashboard",
      i18nStr: "routes.lab.accountManagement",
    },
    alwaysShow: true,
    redirect: "/admin/account/basic-info",
    children: [
      {
        path: "basic-info",
        component: () =>
          import("@/views/admin/laboratory/account/basic-info.vue"),
        name: "basicInfo",
        meta: {
          title: "基本资料",
          icon: "list",
          i18nStr: "routes.lab.basicInformation",
        },
      },
    ],
  },
  {
    path: "/admin/research",
    component: Layout,
    meta: {
      title: "科研管理",
      icon: "dashboard",
      i18nStr: "routes.lab.researchManagement",
    },
    alwaysShow: true,
    redirect: "/admin/research/patent",
    children: [
      {
        path: "patent",
        component: () =>
          import("@/views/admin/laboratory/research/patent/index.vue"),
        name: "Patent",
        meta: {
          title: "专利列表",
          icon: "list",
          i18nStr: "routes.lab.patentList",
        },
      },
      // {
      //   path: "achievement",
      //   component: () =>
      //     import("@/views/admin/laboratory/research/achievement/index.vue"),
      //   name: "Achievement",
      //   meta: {
      //     title: "成果列表",
      //     icon: "list",
      //     i18nStr: "routes.lab.achievementList",
      //   },
      // },
      {
        path: "expert-achievement",
        component: () =>
          import("@/views/admin/laboratory/research/achievement/index.vue"),
        meta: {
          title: "专家成果",
          icon: "list",
          i18nStr: "routes.lab.expertAchievement",
        },
        name: "ExpertAchievement",
      },
      {
        path: "lab-achievement",
        component: () =>
          import("@/views/admin/laboratory/research/achievement/index.vue"),
        meta: {
          title: "实验室成果",
          icon: "list",
          i18nStr: "routes.lab.labAchievement",
        },
        name: "LabAchievement",
      },
      {
        path: "release",
        component: () =>
          import("@/views/admin/laboratory/research/achievement/release"),
        hidden: true,
        name: "Release",
        meta: {
          title: "发布成果",
          icon: "list",
          i18nStr: "routes.expert.publishAchievement",
        },
      },
      {
        path: "service-demand",
        component: () =>
          import("@/views/admin/laboratory/research/service-demand/index.vue"),
        name: "ServiceDemand",
        meta: {
          title: "服务需求列表",
          icon: "list",
          i18nStr: "routes.lab.serviceDemandList",
        },
      },
      {
        path: "service-demand/detail/:id",
        component: () =>
          import("@/views/admin/laboratory/research/service-demand/detail.vue"),
        hidden: true,
        name: "ServiceDemandDetail",
        meta: {
          title: "查看需求",
          icon: "list",
          i18nStr: "routes.lab.viewDemand",
        },
      },
      {
        path: "expert",
        component: () =>
          import("@/views/admin/laboratory/research/expert/index.vue"),
        name: "Expert",
        meta: {
          title: "专家列表",
          icon: "list",
          i18nStr: "routes.lab.expertList",
        },
      },
      {
        path: "research-project",
        component: () =>
          import(
            "@/views/admin/laboratory/research/research-project/index.vue"
          ),
        name: "ResearchProject",
        meta: {
          title: "科研项目列表",
          icon: "list",
          i18nStr: "routes.lab.researchProjectList",
        },
      },
      {
        path: "paper",
        component: () =>
          import("@/views/admin/laboratory/research/paper/index.vue"),
        name: "Paper",
        meta: {
          title: "论文列表",
          icon: "list",
          i18nStr: "routes.lab.paperList",
        },
      },
      {
        path: "paper/unit-info",
        component: () =>
          import("@/views/admin/laboratory/research/paper/unit-info.vue"),
        hidden: true,
        name: "UnitInfo",
        meta: {
          title: "浏览单位信息",
          icon: "list",
          i18nStr: "routes.lab.viewUnitInformation",
        },
      },
      {
        path: "laboratory-equipment",
        component: () =>
          import(
            "@/views/admin/laboratory/research/laboratory-equipment/index.vue"
          ),
        name: "LaboratoryEquipment",
        meta: {
          title: "实验设备",
          icon: "list",
          i18nStr: "routes.lab.experimentalEquipment",
        },
      },
    ],
  },
];

export const researchRoutes = [
  {
    /*研究机构后台首页*/
    path: "/admin",
    component: Layout,
    redirect: "/admin/index",
    children: [
      {
        path: "index",
        component: () => import("@/views/admin/research/index"),
        name: "Index",
        meta: {
          title: "首页",
          icon: "dashboard",
          affix: true,
          i18nStr: "routes.research.home",
        },
      },
    ],
  },
  {
    path: "/admin/account",
    component: Layout,
    meta: {
      title: "账号管理",
      icon: "dashboard",
      i18nStr: "routes.research.accountManagement",
    },
    alwaysShow: true,
    redirect: "/admin/account/basic-info",
    children: [
      {
        path: "basic-info",
        component: () =>
          import("@/views/admin/research/account/basic-info.vue"),
        name: "basicInfo",
        meta: {
          title: "基本资料",
          icon: "list",
          i18nStr: "routes.research.basicInformation",
        },
      },
    ],
  },
  {
    path: "/admin/research",
    component: Layout,
    meta: {
      title: "科研管理",
      icon: "dashboard",
      i18nStr: "routes.research.researchManagement",
    },
    alwaysShow: true,
    redirect: "/admin/research/patent",
    children: [
      {
        path: "patent",
        component: () =>
          import("@/views/admin/research/research/patent/index.vue"),
        name: "Patent",
        meta: {
          title: "专利列表",
          icon: "list",
          i18nStr: "routes.research.patentList",
        },
      },
      // {
      //   path: "achievement",
      //   component: () =>
      //     import("@/views/admin/research/research/achievement/index.vue"),
      //   name: "Achievement",
      //   meta: {
      //     title: "成果列表",
      //     icon: "list",
      //     i18nStr: "routes.research.achievementList",
      //   },
      // },
      {
        path: "expert-achievement",
        component: () =>
          import("@/views/admin/research/research/achievement/index.vue"),
        name: "ExpertAchievement",
        meta: {
          title: "专家成果列表",
          icon: "list",
          i18nStr: "routes.research.expertAchievementList",
        },
      },
      {
        path: "research-achievement",
        component: () =>
          import("@/views/admin/research/research/achievement/index.vue"),
        name: "ResearchAchievement",
        meta: {
          title: "科研机构成果列表",
          icon: "list",
          i18nStr: "routes.research.researchInstitutionAchievementList",
        },
      },
      {
        path: "service-demand",
        component: () =>
          import("@/views/admin/research/research/service-demand/index.vue"),
        name: "ServiceDemand",
        hidden: true,
        meta: {
          title: "服务需求列表",
          icon: "list",
          i18nStr: "routes.research.serviceDemandList",
        },
      },
      {
        path: "service-demand/detail/:id",
        component: () =>
          import("@/views/admin/research/research/service-demand/detail.vue"),
        hidden: true,
        name: "ServiceDemandDetail",
        meta: {
          title: "查看需求",
          icon: "list",
          i18nStr: "routes.research.viewDemand",
        },
      },
      {
        path: "expert",
        component: () =>
          import("@/views/admin/research/research/expert/index.vue"),
        name: "Expert",
        meta: {
          title: "专家列表",
          icon: "list",
          i18nStr: "routes.research.expertList",
        },
      },
      {
        path: "research-project",
        component: () =>
          import("@/views/admin/research/research/research-project/index.vue"),
        name: "ResearchProject",
        meta: {
          title: "科研项目列表",
          icon: "list",
          i18nStr: "routes.research.researchProjectList",
        },
      },
      {
        path: "laboratory",
        component: () =>
          import("@/views/admin/research/research/laboratory/index.vue"),
        name: "Laboratory",
        meta: {
          title: "实验室列表",
          icon: "list",
          i18nStr: "routes.research.labList",
        },
      },
      {
        path: "laboratory/edit",
        component: () =>
          import("@/views/admin/research/research/laboratory/edit.vue"),
        name: "EditLaboratory",
        hidden: true,
        meta: {
          title: "修改实验室",
          icon: "edit",
          i18nStr: "routes.research.modifyLab",
        },
      },
    ],
  },
  {
    // 客户足迹路由
    path: "/admin/footprint",
    component: Layout,
    meta: {
      title: "客户足迹",
      icon: "dashboard",
      i18nStr: "routes.research.customerFootprint",
    },
    alwaysShow: true,
    redirect: "/admin/footprint/browsing-history",
    children: [
      {
        //    浏览数据
        path: "browsing-history",
        component: () =>
          import("@/views/admin/research/footprint/browsing-history/index.vue"),
        name: "BrowsingHistory",
        meta: {
          title: "浏览数据",
          icon: "list",
          i18nStr: "routes.research.browsingData",
        },
      },
    ],
  },
];

/**
 * 经纪人路由列表
 * @type {[{redirect: string, path: string, component: {}, children: [{path: string, component: (function(): Promise<{}>), meta: {affix: boolean, icon: string, title: string}, name: string}]}]}
 */
export const agentRoutes = [
  {
    // 首页路由
    path: "/admin",
    component: Layout,
    redirect: "/admin/index",
    children: [
      {
        path: "index",
        component: () => import("@/views/admin/agent/index.vue"),
        name: "Index",
        meta: {
          title: "首页",
          icon: "dashboard",
          affix: true,
          i18nStr: "routes.broker.home",
        },
      },
    ],
  },
  {
    path: "/admin/service",
    component: Layout,
    meta: {
      title: "服务管理",
      icon: "dashboard",
      i18nStr: "routes.broker.serviceManagement",
    },
    alwaysShow: true,
    redirect: "/admin/service/enterprise",
    children: [
      {
        path: "enterprise",
        component: () =>
          import("@/views/admin/agent/service/enterprise/index.vue"),
        name: "ServiceEnterprise",
        meta: {
          title: "我服务的企业",
          icon: "list",
          i18nStr: "routes.broker.myServiceEnterprise",
        },
      },
      {
        path: "technology-demand",
        component: () =>
          import(
            "@/views/admin/agent/service/enterprise/technology-demand.vue"
          ),
        name: "TechnologyDemandList",
        hidden: true,
        meta: {
          title: "技术需求列表",
          icon: "list",
          i18nStr: "routes.broker.technicalDemandList",
        },
      },
      {
        path: "results",
        component: () => import("@/views/admin/enterprise/extension/results"),
        hidden: true,
        name: "Results",
        meta: {
          title: "匹配结果",
          icon: "list",
          isMatch: true,
          i18nStr: "routes.broker.matchingResults",
        },
      },
      {
        path: "technology-demand-release",
        component: () =>
          import(
            "@/views/admin/agent/service/enterprise/technology-demand-release.vue"
          ),
        name: "TechnologyDemandRelease",
        hidden: true,
        meta: {
          title: "发布需求",
          icon: "list",
          i18nStr: "routes.broker.publishDemand",
        },
      },
      {
        path: "update-status",
        component: () =>
          import("@/views/admin/agent/service/enterprise/update-status.vue"),
        name: "TechnologyDemandUpdateStatus",
        hidden: true,
        meta: {
          title: "更新状态",
          icon: "list",
          i18nStr: "routes.broker.updateStatus",
        },
      },
      // {
      //   path: "matching-demand",
      //   component: () =>
      //     import("@/views/admin/agent/service/matching-demand/index.vue"),
      //   name: "EnterpriseDemandMatch",
      //   meta: {
      //     title: "企业需求匹配",
      //     icon: "list",
      //     i18nStr: "routes.broker.enterpriseDemandMatching",
      //   },
      // },
      {
        path: "matching-demand-detail",
        component: () =>
          import("@/views/admin/agent/service/matching-demand/index.vue"),
        name: "EnterpriseDemandMatchDetail",
        hidden: true,
        meta: {
          title: "企业需求匹配详情",
          icon: "list",
          i18nStr: "routes.broker.enterpriseDemandMatchingDetails",
        },
      },
    ],
  },

  {
    path: "/admin/account",
    component: Layout,
    meta: {
      title: "账号管理",
      icon: "dashboard",
      i18nStr: "routes.broker.accountManagement",
    },
    alwaysShow: true,
    redirect: "/admin/account/basic-info",
    children: [
      {
        path: "basic-info",
        component: () => import("@/views/admin/agent/account/basic-info.vue"),
        name: "basicInfo",
        meta: {
          title: "基本资料",
          icon: "list",
          i18nStr: "routes.broker.basicInformation",
        },
      },
    ],
  },
  {
    path: "/admin/bill",
    component: Layout,
    meta: {
      title: "账单管理",
      icon: "dashboard",
      i18nStr: "routes.broker.billManagement",
    },
    alwaysShow: true,
    redirect: "/admin/bill/bill-list",
    children: [
      {
        path: "bill-list",
        component: () => import("@/views/admin/agent/bill/bill-list/index.vue"),
        name: "BillList",
        meta: {
          title: "账单列表",
          icon: "list",
          i18nStr: "routes.broker.billList",
        },
      },
    ],
  },
];

// 动态路由，基于用户权限动态去加载
const router = createRouter({
  history: createWebHistory(),
  routes: constantRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { top: 0 };
    }
  },
});

export default router;
