import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import useStore from "@/store";

export const Layout = () => import("@/layout/index.vue");
// const mode =
//     import.meta.env.VITE_APP_BASE_API == "https://api.xxx.com"
//         ? true
//         : false;
const roleId = localStorage.getItem("userInfo")
    ? JSON.parse(localStorage.getItem("userInfo") as string).roleId
    : "";
window.localStorage.setItem("roleId", roleId);
const mode = roleId == 70 ? true : false;
// 参数说明: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
// 静态路由
export const constantRoutes: Array<RouteRecordRaw> = [
    {
        path: "/redirect",
        component: Layout,
        meta: { hidden: true },
        children: [
            {
                path: "/redirect/:path(.*)",
                component: () => import("@/views/redirect/index.vue"),
            },
        ],
    },
    {
        path: "/login",
        component: () => import("@/views/login/index.vue"),
        meta: { hidden: true },
    },
    {
        path: "/:catchAll(.*)",
        component: () => import("@/views/error-page/404.vue"),
        meta: { hidden: true },
    },
    {
        path: "/",
        component: Layout,
        redirect: "/dashboard",
        meta: { title: "仪表盘", icon: "homepage", alwaysShow: true, hidden: mode, indexPath: "/dashboard" },
        children: [
            {
                path: "dashboard",
                component: () => import("@/views/dashboard/index.vue"),
                name: "Dashboard",
                meta: {
                    title: "仪表盘",
                    icon: "homepage",
                    affix: true,
                    hidden: true,
                },
            },
            {
                path: "platform-pnl",
                component: () => import("@/views/platform-pnl/index.vue"),
                name: "PlatformPnl",
                meta: {
                    title: "平台盈亏统计表",
                    icon: "chart",
                    hidden: mode,
                },
            },
            {
                path: "personalcenter",
                component: () =>
                    import("@/views/system/personalcenter/index.vue"),
                name: "Personalcenter",
                meta: { hidden: true, title: "个人中心", icon: "user" },
            },
            {
                path: "401",
                component: () => import("@/views/error-page/401.vue"),
                meta: { hidden: true },
            },
        ],
    },
];

