import history from '@/utils/history'
import { removeTokenInfo } from '@/utils/storage'
import React from 'react'

// 点击退出登录
export const loginExit = () => {
  removeTokenInfo()
  history.replace('/login')
}

export type LookDomType = {
  src: string
  type: 'video' | 'audio' | 'model' | ''
  flag?: boolean
}

export type RouterTypeRow = {
  id: number
  name: string
  path: string
  pathLast?: string
  Com: React.LazyExoticComponent<React.MemoExoticComponent<() => JSX.Element>>
  pageType?: string
  authority?: boolean
}

export type RouterType = {
  id: number
  name: string
  show: boolean
  son: RouterTypeRow[]
}[]

const tabLeftArr: RouterType = [
  {
    id: 1,
    name: '工作台',
    show: false,
    son: [
      {
        id: 110,
        name: '数据统计',
        path: '/',
        Com: React.lazy(() => import('../Abench/A1statistics'))
      },
      {
        id: 120,
        name: '工作台',
        path: '/bench',
        Com: React.lazy(() => import('../Abench/A2bench'))
      },
      {
        id: 130,
        name: '流程中心',
        path: '/flow',
        Com: React.lazy(() => import('../Abench/A3flow'))
      },
      {
        id: 140,
        name: '凭证中心',
        path: '/proof',
        Com: React.lazy(() => import('../Abench/A4proof'))
      }
    ]
  },

  {
    id: 2,
    name: '入藏管理',
    show: false,
    son: [
      {
        id: 210,
        name: '藏品征集',
        path: '/collect',
        Com: React.lazy(() => import('../Benter/B1collect')),
        pageType: 'ZJ'
      },
      {
        id: 220,
        name: '藏品入馆',
        path: '/enterGuan',
        Com: React.lazy(() => import('../Benter/B2enterGuan')),
        pageType: 'RG'
      },
      {
        id: 230,
        name: '藏品鉴定',
        path: '/auth',
        Com: React.lazy(() => import('../Benter/B3auth')),
        pageType: 'JD'
      },
      {
        id: 240,
        name: '藏品入藏',
        path: '/enterCang',
        Com: React.lazy(() => import('../Benter/B4enterCang')),
        pageType: 'RC'
      }
    ]
  },

  {
    id: 3,
    name: '藏品台账',
    show: false,
    son: [
      {
        id: 310,
        name: '藏品总账',
        path: '/ledger',
        Com: React.lazy(() => import('../Cledger/C1ledger'))
      },
      {
        id: 320,
        name: '藏品分账',
        path: '/routing',
        Com: React.lazy(() => import('../Cledger/C2routing'))
      },
      {
        id: 330,
        name: '藏品信息',
        path: '/goodsInfo',
        Com: React.lazy(() => import('../Cledger/C3goodsInfo'))
      },
      {
        id: 340,
        name: '藏品附件',
        path: '/C4file',
        Com: React.lazy(() => import('../Cledger/C4file'))
      }
    ]
  },
  {
    id: 4,
    name: '藏品管理',
    show: false,
    son: [
      {
        id: 410,
        name: '藏品登记',
        path: '/register',
        Com: React.lazy(() => import('../Dmanage/D1register')),
        pageType: 'DJ'
      },
      {
        id: 420,
        name: '藏品修改',
        path: '/edit',
        Com: React.lazy(() => import('../Dmanage/D2edit')),
        pageType: 'XG'
      },
      {
        id: 430,
        name: '藏品注销',
        path: '/writeOff',
        Com: React.lazy(() => import('../Dmanage/D3writeOff')),
        pageType: 'ZX'
      },
      {
        id: 440,
        name: '资源使用',
        path: '/resource',
        Com: React.lazy(() => import('../Dmanage/D4resource')),
        pageType: 'ZY'
      },
      {
        id: 601,
        name: '藏品标签',
        path: '/tag',
        Com: React.lazy(() => import('../Eculture/E1tag'))
      }
    ]
  },
  {
    id: 5,
    name: '文创管理',
    show: false,
    son: [
      {
        id: 602,
        name: '故事管理',
        path: '/story',
        Com: React.lazy(() => import('../Eculture/E2story'))
      },
      {
        id: 603,
        name: '文创标签',
        path: '/label',
        Com: React.lazy(() => import('../Eculture/E3label'))
      }
    ]
  },
  {
    id: 6,
    name: '库房管理',
    show: false,
    son: [
      {
        id: 1010,
        name: '藏品入库',
        path: '/inStorage',
        Com: React.lazy(() => import('../Fstorehouse/F1inStorage')),
        pageType: 'RK'
      },
      {
        id: 1020,
        name: '藏品移库',
        path: '/moveStorage',
        Com: React.lazy(() => import('../Fstorehouse/F2moveStorage')),
        pageType: 'YK'
      },
      {
        id: 1030,
        name: '藏品出库',
        path: '/outStorage',
        Com: React.lazy(() => import('../Fstorehouse/F3outStorage')),
        pageType: 'CK'
      },
      {
        id: 1040,
        name: '藏品盘点',
        path: '/check',
        Com: React.lazy(() => import('../Fstorehouse/F4check')),
        pageType: 'PD'
      },
      {
        id: 1050,
        name: '人员出入库',
        path: '/staff',
        Com: React.lazy(() => import('../Fstorehouse/F5staff')),
        pageType: 'RY'
      }
    ]
  },

  {
    id: 7,
    name: '藏品维护',
    show: false,
    son: [
      {
        id: 510,
        name: '事故登记',
        path: '/accident',
        Com: React.lazy(() => import('../Gmaintain/G1accident')),
        pageType: 'SG'
      },
      {
        id: 540,
        name: '现状登记',
        path: '/actuality',
        Com: React.lazy(() => import('../Gmaintain/G2actuality')),
        pageType: 'XZ'
      },
      {
        id: 550,
        name: '修复登记',
        path: '/repair',
        Com: React.lazy(() => import('../Gmaintain/G3repair')),
        pageType: 'XF'
      }
    ]
  },
  {
    id: 8,
    name: '展品管理',
    show: false,
    son: [
      {
        id: 910,
        name: '借展管理',
        path: '/loan',
        Com: React.lazy(() => import('../Hexhibits/H1loan'))
      }
    ]
  },

  {
    id: 9,
    name: '系统管理',
    show: false,
    son: [
      {
        id: 709,
        name: '库房设置',
        path: '/storageSet',
        Com: React.lazy(() => import('../Isystem/I1storageSet'))
      },
      {
        id: 710,
        name: '数据字典',
        path: '/dict',
        Com: React.lazy(() => import('../Isystem/I2dict'))
      },
      {
        id: 720,
        name: '编号设置',
        path: '/numSet',
        Com: React.lazy(() => import('../Isystem/I3numSet'))
      },
      {
        id: 730,
        name: '流程设置',
        path: '/processSet',
        Com: React.lazy(() => import('../Isystem/I4processSet'))
      },
      {
        id: 740,
        name: '组织管理',
        path: '/organization',
        Com: React.lazy(() => import('../Isystem/I5organization'))
      },
      {
        id: 750,
        name: '角色管理',
        path: '/role',
        Com: React.lazy(() => import('../Isystem/I6role'))
      },
      {
        id: 760,
        name: '用户管理',
        path: '/user',
        Com: React.lazy(() => import('../Isystem/I7user'))
      },

      {
        id: 770,
        name: '系统日志',
        path: '/log',
        Com: React.lazy(() => import('../Isystem/I8log'))
      },
      // 不需要 高亮的 详情页
      {
        id: 9901,
        name: '藏品详情',
        path: '/goodsLook/:id',
        pathLast: '/goodsLook',
        Com: React.lazy(() => import('../ZgoodsInfo'))
      }
    ]
  }
]

