import Vue from "vue";
import Router from "vue-router";
import { userInfo } from '@/stores/user'
import request from '@/utils/request';
const isAdmin = true
// const isAdmin = userInfo.user_role_id === '69'

Vue.use(Router);

const originalPush = Router.prototype.push;
Router.prototype.push = function (location) {
  originalPush.call(this, location).catch((err) => err);
};
const originalReplace = Router.prototype.replace;
Router.prototype.replace = function (location) {
  originalReplace.call(this, location).catch((err) => err);
};

/* AppLayout */
import AppLayout from "@/layout/app/index.vue";

/* MainDefaultLayout */
import MainDefaultLayout from "@/layout/main/default/index.vue";

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */
import xxgzjcRoutes from "./routes/xxgzjc";

/**
 * allRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const allRoutes = [
  {
    path: "/gwglxt",
    name: "gwglxt",
    component: AppLayout,
    meta: { title: "公文管理系统", icon: "el-icon-document" },
    redirect: "/gwglxt/fwng",
    children: [
      {
        path: "/gwglxt/fwng",
        name: "gwglxt_fwng",
        component: () => import("@/views/gwglxt/fwng/index.vue"),
        meta: { title: "发文拟稿" },
      },
      {
        path: "/gwglxt/wdfw",
        name: "gwglxt_wdfw",
        component: () => import("@/views/gwglxt/wdfw/index.vue"),
        meta: { title: "我的发文" },
      },
      {
        path: "/gwglxt/dbfw",
        name: "gwglxt_dbfw_main",
        component: MainDefaultLayout,
        meta: { title: "待办发文" },
        children: [
          {
            path: "",
            name: "gwglxt_dbfw",
            component: () => import("@/views/gwglxt/dbfw/index.vue"),
            meta: { title: "待办发文" },
            props: true,
          },
          {
            path: "sh/:id",
            hidden: true,
            name: "gwglxt_dbfw_sh",
            component: () => import("@/views/gwglxt/dbfw/sh/index.vue"),
            meta: { title: "审核" },
            props: true,
          },
          {
            path: "lsbjjl/:id",
            hidden: true,
            name: "gwglxt_dbfw_lsbjjl",
            component: () => import("@/views/gwglxt/dbfw/lsbjjl/index.vue"),
            meta: { title: "历史编辑记录" },
            props: true,
          },
          {
            path: "dzqz/:id",
            hidden: true,
            name: "gwglxt_dbfw_dzqz",
            component: () => import("@/views/gwglxt/dbfw/dzqz/index.vue"),
            meta: { title: "电子签章" },
            props: true,
          },
        ],
      },
      {
        path: "/gwglxt/gwjh",
        name: "gwglxt_gwjh",
        component: () => import("@/views/gwglxt/gwjh/index.vue"),
        meta: { title: "公文交互" },
      },
      {
        path: "/gwglxt/dygw",
        name: "gwglxt_dygw",
        component: () => import("@/views/gwglxt/dygw/index.vue"),
        meta: { title: "待阅公文" },
      },
      {
        path: "/gwglxt/gwk",
        name: "gwglxt_gwk_main",
        component: MainDefaultLayout,
        meta: { title: "公文库" },
        children: [
          {
            path: "",
            name: "gwglxt_gwk",
            component: () => import("@/views/gwglxt/gwk/index.vue"),
            meta: { title: "公文库" },
            props: true,
          },
          {
            path: "gwxq/:id",
            hidden: true,
            name: "gwglxt_dbfw_gwxq",
            component: () => import("@/views/gwglxt/gwk/gwxq/index.vue"),
            meta: { title: "公文详情" },
            props: true,
          },
        ],
      },
      {
        path: "/gwglxt/lcgl",
        name: "gwglxt_lcgl",
        component: () => import("@/views/gwglxt/lcgl/index.vue"),
        meta: { title: "流程管理" },
      },
    ],
  },
  // {
  //   path: "/wjsj",
  //   name: "wjsj",
  //   component: AppLayout,
  //   meta: { title: "文件收集", icon: "el-icon-document" },
  //   redirect: "/wjsj/wjgzt",
  //   children: [
  //     {
  //       path: "/wjsj/wjgzt",
  //       name: "wjsj_wjgzt",
  //       component: () => import("@/views/wjsj/wjgzt/index.vue"),
  //       meta: { title: "文件工作台" },
  //     },
  //     {
  //       path: "wfqd",
  //       name: "wjsj_wfqd_main",
  //       component: MainDefaultLayout,
  //       meta: { title: "我发起的" },
  //       children: [
  //         {
  //           path: "",
  //           name: "wjsj_wfqd",
  //           component: () => import("@/views/wjsj/wfqd/index.vue"),
  //           meta: { title: "我发起的" },
  //           props: true,
  //         },
  //         {
  //           path: "wjxq/:id",
  //           hidden: true,
  //           name: "wjsj_wfqd_wjxq",
  //           component: () => import("@/views/wjsj/wfqd/wjxq/index.vue"),
  //           meta: { title: "文件详情" },
  //           props: true,
  //         },
  //       ],
  //     },
  //     {
  //       path: "wtjd",
  //       name: "wjsj_wtjd_main",
  //       component: MainDefaultLayout,
  //       meta: { title: "我提交的" },
  //       children: [
  //         {
  //           path: "",
  //           name: "wjsj_wtjd",
  //           component: () => import("@/views/wjsj/wtjd/index.vue"),
  //           meta: { title: "我提交的" },
  //           props: true,
  //         },
  //         {
  //           path: "wjxq/:id",
  //           hidden: true,
  //           name: "wjsj_wtjd_wjxq",
  //           component: () => import("@/views/wjsj/wtjd/wjxq/index.vue"),
  //           meta: { title: "文件详情" },
  //           props: true,
  //         },
  //       ],
  //     },
  //   ],
  // },
  {
    path: "/xmlxsb",
    name: "xmlxsb",
    component: AppLayout,
    meta: { title: "三重一大申报", icon: "el-icon-document" },
    redirect: "/xmlxsb/xmsq",
    children: [
      {
        path: "/xmlxsb/xmsq",
        name: "xmlxsb_xmsq_main",
        component: MainDefaultLayout,
        meta: { title: "项目申请" },
        children: [
          {
            path: "",
            name: "xmlxsb_xmsq",
            component: () => import("@/views/xmlxsb/xmsq/index.vue"),
            meta: { title: "项目申请" },
            props: true,
          },
          {
            path: "/xmlxsb/xmsq/xq/:id",
            hidden: true,
            name: "xmlxsb_xmsq_xq",
            component: () => import("@/views/xmlxsb/xmsq/xq/index.vue"),
            meta: { title: "项目详情" },
            props: true,
          },
          {
            path: "/xmlxsb/xmsq/dybb/:id",
            hidden: true,
            name: "xmlxsb_xmsq_dybb",
            component: () => import("@/views/xmlxsb/xmsq/dybb/index.vue"),
            meta: { title: "打印报表" },
            props: true,
          },
        ],
      },

      // {
      //   path: "/xmlxsb/xmsq",
      //   name: "xmlxsb_xmsq",
      //   component: () => import("@/views/xmlxsb/xmsq/index.vue"),
      //   meta: { title: "项目申请" },
      // },
      {
        path: "/xmlxsb/xmds",
        name: "xmlxsb_xmds",
        component: () => import("@/views/xmlxsb/xmds/index.vue"),
        meta: { title: "项目待审" },
      },
      {
        path: "/xmlxsb/xmhp",
        name: "xmlxsb_xmhp",
        component: () => import("@/views/xmlxsb/xmhp/index.vue"),
        meta: { title: "项目获批" },
      },
      {
        path: "/xmlxsb/bbtj",
        name: "xmlxsb_bbtj_main",
        component: MainDefaultLayout,
        meta: { title: "报表统计" },
        children: [
          {
            path: "",
            name: "xmlxsb_bbtj",
            component: () => import("@/views/xmlxsb/bbtj/index.vue"),
            meta: { title: "报表统计" },
            props: true,
          },
          {
            path: "/xmlxsb/bbtj/xq/:id",
            hidden: true,
            name: "xmlxsb_bbtj_xq",
            component: () => import("@/views/xmlxsb/bbtj/xq/index.vue"),
            meta: { title: "报表详情" },
            props: true,
          },
        ],
      },
      {
        path: "/xmlxsb/xmlb",
        name: "xmlxsb_xmlb",
        component: () => import("@/views/xmlxsb/xmlb/index.vue"),
        meta: { title: "项目类别" },
      },
      // {
      //   path: "/xmlxsb/bbtj",
      //   name: "xmlxsb_bbtj",
      //   component: () => import("@/views/xmlxsb/bbtj/index.vue"),
      //   meta: { title: "报表统计" },
      // },
      {
        path: "/xmlxsb/lcgl",
        name: "xmlxsb_lcgl",
        component: () => import("@/views/xmlxsb/lcgl/index.vue"),
        meta: { title: "流程管理" },
      },
    ],
  },
  {
    path: "/jsld",
    component: AppLayout,
    redirect: "/jsld/xxbwrygl",
    name: "jsld",
    meta: { title: "教师流动管理", icon: "el-icon-document" },
    children: [
      {
        path: "xxbwrygl",
        name: "jsld_xxbwrygl_main",
        component: MainDefaultLayout,
        meta: { title: "学校编外人员管理" },
        children: [
          {
            path: "",
            name: "jsld_xxbwrygl",
            component: () => import("@/views/jsld/xxbwrygl/index.vue"),
            meta: { title: "学校编外人员管理" },
            props: true,
          },
          {
            path: "detail/:id",
            hidden: true,
            name: "jsld_xxbwrygl_detail",
            component: () => import("@/views/jsld/xxbwrygl/detail/index.vue"),
            meta: { title: "详情" },
            props: true,
          },
        ],
      },
      {
        path: "ndkhhz",
        name: "jsld_ndkhhz",
        component: () => import("@/views/jsld/ndkhhz/index.vue"),
        meta: { title: "年度考核汇总" },
      },

      {
        path: "myjsqkhz",
        name: "jsld_myjsqkhz",
        component: () => import("@/views/jsld/myjsqkhz/index.vue"),
        meta: { title: "名优教师情况汇总" },
      },

      {
        path: "txjstx",
        name: "jsld_txjstx",
        component: () => import("@/views/jsld/txjstx/index.vue"),
        meta: { title: "退休教师提醒" },
      },
      {
        path: "myjsjxkh",
        name: "jsld_myjsjxkh",
        component: MainDefaultLayout,
        meta: { title: "名优教师绩效考核" },
        children: [
          {
            path: "khhz",
            name: "myjsjxkh_khhz",
            component: MainDefaultLayout,
            props: true,
            meta: { title: "考核汇总" },
            children: [
              {
                path: "",
                name: "jsld_myjsjxkh_khhz",
                component: () => import("@/views/jsld/myjsjxkh/khhz/index.vue"),
                meta: { title: "考核汇总" },
                props: true,
              },
              {
                path: "detail/:id",
                hidden: true,
                name: "jsld_myjsjxkh_khhz_detail",
                component: () =>
                  import("@/views/jsld/myjsjxkh/khhz/detail/index.vue"),
                meta: { title: "详情" },
                props: true,
              },
            ],
          },
          {
            path: "wshd",
            name: "myjsjxkh_wshd",
            component: MainDefaultLayout,
            meta: { title: "我审核的" },
            props: true,
            children: [
              {
                path: "",
                name: "jsld_myjsjxkh_wshd",
                component: () => import("@/views/jsld/myjsjxkh/wshd/index.vue"),
                meta: { title: "我审核的" },
                props: true,
              },
              {
                path: "detail/:id",
                hidden: true,
                name: "jsld_myjsjxkh_wshd_detail",
                component: () =>
                  import("@/views/jsld/myjsjxkh/wshd/detail/index.vue"),
                meta: { title: "详情" },
                props: true,
              },
            ],
          },
          {
            path: "lbgl",
            name: "myjsjxkh_lbgl",
            component: MainDefaultLayout,
            props: true,
            meta: { title: "类别管理" },
            children: [
              {
                path: "",
                name: "jsld_myjsjxkh_lbgl_list",
                component: () => import("@/views/jsld/myjsjxkh/lbgl/index.vue"),
                meta: { title: "类别管理" },
                props: true,
              },
              {
                path: "detail/:id",
                name: "jsld_myjsjxkh_lbgl_detail",
                component: () => import("@/views/jsld/myjsjxkh/lbgl/edit.vue"),
                meta: { title: "详情" },
                props: true,
                hidden: true,
              },
            ],
          },
        ],
      },
      // {
      //   path: "bbtj",
      //   component: MainDefaultLayout,
      //   meta: { title: "报表统计" },
      //   children: [
      //     {
      //       path: "",
      //       name: "jsld_bbtj",
      //       component: () => import("@/views/jsld/bbtj/index.vue"),
      //       meta: { title: "报表统计" },
      //       props: true,
      //     },
      //     {
      //       path: "bbxq/:id",
      //       hidden: true,
      //       name: "jsld_bbtj_bbxq",
      //       component: () => import("@/views/jsld/bbtj/bbxq/index.vue"),
      //       meta: { title: "报表详情" },
      //       props: true,
      //     },
      //   ],
      // },
    ],
  },
  // {
  //   path: "/kylxsb",
  //   component: AppLayout,
  //   redirect: "/kylxsb/kylx",
  //   name: "kylxsb",
  //   meta: { title: "科研立项申报", icon: "el-icon-document" },
  //   children: [
  //     {
  //       path: "kylx",
  //       name: 'kylx_main',
  //       component: () => import("@/views/kylxsb/kylx/index.vue"),
  //       meta: { title: "科研立项" },
  //     },
  //     {
  //       path: "kylb",
  //       name: 'kylb_main',
  //       component: () => import("@/views/kylxsb/kylb/index.vue"),
  //       meta: { title: "科研类别" },
  //     },
  //     {
  //       path: "kyhd",
  //       name: 'kyhd_main',
  //       component: () => import("@/views/kylxsb/kyhd/index.vue"),
  //       meta: { title: "科研活动" },
  //     },
  //     {
  //       path: "bbtj",
  //       name: "kylxsb_bbtj_main",
  //       component: MainDefaultLayout,
  //       children: [
  //         {
  //           path: "",
  //           name: "kylxsb_bbtj",
  //           component: () => import("@/views/kylxsb/bbtj/index.vue"),
  //           meta: { title: "报表统计" },
  //           props: true,
  //         },
  //         {
  //           path: "bbxq/:id",
  //           hidden: true,
  //           name: "kylxsb_bbtj_bbxq",
  //           component: () => import("@/views/kylxsb/bbtj/bbxq/index.vue"),
  //           meta: { title: "报表详情" },
  //           props: true,
  //         },
  //       ],
  //     },
  //   ],
  // },
  // {
  //   path: "/jxdydj",
  //   component: AppLayout,
  //   redirect: "/jxdydj/jyxxtz",
  //   name: "jxdydj",
  //   meta: { title: "教学调研登记", icon: "el-icon-document" },
  //   children: [
  //     {
  //       path: "jyxxtz",
  //       name: 'jyxxtz_main',
  //       component: () => import("@/views/jxdydj/jyxxtz/index.vue"),
  //       meta: { title: "教研消息通知" },
  //     },
  //     {
  //       path: "dyjg",
  //       name: 'dyjg_main',
  //       component: () => import("@/views/jxdydj/dyjg/index.vue"),
  //       meta: { title: "调研结果" },
  //     },
  //     {
  //       path: "bbtj",
  //       name: "jxdydj_bbtj_main",
  //       component: MainDefaultLayout,
  //       children: [
  //         {
  //           path: "",
  //           name: "jxdydj_bbtj",
  //           component: () => import("@/views/jxdydj/bbtj/index.vue"),
  //           meta: { title: "报表统计" },
  //           props: true,
  //         },
  //         {
  //           path: "bbxq/:id",
  //           hidden: true,
  //           name: "jxdydj_bbtj_bbxq",
  //           component: () => import("@/views/jxdydj/bbtj/bbxq/index.vue"),
  //           meta: { title: "报表详情" },
  //           props: true,
  //         },
  //       ],
  //     },
  //   ],
  // },
  // {
  //   path: "/cfbtsb",
  //   component: AppLayout,
  //   redirect: "/cfbtsb/gzt",
  //   name: "cfbtsb",
  //   meta: { title: "餐费补贴申报", icon: "el-icon-document" },
  //   children: [
  //     {
  //       path: "gzt",
  //       name: 'cfbtsb_gzt',
  //       component: () => import("@/views/cfbtsb/gzt/index.vue"),
  //       meta: { title: "工作台" },
  //     },
  //     {
  //       path: "btlb",
  //       name: 'cfbtsb_btlb',
  //       component: () => import("@/views/cfbtsb/btlb/index.vue"),
  //       meta: { title: "补贴列表" },
  //     },
  //     {
  //       path: "shsz",
  //       name: 'cfbtsb_shsz',
  //       component: () => import("@/views/cfbtsb/shsz/index.vue"),
  //       meta: { title: "审核设置" },
  //     },
  //     {
  //       path: "bbtj",
  //       name: "cfbtsb_bbtj_main",
  //       component: MainDefaultLayout,
  //       children: [
  //         {
  //           path: "",
  //           name: "cfbtsb_bbtj",
  //           component: () => import("@/views/cfbtsb/bbtj/index.vue"),
  //           meta: { title: "报表统计" },
  //           props: true,
  //         },
  //         {
  //           path: "bbxq/:id",
  //           hidden: true,
  //           name: "cfbtsb_bbtj_bbxq",
  //           component: () => import("@/views/cfbtsb/bbtj/bbxq/index.vue"),
  //           meta: { title: "报表详情" },
  //         },
  //       ],
  //     },
  //   ],
  // },
  {
    path: "/jbcfbt",
    component: AppLayout,
    redirect: "/jbcfbt/gzt",
    name: "jbcfbt",
    meta: { title: "加班餐费补贴", icon: "el-icon-document" },
    children: [
      {
        path: "gzt",
        name: "jbcfbt_gzt",
        component: () => import("@/views/jbcfbt/gzt/index.vue"),
        meta: { title: "工作台" },
      },
      {
        path: "gzt_wdsh",
        hidden: true,
        name: "gzt_wdsh",
        component: () => import("@/views/jbcfbt/gzt/wdsh/index.vue"),
        meta: { title: "我的审核" },
      },
      {
        path: "gzt_wdsq",
        hidden: true,
        name: "gzt_wdsq",
        component: () => import("@/views/jbcfbt/gzt/wdsq/index.vue"),
        meta: { title: "我的申请" },
      },
      {
        path: "jblx",
        name: "jbcfbt_jblx",
        component: () => import("@/views/jbcfbt/jblx/index.vue"),
        meta: { title: "加班类型" },
      },
      {
        path: "lxjt",
        name: "jbcfbt_lxjt",
        component: () => import("@/views/jbcfbt/lxjt/index.vue"),
        meta: { title: "类型津贴" },
      },
      {
        path: "bbtj",
        name: "jbcfbt_bbtj_main",
        component: MainDefaultLayout,
        children: [
          {
            path: "",
            name: "jbcfbt_bbtj",
            component: () => import("@/views/jbcfbt/bbtj/index.vue"),
            meta: { title: "报表统计" },
            props: true,
          },
          {
            path: "bbxq1/:id",
            hidden: true,
            name: "cfbtsb_bbtj_bbxq1",
            component: () => import("@/views/cfbtsb/bbtj/bbxq/index.vue"),
            meta: { title: "报表详情" },
          },
        ],
      },
    ],
  },
  // {
  //   path: "/jysbys",
  //   component: AppLayout,
  //   redirect: "/jysbys/sbys",
  //   name: "jysbys",
  //   meta: { title: "教育设备预算", icon: "el-icon-document" },
  //   children: [
  //     {
  //       path: "sbys",
  //       name: 'jysbys_sbys',
  //       component: () => import("@/views/jysbys/sbys/index.vue"),
  //       meta: { title: "设备预算" },
  //     },
  //     {
  //       path: "sblxgl",
  //       name: 'jysbys_sblxgl',
  //       component: () => import("@/views/jysbys/sblxgl/index.vue"),
  //       meta: { title: "设备类别管理" },
  //     },
  //     {
  //       path: "bbtj",
  //       name: "jysbys_bbtj_main",
  //       component: MainDefaultLayout,
  //       children: [
  //         {
  //           path: "",
  //           name: "jysbys_bbtj",
  //           component: () => import("@/views/jysbys/bbtj/index.vue"),
  //           meta: { title: "报表统计" },
  //           props: true,
  //         },
  //         {
  //           path: "bbxq/:id",
  //           hidden: true,
  //           name: "jysbys_bbtj_bbxq",
  //           component: () => import("@/views/jysbys/bbtj/bbxq/index.vue"),
  //           meta: { title: "报表详情" },
  //           props: true,
  //         },
  //       ],
  //     },
  //   ],
  // },
  // {
  //   path: "/xqyctj",
  //   component: AppLayout,
  //   redirect: "/xqyctj/wcyd",
  //   name: "xqyctj",
  //   meta: { title: "需求预测统计", icon: "el-icon-document" },
  //   children: [
  //     {
  //       path: "wcyd",
  //       name: 'xqyctj_wcyd',
  //       component: () => import("@/views/xqyctj/wcyd/index.vue"),
  //       meta: { title: "我参与的" },
  //     },
  //     {
  //       path: "wfqd",
  //       name: 'xqyctj_wfqd',
  //       component: () => import("@/views/xqyctj/wfqd/index.vue"),
  //       meta: { title: "我发起的" },
  //     },
  //     {
  //       path: "bbtj",
  //       name: "xqyctj_bbtj_main",
  //       component: MainDefaultLayout,
  //       children: [
  //         {
  //           path: "",
  //           name: "xqyctj_bbtj",
  //           component: () => import("@/views/xqyctj/bbtj/index.vue"),
  //           meta: { title: "报表统计" },
  //           props: true,
  //         },
  //         {
  //           path: "bbxq/:id",
  //           hidden: true,
  //           name: "xqyctj_bbtj_bbxq",
  //           component: () => import("@/views/xqyctj/bbtj/bbxq/index.vue"),
  //           meta: { title: "报表详情" },
  //           props: true,
  //         },
  //       ],
  //     },
  //   ],
  // },
  {
    path: "/jkdagl",
    component: AppLayout,
    redirect: "/jkdngl/sjgl",
    name: "jkdagl",
    meta: { title: "健康档案管理", icon: "el-icon-document" },
    children: [
      {
        path: "sjgl",
        name: "jkdagl_sjgl",
        component: () => import("@/views/jkdagl/sjgl/index.vue"),
        meta: { title: "数据概览" },
      },
      {
        path: "xstzjkda",
        name: "jkdagl_xstzjkda",
        component: MainDefaultLayout,
        meta: { title: "学生体质健康档案" },
        children: [
          {
            path: "",
            name: "jkdagl_xstzjkda_index",
            component: () => import("@/views/jkdagl/xstzjkda/index.vue"),
            meta: { title: "学生体质健康档案" },
          },
          {
            path: "detail/:id",
            hidden: true,
            name: "xstzjkda_detail",
            component: () =>
              import("@/views/jkdagl/xstzjkda/detail/detail.vue"),
            meta: { title: "详情" },
            props: true,
          },
        ],
      },
      {
        path: "bbtj",
        name: "jkdagl_bbtj_main",
        component: MainDefaultLayout,
        children: [
          {
            path: "",
            name: "jkdagl_bbtj",
            component: () => import("@/views/jkdagl/bbtj/index.vue"),
            meta: { title: "报表统计" },
            props: true,
          },
          {
            path: "",
            name: "jkdagl_bbtj_detail",
            component: MainDefaultLayout,
            meta: { title: "报表详情" },
            hidden: true,
            children: [
              {
                path: "bbtj_detail/:jkbb_xq/:jkbb_bbmc",
                name: "bbtj_detail",
                component: () => import("@/views/jkdagl/bbtj/detail.vue"),
                meta: { title: "报表详情" },
              },
              {
                path: "bbtj_bbxq/:id",
                name: "bbtj_bbxq",
                component: () => import("@/views/jkdagl/bbtj/bbxq/index.vue"),
                meta: { title: "详情" },
                hidden: true,
              },
            ],
          },
        ],
      },
    ],
  },
  {
    path: "/qjygl",
    component: AppLayout,
    redirect: "/qjygl/zyxxlb",
    name: "qjygl",
    meta: { title: "区教研管理", icon: "el-icon-document" },
    children: [
      {
        path: "zyxxlb",
        name: "qjygl_zyxxlb",
        component: MainDefaultLayout,
        meta: { title: "资源信息列表" },
        children: [
          {
            path: "",
            name: "qjygl_zyxxlb_index",
            component: () => import("@/views/qjygl/zyxxlb/index.vue"),
            meta: { title: "资源信息列表" },
          },
          {
            path: "detail/:id",
            hidden: true,
            name: "zyxxlb_detail",
            component: () => import("@/views/qjygl/zyxxlb/detail/detail.vue"),
            meta: { title: "详情" },
            props: true,
          },
        ],
      },

      {
        path: "zylbgl",
        name: "qjygl_zylbgl",
        component: () => import("@/views/qjygl/zylbgl/index.vue"),
        meta: { title: "资源类别管理" },
      },
      {
        path: "zygx",
        name: "qjygl_zygx",
        component: MainDefaultLayout,
        meta: { title: "资源共享" },
        children: [
          {
            path: "zygx",
            name: "qjygl_zygx_index",
            component: () => import("@/views/qjygl/zygx/index.vue"),
            meta: { title: "资源共享" },
          },
          {
            path: "detail/:id",
            hidden: true,
            name: "zygx_detail",
            component: () => import("@/views/qjygl/zygx/detail/detail.vue"),
            meta: { title: "详情" },
            props: true,
          },
        ],
      },
    ],
  },
  {
    path: "/dddx",
    component: AppLayout,
    redirect: "/dddx/ddrw",
    name: "dddx",
    meta: { title: "督导督学系统", icon: "el-icon-document" },
    children: [
      // {
      //   path: "ddrw",
      //   name: "dddx-ddrw",
      //   component: () => import("@/views/dddx/ddrw/index.vue"),
      //   redirect: "/dddx/ddrw/ddrw-main",
      //   meta: { title: "督导任务" },
      //   children: [
      //     {
      //       hidden: true,
      //       path: "ddrw-main",
      //       name: "dddx-ddrw-main",
      //       component: () => import("@/views/dddx/ddrw/components/ddrw.vue"),
      //       meta: { title: "" },
      //     },
      //     {
      //       hidden: true,
      //       path: "ddrw-tjzb/:id",
      //       name: "dddx-ddrw-tjzb",
      //       component: () => import("@/views/dddx/ddrw/components/tjzb.vue"),
      //       meta: { title: "添加指标" },
      //     },
      //     {
      //       hidden: true,
      //       path: "ddrw-detail/:id",
      //       name: "dddx-ddrw-detail",
      //       component: () => import("@/views/dddx/ddrw/components/detail.vue"),
      //       meta: { title: "详情" },
      //     },
      //   ],
      // },

      {
        path: "ddrw",
        name: "dddx-ddrw",
        component: () => import("@/views/dddx/ddrw/index.vue"),
        redirect: "/dddx/ddrw/ddrw-main",
        meta: { title: "督导任务" },
        children: [
          {
            hidden: true,
            path: "ddrw-main",
            name: "dddx-ddrw-main",
            component: () => import("@/views/dddx/ddrw/components/ddrw.vue"),
            meta: { title: "" },
          },
          {
            hidden: true,
            path: "ddrw-tjzb/:id",
            name: "dddx-ddrw-tjzb",
            component: () => import("@/views/dddx/ddrw/components/tjzb.vue"),
            meta: { title: "添加指标" },
          },
          {
            hidden: true,
            path: "ddrw-detail",
            name: "dddx-ddrw-detail",
            component: () =>
              import("@/views/dddx/ddrw/components/detail/index.vue"),
            meta: { title: "" },
            children: [
              {
                hidden: true,
                path: "ddrw-detail-index/:id",
                name: "dddx-ddrw-detail-index",
                component: () =>
                  import("@/views/dddx/ddrw/components/detail/ddrw-detail.vue"),
                meta: { title: "详情" },
              },
              {
                hidden: true,
                path: "indicator-detail/:id/:xfId",
                name: "dddx-ddrw-indicator-detail",
                component: () =>
                  import(
                    "@/views/dddx/ddrw/components/detail/indicator-detail.vue"
                  ),
                meta: { title: "详情" },
              },
              {
                hidden: true,
                path: "noindicator-detail/:id/:xfId",
                name: "dddx-ddrw-noindicator-detail",
                component: () =>
                  import(
                    "@/views/dddx/ddrw/components/detail/noindicator-detail.vue"
                  ),
                meta: { title: "上传" },
              },
            ],
          },
        ],
      },

      {
        path: "ddrwfk",
        name: "dddx_ddrwfk_main",
        component: MainDefaultLayout,
        meta: { title: "督导任务反馈" },
        children: [
          {
            path: "",
            name: "dddx_ddrwfk",
            component: () => import("@/views/dddx/ddrwfk/index.vue"),
            meta: { title: "督导任务反馈" },
          },
          {
            path: "detail/:id",
            name: "ddrwfk_detail",
            hidden: true,
            component: () => import("@/views/dddx/ddrwfk/detail/index.vue"),
            meta: { title: "反馈详情" },
          },
        ],
      },
      {
        path: "ddzg",
        name: "dddx_ddzg_main",
        component: MainDefaultLayout,
        meta: { title: "督导整改" },
        children: [
          {
            path: "",
            name: "dddx_ddzg",
            meta: { title: "督导整改" },
            component: () => import("@/views/dddx/ddzg/index.vue"),
          },
          {
            path: "ddzg_detail/:id",
            name: "ddzg_detail",
            hidden: true,
            component: () => import("@/views/dddx/ddzg/detail.vue"),
            meta: { title: "详情" },
          },
        ],
      },
      {
        path: "ddpx",
        name: "dddx_ddpx_main",
        component: MainDefaultLayout,
        meta: { title: "督导培训" },
        children: [
          {
            path: "",
            name: "dddx_ddpx",
            meta: { title: "督导培训" },
            component: () => import("@/views/dddx/ddpx/index.vue"),
          },
          {
            path: "ddpx_detail/:id",
            name: "ddpx_detail",
            hidden: true,
            component: () => import("@/views/dddx/ddpx/detail.vue"),
            meta: { title: "详情" },
          },
        ],
      },
      // {
      //     path: "",
      //     name: "ddzs_index",
      //     component: () => import("@/views/dddx/ddzs/index.vue"),
      //     meta: { title: "督导综述" },
      // },
      // {
      //   path: "jyjdetail/:id",
      //   hidden: true,
      //   name: "dddx_jyj_detail",
      //   component: () => import("@/views/dddx/ddzs/detail/jyjDetail.vue"),
      //   meta: { title: "详情" },
      //   props: true,
      // },
      // {
      //   path: "yzbdetail/:id",
      //   hidden: true,
      //   name: "dddx_xxyzb_detail",
      //   component: () => import("@/views/dddx/ddzs/detail/xxyzbDetail.vue"),
      //   meta: { title: "详情" },
      //   props: true,
      // },
      // {
      //   path: "wzbdetail/:id",
      //   hidden: true,
      //   name: "dddx_xxwzb_detail",
      //   component: () => import("@/views/dddx/ddzs/detail/xxwzbDetail.vue"),
      //   meta: { title: "详情" },
      //   props: true,
      // },
      // {
      //   path: "ddgzjh/:id",
      //   name: "dddx_ddgzjh",
      //   component: () => import("@/views/dddx/ddgzjh/index.vue"),
      //   meta: { title: "督导工作计划" },
      //   props: true,
      // },
      // {
      //   path: "ddgzjl",
      //   name: "dddx_ddgzjl",
      //   component: () => import("@/views/dddx/ddgzjl/index.vue"),
      //   meta: { title: "督导工作记录" },
      //   props: true,
      // },
      // {
      //   path: "ddqkfk",
      //   name: 'dddx_ddqkfk',
      //   component: () => import("@/views/dddx/ddqkfk/index.vue"),
      //   meta: { title: "督导情况反馈" },
      // },
      {
        path: "ddzs",
        name: "ddzs",
        component: MainDefaultLayout,
        meta: { title: "督导综述" },
        children: [
          {
            path: "",
            name: "ddzs_index",
            component: () => import("@/views/dddx/ddzs/index.vue"),
            meta: { title: "督导综述" },
          },
          {
            path: "jyjdetail/:id",
            hidden: true,
            name: "dddx_jyj_detail",
            component: () => import("@/views/dddx/ddzs/detail/jyjDetail.vue"),
            meta: { title: "详情" },
            props: true,
          },
          {
            path: "jyjwzbdetail/:id",
            hidden: true,
            name: "dddx_jyjwzb_detail",
            component: () => import("@/views/dddx/ddzs/detail/jyjwzbDetail.vue"),
            meta: { title: "详情" },
            props: true,
          },
          {
            path: "xxyzbdetail/:id",
            hidden: true,
            name: "dddx_xxyzb_detail",
            component: () => import("@/views/dddx/ddzs/detail/xxyzbDetail.vue"),
            meta: { title: "详情" },
            props: true,
          },
          {
            path: "xxwzbdetail/:id",
            hidden: true,
            name: "dddx_xxwzb_detail",
            component: () => import("@/views/dddx/ddzs/detail/xxwzbDetail.vue"),
            meta: { title: "详情" },
            props: true,
          },
        ],
      },
      {
        path: "xnddpd",
        name: "dddx-xnddpd",
        component: () => import("@/views/dddx/xnddpd/index.vue"),
        meta: { title: "学年督导评定" },
      },
      {
        path: "bbtj",
        name: "dddx-bbtj",
        component: () => import("@/views/dddx/bbtj/index.vue"),
        redirect: "/dddx/bbtj/bbtj-main",
        meta: { title: "报表统计" },
        children: [
          {
            hidden: true,
            path: "bbtj-main",
            name: "dddx-bbtj-main",
            component: () => import("@/views/dddx/bbtj/components/bbtj.vue"),
            meta: {
              title: "",
              checkList: ["show", "add", "edit", "delete", "detail", "export"],
            },
          },
          {
            hidden: true,
            path: "bbtj-detail/:id",
            name: "dddx-bbtj-detail",
            component: () => import("@/views/dddx/bbtj/components/detail.vue"),
            meta: {
              title: "详情",
              checkList: ["show", "edit", "export"],
            },
          },
        ],
      },
      // {
      //   path: "gzzj",
      //   name: "gzzj",
      //   component: () => import("@/views/dddx/gzzj/index.vue"),
      //   meta: { title: "工作总结" },
      // },
    ],
  },
  // {
  //   path: "/pjkhxt",
  //   component: AppLayout,
  //   redirect: "/pjkhxt/sjgl",
  //   name: "pjkhxt",
  //   meta: { title: "评价考核系统", icon: "el-icon-document" },
  //   children: [
  //     {
  //       path: "sjgl",
  //       name: 'pjkhxt_sjgl',
  //       component: () => import("@/views/pjkhxt/sjgl/index.vue"),
  //       meta: { title: "数据概览" },
  //     },
  //     {
  //       path: "pjkh",
  //       name: 'pjkhxt_pjkh',
  //       component: () => import("@/views/pjkhxt/pjkh/index.vue"),
  //       meta: { title: "评价考核" },
  //     },
  //   ],
  // },
  {
    path: "/zzjgyqx",
    component: AppLayout,
    name: "zzjgyqx",
    meta: { title: "", icon: "el-icon-document" },
    children: [
      {
        path: "",
        name: "zzjgyqx_main",
        component: () => import("@/views/zzjgyqx/index.vue"),
        meta: { title: "组织机构与权限" },
      },
    ],
  },
  {
    path: "/xxzx",
    name: "xxzx_main",
    component: AppLayout,
    hidden: true,
    children: [
      {
        path: "",
        name: "xxzx",
        component: () => import("@/views/xxzx/index.vue"),
        meta: { title: "消息中心" },
      },
    ],
  },
  {
    path: "/sbcgsq",
    component: AppLayout,
    redirect: "/sbcgsq/cgxmk",
    name: "sbcgsq",
    meta: { title: "设备采购申请", icon: "el-icon-document" },
    children: [
      {
        path: "sbys",
        name: "sbcgsq_sbys",
        component: MainDefaultLayout,
        meta: { title: "设备预算" },
        children: [
          {
            path: "",
            name: "sbys",
            component: () => import("@/views/sbcgsq/sbys/index.vue"),
            meta: {
              title: "设备预算",
              checkList: ["show", "add", "edit", "delete", "detail"],
            },
            props: true,
          },
          {
            path: "detail/:id",
            hidden: true,
            name: "sbys_detail",
            component: () => import("@/views/sbcgsq/sbys/detail.vue"),
            meta: {
              title: "详情",
              checkList: ["show"],
            },
            // props: true,
          },
        ],
      },
      {
        path: "cgxmk",
        name: "cgxmk",
        component: () => import("@/views/sbcgsq/cgxmk/index.vue"),
        meta: {
          title: "设备项目库",
          checkList: ["show", "detail"],
        },
      },
      {
        path: "sblxgl",
        name: "sblxgl",
        component: () => import("@/views/sbcgsq/sblxgl/index.vue"),
        meta: {
          title: "设备类型管理",
          checkList: ["show", "add", "edit", "delete"],
        },
      },
      {
        path: "/sbcgsq/bbtj",
        name: "sbcgsq_bbtj_main",
        component: MainDefaultLayout,
        meta: { title: "报表统计" },
        children: [
          {
            path: "",
            name: "sbcgsq_bbtj",
            component: () => import("@/views/sbcgsq/bbtj/index.vue"),
            meta: {
              title: "报表统计",
              checkList: ["show", "add", "delete", "detail", "export"],
            },
            props: true,
          },
          {
            path: "bbxq/:id",
            hidden: true,
            name: "sbcgsq_bbtj_bbxq",
            component: () => import("@/views/sbcgsq/bbtj/detail/detail.vue"),
            meta: {
              title: "报表详情",
              checkList: ["show", "edit", "export"],
            },
            props: true,
          },
        ],
      },
      {
        path: "lcgl",
        name: "lcgl_main",
        component: MainDefaultLayout,
        meta: { title: "流程管理" },
        children: [
          {
            path: "",
            name: "lcgl",
            component: () => import("@/views/sbcgsq/lcgl/index.vue"),
            meta: {
              title: "流程管理",
              checkList: ["show", "add", "edit", "detail"],
            },
            props: true,
          },
          {
            path: "detail/:id",
            hidden: true,
            name: "lcgl_detail",
            component: () => import("@/views/sbcgsq/lcgl/detail.vue"),
            meta: {
              title: "详情",
              checkList: ["show", "detail"],
            },
            props: true,
          },
        ],
      },
    ],
  },
  {
    path: "/hysydgl",
    component: AppLayout,
    redirect: "/hysydgl/hysyd",
    name: "hysydgl",
    meta: { title: "会议室预定管理", icon: "el-icon-document" },
    children: [
      {
        path: "hysyd",
        name: "hysydgl_hysyd",
        component: MainDefaultLayout,
        meta: { title: "会议室预定" },
        children: [
          {
            path: "",
            name: "hysyd",
            component: () => import("@/views/hysydgl/hysyd/index.vue"),
            meta: { title: "会议室预定" },
          },
          {
            path: "hysyd_detail/:yd_id",
            name: "hysyd_detail",
            hidden: true,
            meta: { title: "预定详情" },
            component: () => import("@/views/hysydgl/hysyd/detail.vue"),
          },
        ],
      },
      {
        path: "hyjy",
        name: "hyjy_main",
        component: MainDefaultLayout,
        meta: { title: "会议纪要" },
        children: [
          {
            path: "",
            name: "hyjy",
            component: () => import("@/views/hysydgl/hyjy/index.vue"),
            meta: { title: "会议纪要" },
          },
          {
            path: "hyjy_detail/:jy_id",
            name: "hyjy_detail",
            meta: { title: "详情" },
            hidden: true,
            component: () => import("@/views/hysydgl/hyjy/detail.vue"),
          },
        ],
      },

      {
        path: "hyjyk",
        name: "hyjyk_main",
        component: MainDefaultLayout,
        meta: { title: "会议纪要库" },
        children: [
          {
            path: "",
            name: "hyjyk",
            component: () => import("@/views/hysydgl/hyjyk/index.vue"),
            meta: { title: "会议纪要库" },
          },
          {
            path: "hyjyk_detail/:jy_id",
            name: "hyjyk_detail",
            meta: { title: "详情" },
            hidden: true,
            component: () => import("@/views/hysydgl/hyjyk/detail.vue"),
          },
        ],
      },
      {
        path: "hysgl",
        name: "hysgl",
        component: () => import("@/views/hysydgl/hysgl/index.vue"),
        meta: { title: "会议室管理" },
      },
      {
        path: "bbtj",
        name: "hysyd_bbtj_main",
        component: MainDefaultLayout,
        meta: { title: "报表统计" },
        children: [
          {
            path: "",
            name: "hysyd_bbtj",
            component: () => import("@/views/hysydgl/bbtj/index.vue"),
            meta: { title: "报表统计" },
            props: true,
          },
          {
            path: "bbxq/:bb_id",
            hidden: true,
            name: "hysyd_bbtj_bbxq",
            component: () => import("@/views/hysydgl/bbtj/detail.vue"),
            meta: { title: "报表详情" },
            props: true,
          },
        ],
      },
    ],
  },
  {
    path: "/xmgl",
    component: AppLayout,
    redirect: "/xmgl/xmgkt/xmgkt-main",
    name: "xmgl",
    meta: {
      title: "项目管理",
      icon: "el-icon-document",
    },
    children: [
      {
        path: "xmgkt",
        name: "xmgl-xmgkt",
        component: () => import("@/views/xmgl/xmgkt/index.vue"),
        redirect: "/xmgl/xmgkt/xmgkt-main",
        meta: { title: "项目管控台" },
        children: [
          {
            hidden: true,
            path: "xmgkt-main",
            name: "xmgl-xmgkt-main",
            component: () => import("@/views/xmgl/xmgkt/components/xmgkt.vue"),
            meta: {
              title: "",
              checkList: ["show", "add", "manage", "detail"],
            },
          },
          {
            hidden: true,
            path: "xmgkt-manage/:id",
            name: "xmgl-xmgkt-manage",
            component: () => import("@/views/xmgl/xmgkt/components/manage.vue"),
            meta: {
              title: "管理",
              checkList: ["show"],
            },
          },
        ],
      },
      {
        path: "xmmbk",
        name: "xmgl-xmmbk",
        component: () => import("@/views/xmgl/xmmbk/index.vue"),
        meta: {
          title: "项目模板库",
          checkList: ["show", "add", "edit", "delete", "detail"],
        },
      },
      {
        path: "xmzlk",
        name: "xmgl-xmzlk",
        component: () => import("@/views/xmgl/xmzlk/index.vue"),
        meta: {
          title: "项目资料库",
          checkList: ["show", "detail"],
        },
      },
      {
        path: "xmlcgl",
        name: "xmgl-xmlcgl",
        component: () => import("@/views/xmgl/xmlcgl/index.vue"),
        meta: {
          title: "项目流程管理",
          checkList: ["show", "add", "edit", "delete", "detail"],
        },
      },
      {
        path: "bbtj",
        name: "xmgl-bbtj",
        component: () => import("@/views/xmgl/bbtj/index.vue"),
        redirect: "/xmgl/bbtj/bbtj-main",
        meta: { title: "报表统计" },
        children: [
          {
            hidden: true,
            path: "bbtj-main",
            name: "xmgl-bbtj-main",
            component: () => import("@/views/xmgl/bbtj/components/bbtj.vue"),
            meta: {
              title: "",
              checkList: ["show", "add", "edit", "delete", "detail", "export"],
            },
          },
          {
            hidden: true,
            path: "bbtj-detail/:id",
            name: "xmgl-bbtj-detail",
            component: () => import("@/views/xmgl/bbtj/components/detail.vue"),
            meta: {
              title: "详情",
              checkList: ["show", "edit", "export"],
            },
          },
        ],
      },
      {
        path: "qxfp",
        name: "xmgl-qxfp",
        component: () => import("@/views/xmgl/qxfp/index.vue"),
        meta: {
          title: "权限分配",
          checkList: ["show"],
        },
      },
    ],
  },
  {
    path: "/xxrygl",
    component: AppLayout,
    // redirect: "/xxrygl",
    name: "xxrygl",
    meta: { title: "学校荣誉管理", icon: "el-icon-document" },
    children: [
      {
        path: "",
        name: "xxrygl_index",
        component: () => import("@/views/xxrygl/index.vue"),
        meta: { title: "学校荣誉管理" },
      },
      {
        path: "detail/:id",
        hidden: true,
        name: "xxrygl_detail",
        component: () => import("@/views/xxrygl/detail/detail.vue"),
        meta: { title: "详情" },
        props: true,
      },
    ],
  },
  {
    path: "/xsjsgl",
    component: AppLayout,
    redirect: "/xsjsgl/cjbs",
    name: "xsjsgl",
    meta: { title: "学生竞赛管理", icon: "el-icon-document" },
    children: [
      {
        path: "cjbs",
        name: "xsjsgl_cjbs",
        component: MainDefaultLayout,
        meta: { title: "创建比赛" },
        children: [
          {
            path: "",
            name: "xsjsgl_cjbs_index",
            component: () => import("@/views/xsjsgl/cjbs/index.vue"),
            meta: { title: "创建比赛" },
          },
          {
            path: "detail/:id",
            hidden: true,
            name: "cjbs_detail",
            component: () => import("@/views/xsjsgl/cjbs/detail/detail.vue"),
            meta: { title: "详情" },
            props: true,
          },
        ],
      },

      {
        path: "zsdy",
        name: "xsjsgl_zsdy",
        component: () => import("@/views/xsjsgl/zsdy/index.vue"),
        meta: { title: "证书打印" },
      },
      {
        path: "sjhz",
        name: "xsjsgl_sjhz",
        component: MainDefaultLayout,
        meta: { title: "数据汇总" },
        children: [
          {
            path: "sjhz",
            name: "xsjsgl_sjhz_index",
            component: () => import("@/views/xsjsgl/sjhz/index.vue"),
            meta: { title: "数据汇总" },
          },
          {
            path: "detail/:bb_id",
            hidden: true,
            name: "sjhz_detail",
            component: () => import("@/views/xsjsgl/sjhz/detail/detail.vue"),
            meta: { title: "报表详情" },
            props: true,
          },
        ],
      },

      {
        path: "rylb",
        name: "xsjsgl_rylb",
        component: () => import("@/views/xsjsgl/rylb/index.vue"),
        meta: { title: "荣誉列表" },
      },
    ],
  },
  ...xxgzjcRoutes,
  // 404 page must be placed at the end !!!
  { path: "*", redirect: "/404", hidden: true },
];

// function hasPermission(route, role) {
//   if (Array.isArray(route?.meta?.roles)) {
//     return route.meta.roles.includes(role);
//   } else {
//     return true;
//   }
// }

// function handleFilterRoutes(routes, role) {
//   const res = [];
//   routes.forEach((route) => {
//     const tmp = { ...route };
//     if (hasPermission(tmp, role)) {
//       if (tmp.children) {
//         tmp.children = handleFilterRoutes(tmp.children, role);
//       }
//       res.push(tmp);
//     }
//   });
//   return res;
// }

const _routes_ = await request({
  url: '/user/org_menu/setting_tyyx',
  data: {
    cpm_id: '80011',
    dept_id: userInfo.uo_id,
    keyname: "cmu_name"
  }
}).then(setting => {
  const requestRoutes = setting.data.cmu_name ?? {}
  // console.log('requestRoutes :>> ', requestRoutes);
  const requestRoutesKeyMap = {}
  Object.keys(requestRoutes).forEach(k => {
    const val = requestRoutes[k]
    if (val?.split(',')?.includes('show')) { requestRoutesKeyMap[k] = true }
  })
  // console.log('requestRoutesKeyMap :>> ', requestRoutesKeyMap);

  const filteredRoutesMap = {}
  // 维护路由树结构
  const RoutesTreeRelationMap = {}
  // const leafRouteMap: any = {}
  function initRoutesTreeRelation(routes, parent) {
    routes.forEach(route => {
      RoutesTreeRelationMap[route.name] = {
        parent,
        children: route.children === undefined ? undefined : initRoutesTreeRelation(route.children, [...parent, route.name])
      }
      if (route.children === undefined) {
        // leafRouteMap[route.name] = true
        if (requestRoutesKeyMap[route.name]) {
          filteredRoutesMap[route.name] = true
          RoutesTreeRelationMap[route.name].parent.forEach((k) => filteredRoutesMap[k] = true)
        }
      }
    })
  }
  initRoutesTreeRelation(allRoutes, [])
  // console.log('filteredRoutesMap :>> ', filteredRoutesMap);
  // export const RoutesCheck: any = {}
  function handleFilterRoutes(routes) {
    const res = []
    routes.forEach((route) => {
      const tmp = { ...route }
      // console.log('route :>> ', route, filteredRoutesMap[tmp.name]);

      if (filteredRoutesMap[tmp.name]) {
        if (!isAdmin) {
          tmp.meta.checkList = requestRoutes[tmp.name]?.split(',')
        }
        // RoutesCheck[tmp.name] = tmp.meta.checkList
        if (tmp.children) {
          tmp.children = handleFilterRoutes(tmp.children)
        }
        res.push(tmp)
      }
      // else if(!tmp?.meta?.checkList){
      //   if (tmp.children) {
      //     tmp.children = handleFilterRoutes(tmp.children)
      //   }
      //   res.push(tmp)
      // }
    })
    return res
  }

  const $routes = (isAdmin ? allRoutes : handleFilterRoutes(allRoutes)).sort((a, b) => a?.meta?.sort - b?.meta?.sort)
  let routes
  if ($routes?.length > 0)
    routes = $routes.concat([
      {
        path: "/404",
        component: () => import("@/views/404.vue"),
        hidden: true,
      },
      {
        path: "/",
        redirect: { name: $routes?.[0]?.name },
      }
    ])
  else {
    routes = [
      {
        path: '*',
        component: () => import('@/views/noSet.vue')
      }
    ]
  }
  sessionStorage.setItem('routes', JSON.stringify(routes))

  return routes
})

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: _routes_
    // routes: allRoutes,
  });

const router = createRouter();
//
// // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
// export function resetRouter() {
//     const newRouter = createRouter();
//     router.matcher = newRouter.matcher; // reset router
// }

export default router;

/*
=====================================================================================
=====================================================================================
*/

import getPageTitle from "@/utils/get-page-title";

router.beforeEach(async (to, from, next) => {
  document.title = getPageTitle(to.meta.title);
  console.groupCollapsed(
    `router ${from.meta.title || "新进入"} => ${to.meta.title}`
  );
  console.log("from :>> ", from);
  console.log("to :>> ", to);
  console.groupEnd();
  next();
});