// 动态路由
export const asyncRoutes: any = [
    {
        id: 1,
        path: "/member",
        component: "Layout",
        meta: {
            title: "会员管理",
            icon: "peoples",
            hidden: false,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 2,
                path: "list",
                component: "member/list/index",
                name: "list",
                meta: {
                    title: "会员列表",
                    icon: "user",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 3,
                path: "audit",
                component: "member/audit/index",
                name: "audit",
                meta: {
                    title: "实名管理",
                    icon: "role",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 4,
                path: "account",
                component: "member/account/index",
                name: "account",
                meta: {
                    title: "账户监控",
                    icon: "security",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 5,
                path: "asset",
                component: "member/asset/index",
                name: "asset",
                meta: {
                    title: "余额管理",
                    icon: "money",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 6,
                path: "applog",
                component: "member/applog/index",
                name: "applog",
                meta: {
                    title: "APP日志",
                    icon: "bug",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 7,
                path: "agent",
                component: "member/agent/index",
                name: "agent",
                meta: {
                    title: "业务汇总",
                    icon: "business",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 8,
                path: "riskcontrolrecord",
                component: "member/riskcontrolrecord/index",
                name: "riskcontrolrecord",
                meta: {
                    title: "风控记录",
                    icon: "security",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 9,
                path: "deviceMonitor",
                component: "member/deviceMonitor/index",
                name: "deviceMonitor",
                meta: {
                    title: "设备监控",
                    icon: "security",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 0,
                path: "agentarcdiag",
                component: "member/agentarcdiag/index",
                name: "agentarcdiag",
                meta: {
                    title: "架构图代理",
                    hidden: true,
                    roles: ["ADMIN"],
                },
            },
            {
                id: 0,
                path: "memberdetail",
                component: "member/memberdetail/index",
                name: "memberdetail",
                meta: {
                    title: "会员详情",
                    hidden: true,
                    roles: ["ADMIN"],
                },
            },
            {
                id: 0,
                path: "memberauditdetail",
                component: "member/auditdetail/index",
                name: "memberauditdetail",
                meta: {
                    title: "会员审核详情",
                    hidden: true,
                    roles: ["ADMIN"],
                },
            },
        ],
    },
    // {
    //     id: 11,
    //     path: "/events",
    //     component: "Layout",
    //     meta: {
    //         title: "赛事管理",
    //         icon: "events",
    //         hidden: mode,
    //         alwaysShow: true,
    //         roles: ["ADMIN"],
    //         keepAlive: true,
    //     },
    //     children: [
    //         {
    //             id: 18,
    //             path: "order",
    //             component: "events/order/index",
    //             name: "order",
    //             meta: {
    //                 title: "下单记录",
    //                 icon: "orderRecord",
    //                 hidden: mode,
    //                 alwaysShow: false,
    //                 roles: ["ADMIN"],
    //                 keepAlive: true,
    //             },
    //         },
    //     ],
    // },
    {
        id: 10,
        path: "/coinSpot",
        component: "Layout",
        meta: {
            title: "现货管理",
            icon: "documentary",
            hidden: mode,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 11,
                path: "coinSymbolConfig",
                component: "coinSpot/coinSymbolConfig/index",
                name: "coinSymbolConfig",
                meta: {
                    title: "币种配置",
                    icon: "walkthrough",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 12,
                path: "symbolConfig",
                component: "coinSpot/symbolConfig/index",
                name: "symbolConfig",
                meta: {
                    title: "币对配置",
                    icon: "walkthrough",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 13,
                path: "orderManage",
                component: "coinSpot/orderManage/index",
                name: "orderManage",
                meta: {
                    title: "委托订单管理",
                    icon: "walkthrough",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 14,
                path: "tradeHistory",
                component: "coinSpot/tradeHistory/index",
                name: "tradeHistory",
                meta: {
                    title: "历史成交",
                    icon: "walkthrough",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 15,
                path: "robotConfig",
                component: "coinSpot/robotConfig/index",
                name: "robotConfig",
                meta: {
                    title: "机器人配置",
                    icon: "walkthrough",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
        ],
    },
    {
        id: 20,
        path: "/documentary",
        component: "Layout",
        meta: {
            title: "跟单管理",
            icon: "documentary",
            hidden: false,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 21,
                path: "documentaryRecord",
                component: "documentary/documentaryRecord/index",
                name: "documentaryRecord",
                meta: {
                    title: "跟单记录",
                    icon: "walkthrough",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 22,
                path: "traderApplication",
                component: "documentary/traderApplication/index",
                name: "traderApplication",
                meta: {
                    title: "交易员申请",
                    icon: "applyFor",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 23,
                path: "labelManagement",
                component: "documentary/labelManagement/index",
                name: "labelManagement",
                meta: {
                    title: "标签管理",
                    icon: "label",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 24,
                path: "DconfiGuration",
                component: "documentary/DconfiGuration/index",
                name: "DconfiGuration",
                meta: {
                    title: "跟单配置",
                    icon: "warehouse",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 25,
                path: "dealerClass",
                component: "documentary/dealerClass/index",
                name: "dealerClass",
                meta: {
                    title: "交易员等级管理",
                    icon: "class",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 26,
                path: "dealerList",
                component: "documentary/dealerList/index",
                name: "dealerList",
                meta: {
                    title: "交易员列表",
                    icon: "user",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 27,
                path: "positionManagement",
                component: "documentary/positionManagement/index",
                name: "positionManagement",
                meta: {
                    title: "学生仓位管理",
                    icon: "warehouse",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 28,
                path: "traderPosition",
                component: "documentary/traderPosition/index",
                name: "traderPosition",
                meta: {
                    title: "老师仓位管理",
                    icon: "business",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 29,
                path: "statisticsManagement",
                component: "documentary/statisticsManagement/index",
                name: "statisticsManagement",
                meta: {
                    title: "交易员统计管理",
                    icon: "tree",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 30,
                path: "summaryOfDocumentaryBusiness",
                component: "documentary/summaryOfDocumentaryBusiness/index",
                name: "summaryOfDocumentaryBusiness",
                meta: {
                    title: "跟单业务汇总",
                    icon: "business",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 31,
                path: "positionHistory",
                component: "documentary/positionHistory/index",
                name: "positionHistory",
                meta: {
                    title: "跟单历史仓位",
                    icon: "recording",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 32,
                path: "liquidationRecord",
                component: "documentary/liquidationRecord/index",
                name: "liquidationRecord",
                meta: {
                    title: "平仓记录",
                    icon: "rank",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 33,
                path: "copyTradePosition",
                component: "documentary/copyTradePosition/index",
                name: "copyTradePosition",
                meta: {
                    title: "跟单持仓统计",
                    icon: "rank",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 0,
                path: "copyTradePosition/detail",
                component: "documentary/copyTradePosition/detail",
                name: "CopyTradePositionDetail",
                meta: {
                    title: "跟单明细",
                    icon: "rank",
                    hidden: true,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: false,
                },
            },
        ],
    },
    {
        id: 40,
        path: "/invitation",
        component: "Layout",
        redirect: "/invitation/index",
        meta: {
            title: "代理商管理",
            icon: "tree",
            hidden: mode,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 41,
                path: "record",
                component: "invitation/record/index",
                name: "record",
                meta: {
                    title: "邀请记录",
                    icon: "recording",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 42,
                path: "rank",
                component: "invitation/rank/index",
                name: "rank",
                meta: {
                    title: "邀请排名",
                    icon: "rank",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 43,
                path: "reward",
                component: "swap/reward/index",
                name: "reward",
                meta: {
                    title: "返佣管理",
                    icon: "rebates",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            // {
            //     id: 259,
            //     path: "rewardset",
            //     component: "swap/rewardset/index",
            //     name: "rewardset",
            //     meta: {
            //         title: "返佣比例",
            //         icon: "proportion",
            //         hidden: mode,
            //         alwaysShow: false,
            //         roles: ["ADMIN"],
            //         keepAlive: true,
            //     },
            // },
            {
                id: 44,
                path: "relation",
                component: "invitation/relation/index",
                name: "relation",
                meta: {
                    title: "推荐关系图",
                    icon: "diagram",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 45,
                path: "team",
                component: "invitation/team/index",
                name: "team",
                meta: {
                    title: "团队业务汇总",
                    icon: "team",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 46,
                path: "agentApply",
                component: "invitation/agentApply/index",
                name: "agentApply",
                meta: {
                    title: "代理商审核",
                    icon: "applyFor",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
        ],
    },
    {
        id: 50,
        path: "/swap",
        component: "Layout",
        redirect: "/swap/index",
        meta: {
            title: "永续合约",
            icon: "contract",
            hidden: mode,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 51,
                path: "swapcoin",
                component: "swap/coin/index",
                name: "swapcoin",
                meta: {
                    title: "交易对管理",
                    icon: "tradingpairs",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 52,
                path: "entrust",
                component: "swap/entrust/index",
                name: "entrust",
                meta: {
                    title: "委托管理",
                    icon: "entrust",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 53,
                path: "contract",
                component: "swap/contract/index",
                name: "contract",
                meta: {
                    title: "仓位管理",
                    icon: "warehouse",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 54,
                path: "account",
                component: "swap/account/index",
                name: "contractAccount",
                meta: {
                    title: "价格测试",
                    icon: "warehouse",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 55,
                path: "backLength",
                component: "swap/backLength/index",
                name: "backLength",
                meta: {
                    title: "开仓前移",
                    icon: "warehouse",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            /*{
        path: 'agency',
        component: 'swap/agency/index',
        name: 'agency',
        meta: {
          title: '代理列表',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      }*/
        ],
    },
    /*{
    path: '/option',
    component: 'Layout',
    redirect: 'option/index',
    name: 'option',
    meta: {
      title: '期权合约',
      icon: 'tree',
      hidden: mode,
      alwaysShow: true,
      roles: [
        "ADMIN"
      ],
      keepAlive: true
    },
    children: [
      {
        path: 'optioncoin',
        component: 'option/coin/index',
        name: 'optioncoin',
        meta: {
          title: '交易对管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      },
      {
        path: 'optionlist',
        component: 'option/list/index',
        name: 'optionlist',
        meta: {
          title: '合约管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      },
      {
        path: 'order',
        component: 'option/order/index',
        name: 'order',
        meta: {
          title: '订单管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      }
    ]
  },
  {
    path: '/exchange',
    component: 'Layout',
    redirect: '/exchange/index',
    name: 'Exchange',
    meta: {
      title: '币币管理',
      icon: 'tree',
      hidden: mode,
      alwaysShow: true,
      roles: [
        "ADMIN"
      ],
      keepAlive: true
    },
    children: [
      {
        path: 'bborder',
        component: 'exchange/bborder/index',
        name: 'Bborder',
        meta: {
          title: '订单管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      },
      {
        path: 'bbsetting',
        component: 'exchange/bbsetting/index',
        name: 'Bbsetting',
        meta: {
          title: '币币设置',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      },
      {
        path: 'robot',
        component: 'exchange/robot/index',
        name: 'Robot',
        meta: {
          title: '控盘机器人',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      }
    ]
  },
  {
    path: '/otc',
    component: 'Layout',
    redirect: '/otc/index',
    name: 'Otc',
    meta: {
      title: 'OTC管理',
      icon: 'tree',
      hidden: mode,
      alwaysShow: true,
      roles: [
        "ADMIN"
      ],
      keepAlive: true
    },
    children: [
      {
        path: 'otcad',
        component: 'otc/ad/index',
        name: 'otcad',
        meta: {
          title: '后台广告',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      },
      {
        path: 'appeal',
        component: 'otc/appeal/index',
        name: 'Appeal',
        meta: {
          title: '后台申诉',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        },
        hidden: true
      },
      {
        path: 'order',
        component: 'otc/order/index',
        name: 'Order',
        meta: {
          title: '订单管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      },
      {
        path: 'otccoin',
        component: 'otc/coin/index',
        name: 'otccoin',
        meta: {
          title: '币种管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      },
      {
        path: 'cancelapply',
        component: 'otc/cancelapply/index',
        name: 'cancelApply',
        meta: {
          title: '退保管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      },
      {
        path: 'businessaudit',
        component: 'otc/businessaudit/index',
        name: 'BusinessAudit',
        meta: {
          title: '商家认证',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      }
    ]
  },
  {
    path: '/ctc',
    component: 'Layout',
    redirect: '/ctc/index',
    name: 'Ctc',
    meta: {
      title: 'CTC管理',
      icon: 'tree',
      hidden: mode,
      alwaysShow: true,
      roles: [
        "ADMIN"
      ],
      keepAlive: true
    },
    children: [
      {
        path: 'order',
        component: 'ctc/order/index',
        name: 'Order',
        meta: {
          title: '订单列表',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      },
      {
        path: 'acceptor',
        component: 'ctc/acceptor/index',
        name: 'Acceptor',
        meta: {
          title: '承兑商列表',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      }
    ]
  },*/
    {
        id: 60,
        path: "/finance",
        component: "Layout",
        redirect: "/finance/index",
        name: "Finance",
        meta: {
            title: "财务管理",
            icon: "finance",
            hidden: false,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 61,
                path: "tradedetail",
                component: "finance/tradedetail/index",
                name: "TradeDetail",
                meta: {
                    title: "交易明细",
                    icon: "trade",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                    noCache: true,
                },
            },
            {
                id: 62,
                path: "withdrawals",
                component: "finance/withdrawals/index",
                name: "Withdrawals",
                meta: {
                    title: "提币审核",
                    icon: "audit",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                    noCache: true,
                },
            },
            {
                id: 0,
                path: "financeauditdetail",
                component: "finance/auditdetail/index",
                name: "financeauditdetail",
                meta: {
                    title: "提币审核详情",
                    hidden: true,
                    roles: ["ADMIN"],
                },
            },
            {
                id: 63,
                path: "internalRecord",
                component: "finance/internalRecord/index",
                name: "internalRecord",
                meta: {
                    title: "内部转账记录",
                    icon: "withdraw",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                    noCache: true,
                },
            },
            /*{
        path: 'fee',
        component: 'finance/fee/index',
        name: 'Fee',
        meta: {
          title: '手续费管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      },*/
            {
                id: 64,
                path: "chargecoin",
                component: "finance/chargecoin/index",
                name: "chargecoin",
                meta: {
                    title: "充币记录",
                    icon: "recharge",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                    noCache: true,
                },
            },
            /*{
        path: 'otc',
        component: 'finance/otc/index',
        name: 'Otc',
        meta: {
          title: '法币交易明细',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      },*/
            {
                id: 65,
                path: "withdrawdetail",
                component: "finance/withdrawdetail/index",
                name: "WithdrawDetail",
                meta: {
                    title: "提币明细",
                    icon: "withdraw",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                    noCache: true,
                },
            },
            /*{
        path: 'statistic',
        component: 'finance/statistic/index',
        name: 'Statistic',
        meta: {
          title: '财务统计',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      },
      {
        path: 'manual',
        component: 'finance/manual/index',
        name: 'Manual',
        meta: {
          title: '手动充值管理',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true,
          noCache: true
        }
      }*/
        ],
    },
    {
        id: 80,
        path: "/messageCenter",
        component: "Layout",
        meta: {
            title: "消息中心",
            icon: "documentary",
            hidden: mode,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 81,
                path: "emailCode",
                component: "messageCenter/emailCode/index",
                name: "emailCode",
                meta: {
                    title: "邮箱验证码",
                    icon: "walkthrough",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 82,
                path: "sendEmail",
                component: "messageCenter/sendEmail/index",
                name: "sendEmail",
                meta: {
                    title: "发送邮件",
                    icon: "walkthrough",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
        ],
    },
    {
        id: 90,
        path: "/cms",
        component: "Layout",
        redirect: "/cms/index",
        name: "Cms",
        meta: {
            title: "内容管理",
            icon: "content",
            hidden: mode,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 91,
                path: "ad",
                component: "cms/ad/index",
                name: "Ad",
                meta: {
                    title: "广告管理",
                    icon: "ad",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 92,
                path: "banner",
                component: "cms/banner/index",
                name: "Banner",
                meta: {
                    title: "Banner管理",
                    icon: "ad",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 93,
                path: "header",
                component: "cms/header/index",
                name: "Header",
                meta: {
                    title: "Header管理",
                    icon: "ad",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 94,
                path: "help-category",
                component: "cms/help-category/index",
                name: "HelpCategory",
                meta: {
                    title: "帮助分类",
                    icon: "help",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 95,
                path: "help",
                component: "cms/help/index",
                name: "Help",
                meta: {
                    title: "帮助管理",
                    icon: "help",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 96,
                path: "announce",
                component: "cms/announce/index",
                name: "Announce",
                meta: {
                    title: "公告管理",
                    icon: "announcement",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
        ],
    },
    /*{
    path: '/bond',
    component: 'Layout',
    redirect: '/bond/index',
    name: 'Bond',
    meta: {
      title: '保证金管理',
      icon: 'tree',
      hidden: mo de,
      alwaysShow: true,
      roles: [
        'ADMIN'
      ],
      keepAlive: true
    },
    children: [
      {
        path: 'manage',
        component: 'bond/manage/index',
        name: 'Manage',
        meta: {
          title: '查询保证金策略',
          icon: 'client',
          hidden: mode,
          alwaysShow: false,
          roles: [
            'ADMIN'
          ],
          keepAlive: true
        }
      }
    ]
  },
  
  {
    path: '/envelope',
    component: 'Layout',
    redirect: '/envelope/index',
    name: 'Envelope',
    meta: {
      title: "红包管理",
      icon: "tree",
      hidden: mode,
      alwaysShow: true,
      roles: [
        "ADMIN"
      ],
      keepAlive: true
    },
    children: [
      {
        path: "list",
        component: 'envelope/list/index',
        name: "List",
        meta: {
          title: "红包列表",
          icon: "client",
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      }
    ]
  },*/
    {
        id: 120,
        path: "/staking",
        component: "Layout",
        meta: {
            title: "质押管理",
            icon: "money",
            hidden: mode,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 121,
                path: "config",
                component: "staking/config/index",
                name: "stakingConfig",
                meta: {
                    title: "质押配置",
                    icon: "edit",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 122,
                path: "order",
                component: "staking/order/index",
                name: "stakingOrder",
                meta: {
                    title: "质押订单",
                    icon: "list",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 123,
                path: "record",
                component: "staking/record/index",
                name: "stakingRecord",
                meta: {
                    title: "质押流水",
                    icon: "list",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 124,
                path: "airdrop-distribute",
                component: "staking/airdropDistribute/index",
                name: "airdropDistribute",
                meta: {
                    title: "空投分配",
                    icon: "gift",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 125,
                path: "airdrop-record",
                component: "staking/airdropRecord/index",
                name: "airdropRecord",
                meta: {
                    title: "空投记录",
                    icon: "list",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 126,
                path: "airdrop-audit",
                component: "staking/airdropAudit/index",
                name: "airdropAudit",
                meta: {
                    title: "空投审核",
                    icon: "edit",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
        ],
    },
    {
        id: 100,
        path: "/system",
        component: "Layout",
        redirect: "/system/index",
        name: "System",
        meta: {
            title: "系统管理",
            icon: "system",
            hidden: mode,
            alwaysShow: true,
            roles: ["ADMIN"],
            keepAlive: true,
        },
        children: [
            {
                id: 101,
                path: "role",
                component: "system/role/index",
                name: "Role",
                meta: {
                    title: "角色管理",
                    icon: "role",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 102,
                path: "employee",
                component: "system/employee/index",
                name: "Employee",
                meta: {
                    title: "用户管理",
                    icon: "user",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 103,
                path: "depart",
                component: "system/depart/index",
                name: "Depart",
                meta: {
                    title: "部门管理",
                    icon: "department",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 104,
                path: "accesslog",
                component: "system/accesslog/index",
                name: "accesslog",
                meta: {
                    title: "系统日志",
                    icon: "systemlogs",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 105,
                path: "coin",
                component: "system/coin/index",
                name: "coin",
                meta: {
                    title: "币种管理",
                    icon: "currency",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 106,
                path: "currency-coin",
                component: "system/currency-coin/index",
                name: "CurrencyCoin",
                meta: {
                    title: "法币管理",
                    icon: "currency",
                    hidden: false,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 107,
                path: "permission",
                component: "system/permission/index",
                name: "Permission",
                meta: {
                    title: "权限管理",
                    icon: "permissions",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            /*{
        path: "dictionary",
        component: 'system/dictionary/index',
        name: "Dictionary",
        meta: {
          title: "系统信息维护",
          icon: "client",
          hidden: mode,
          alwaysShow: false,
          roles: [
            "ADMIN"
          ],
          keepAlive: true
        }
      },*/
            {
                id: 108,
                path: "appreversion",
                component: "system/appreversion/index",
                name: "appreversion",
                meta: {
                    title: "版本管理",
                    icon: "version",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 0,
                path: "transferdetail",
                component: "system/transferdetail/index",
                name: "transferdetail",
                meta: {
                    title: "转入明细",
                    hidden: true,
                    roles: ["ADMIN"],
                },
            },
            {
                id: 109,
                path: "sysConfig",
                component: "system/sysConfig/index",
                name: "sysConfig",
                meta: {
                    title: "系统配置",
                    icon: "system",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 110,
                path: "coin-network",
                component: "system/coinNetwork/index",
                name: "coinNetwork",
                meta: {
                    title: "主网配置",
                    icon: "link",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 111,
                path: "coin-network-config",
                component: "system/coinNetworkConfig/index",
                name: "coinNetworkConfig",
                meta: {
                    title: "币种主网配置",
                    icon: "link",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
            {
                id: 112,
                path: "withdraw-chain-config",
                component: "system/withdrawChainConfig/index",
                name: "withdrawChainConfig",
                meta: {
                    title: "提现链配置",
                    icon: "link",
                    hidden: mode,
                    alwaysShow: false,
                    roles: ["ADMIN"],
                    keepAlive: true,
                },
            },
        ],
    },

    { id: 0, path: "*", redirect: "/404", hidden: true },
];

// 创建路由
const router = createRouter({
    history: createWebHashHistory(),
    routes: constantRoutes as RouteRecordRaw[],
    // 刷新时，滚动条位置还原
    scrollBehavior: () => ({ left: 0, top: 0 }),
});

// 重置路由
export function resetRouter() {
    const { permission } = useStore();
    permission.routes.forEach((route: any) => {
        const name = route.name;
        if (name && router.hasRoute(name)) {
            router.removeRoute(name);
        }
    });
}

export default router;