export default tabLeftArr

// 里面的页面，不是左边的tab栏
// 这里的id要和tab栏的id相同，不然没有权限进入页面
export const routerSon: RouterTypeRow[] = [
  {
    id: 140,
    name: '凭证中心-详情页',
    path: '/proof_edit/:key/:id',
    Com: React.lazy(() => import('../Abench/A4proof/A4edit'))
  },
  {
    id: 210,
    name: '藏品征集-详情页',
    path: '/collect_edit/:key/:id',
    Com: React.lazy(() => import('../Benter/B1collect/B1edit'))
  },
  {
    id: 220,
    name: '藏品入馆-详情页',
    path: '/enterGuan_edit/:key/:id',
    Com: React.lazy(() => import('../Benter/B2enterGuan/B2edit'))
  },
  {
    id: 230,
    name: '藏品鉴定-详情页',
    path: '/auth_edit/:key/:id',
    Com: React.lazy(() => import('../Benter/B3auth/B3edit'))
  },
  {
    id: 240,
    name: '藏品入藏-详情页',
    path: '/enterCang_edit/:key/:id',
    Com: React.lazy(() => import('../Benter/B4enterCang/B4edit'))
  },
  {
    id: 410,
    name: '藏品登记-详情页',
    path: '/register_edit/:key/:id',
    Com: React.lazy(() => import('../Dmanage/D1register/D1edit'))
  },
  {
    id: 420,
    name: '藏品修改-详情页',
    path: '/edit_edit/:key/:id',
    Com: React.lazy(() => import('../Dmanage/D2edit/D2editSon'))
  },
  {
    id: 430,
    name: '藏品注销-详情页',
    path: '/writeOff_edit/:key/:id',
    Com: React.lazy(() => import('../Dmanage/D3writeOff/D3edit'))
  },
  {
    id: 440,
    name: '资源使用-详情页',
    path: '/resource_edit/:key/:id',
    Com: React.lazy(() => import('../Dmanage/D4resource/D4edit'))
  },
  {
    id: 510,
    name: '事故登记-详情页',
    path: '/accident_edit/:key/:id',
    Com: React.lazy(() => import('../Gmaintain/G1accident/G1edit'))
  },
  {
    id: 540,
    name: '现状登记-详情页',
    path: '/actuality_edit/:key/:id',
    Com: React.lazy(() => import('../Gmaintain/G2actuality/G2edit'))
  },
  {
    id: 550,
    name: '修复登记-详情页',
    path: '/repair_edit/:key/:id',
    Com: React.lazy(() => import('../Gmaintain/G3repair/G3edit'))
  },
  {
    id: 602,
    name: '故事管理-详情页',
    path: '/story_edit/:key/:id',
    Com: React.lazy(() => import('../Eculture/E2story/E2edit'))
  },
  {
    id: 1010,
    name: '藏品入库-详情页',
    path: '/inStorage_edit/:key/:id',
    Com: React.lazy(() => import('../Fstorehouse/F1inStorage/F1edit'))
  },
  {
    id: 1020,
    name: '藏品移库-详情页',
    path: '/moveStorage_edit/:key/:id',
    Com: React.lazy(() => import('../Fstorehouse/F2moveStorage/F2edit'))
  },
  {
    id: 1030,
    name: '藏品出库-详情页',
    path: '/outStorage_edit/:key/:id',
    Com: React.lazy(() => import('../Fstorehouse/F3outStorage/F3edit'))
  },
  {
    id: 1040,
    name: '藏品盘点-详情页',
    path: '/check_edit/:key/:id',
    Com: React.lazy(() => import('../Fstorehouse/F4check/F4edit'))
  },
  {
    id: 1050,
    name: '人员出入库-详情页',
    path: '/staff_edit/:key/:id',
    Com: React.lazy(() => import('../Fstorehouse/F5staff/F5edit'))
  },
  {
    id: 910,
    name: '借展管理-详情页',
    path: '/loan_detail/:id',
    Com: React.lazy(() => import('../Hexhibits/H1loan/H1detail'))
  }
]
