import React, { lazy, useEffect } from 'react'
import { useDispatch } from 'react-redux'
import { Navigate, useRoutes } from 'react-router'
import DashboardLayout from '../components/DashboardLayout'
import { Dispatch } from '../models/store'
import LoginPage from './Login/index1'

import Sszq from './ysgzq/sszq'
import Yxqk from './ysgzq/ssgq/yxqk'
import Gcxq from './ysgzq/ssgq/gcxq'
import Dbaq from './ysgzq/ssgq/dbaq'
import Skhs from './fxdd/hsyb/skhs'
import Hdhs from './fxdd/hsyb/hdhs'
import Yjxy from './fxdd/ddjc/yjxy'

import Ddzl from './fxdd/ddjc/ddzl'


import Ddgc from "./fxzb/ddgc"
import Fxya from './fxzb/fxya'
import Hsybjs from './fxzb/hsybjs'
import Ybfagl from './fxzb/ybfagl'
import Csgl from './fxzb/csgl'

import Qxdw_Gc from './fxzb/qxdw/gc/index.js'
import Qxwl_Gc from './fxzb/qxwl/gc'
// 工程安全监测
import Bzt from './gcaqjc/bzt2'
import Yhyj from "./gcaqjc/gcaqyj/yhyj"
import Yjgzpz from "./gcaqjc/gcaqyj/yjgzpz"
import Sljc from "./gcaqjc/sjtjcx/sljc"
import Syjc from "./gcaqjc/sjtjcx/syjc"
import Wyjc from "./gcaqjc/sjtjcx/wyjc"
import Czcx from "./gcaqjc/sjtjcx/czcx"
import Sjlr from "./gcaqjc/sjtjcx/sjlr"
import Ndsytjb from "./gcaqjc/sjtjcx/ndsytjb"
import Ndsltjb from "./gcaqjc/sjtjcx/ndsltjb"
import Ndwytjb from "./gcaqjc/sjtjcx/ndwytjb"
import Jrx from "./gcaqjc/gcaqfx/jrx"

// 日常管理
import Rjswnbb from "./rcgl/btbb/rjswnbb"
import Rjylnbb from "./rcgl/btbb/rjynbb"
import Sdswrbb from "./rcgl/btbb/sdswrbb"
import Sdjyrbb from "./rcgl/btbb/sdjyrbb"
import Xjrw from "./rcgl/xcxj/xjrw"
import Xjwtcl from "./rcgl/xcxj/xjwtcl"
import Xjxpz from "./rcgl/xcxj/xjxpz"
import Fzxc from "./rcgl/byfz/fzxc"
import Bypc from "./rcgl/byfz/bypc"

import Zmjk from "./rcgl/zmjk"
import Wxyh from "./rcgl/wxyh"
import Szzb from "./rcgl/szzb"
import Stlljc from "./rcgl/stlljc"
import Aqyhpc from "./rcgl/aqgl/aqyhpc"
import Aqjcgl from "./rcgl/aqgl/aqjcgl"
import Aqsgdj from "./rcgl/aqgl/aqsgdj"
import Aqjdtz from "./rcgl/aqgl/aqjdtz"
import Cxjgtz from "./rcgl/aqgl/cxjgtz"
import Fxgkqd from "./rcgl/aqgl/fxgkqd"
import Khzbgl from "./rcgl/jdkh/khzbgl"
import Khmbgl from "./rcgl/jdkh/khmbgl"
import Khtj from "./rcgl/jdkh/khtj"
import Khwtzg from "./rcgl/jdkh/khwtzg"
import Khrwgl from "./rcgl/jdkh/khrwgl"

// 值班管理
import Zbb from "./zbgl/zbb"
import Zbrz from "./zbgl/zbrz"
// import Gcdsj from "./rcgl/gcdsj"

import VideoList from './video'

// 供水兴利
import Dxnjyzl from "./gxsl/dxnjyzl"
import Zfzl from "./gxsl/zfzl"
import Zfjk from './gxsl/zfjk'
import Gstjfx from "./gxsl/gstjfx"
import Skzfzl from "./gxsl/skzfzl"
// 视频监控
import Spjk from "./video"
import AiWarn from "./spjk/aiWarn"
// 广播预警
import Gbyj from "./gbyj/index"


// 四全
import Zcdjxx from './sq/qfg/zcdjxx'
import Kqys from './sq/qys/kqys/index.js'
import Xyys from './sq/qys/xyys/index.js'
import Gcys from './sq/qys/gcys/index.js'
import Gcdsj from './sq/qzq/gcdsj'
import Sksq from './sq/qth/sksq'
import Hdsq from './sq/qth/hdsq'
import Ssyq from './sq/qth/ssyq'
import Trsq from './sq/qth/trsq'
import Skyh from './sq/qth/skyh'
import Qzqda from './sq/qzq/qzqda'
// import Zcdjxx from './sq/qys/'
// import Zcdjxx from './sq/qfg/zcdjxx'
// import Zcdjxx from './sq/qfg/zcdjxx'
// import Zcdjxx from './sq/qfg/zcdjxx'

// 四制 - 组织机构查看
import Zzjgck from './sz/zzjgck'
import Zrrgl from './sz/zrrgl'
import Pxjhgl from './sz/pxjhgl'
import Pxjlgl from './sz/pxjlgl'
import Flfg from './sz/flfg'
import Zdgl from './sz/zdgl'
import Ajdj from './sz/szzf/ajdj'
import Ajtj from './sz/szzf/ajtj'
import Clyj from './sz/szzf/clyj'
import Ddfa from './sz/ddfa'

import Krgl from './KrLine'
import Gsnlfx from './gxsl/gsnlfx'
import Ddjl from './szydd/ddjl'
import Ywgz from './sz/ywgz'
import Gcaq from './sz/khzbgl'


const HomePage = lazy(() => import('./Home'))

const IframePage = lazy(() => import('./Iframe'))

const AppRouters: React.FC = () => {
  const dispatch = useDispatch<Dispatch>()

  useEffect(() => {
    ;(window as any).__dispatch__ = dispatch
    return () => {
      delete (window as any).__dispatch__
    }
  }, [dispatch])

  let element = useRoutes([
    { path: '/', element: <LoginPage /> },
    // { path: '/', element: <DashboardLayout /> },

    // { id: id(), title: '洪水预报计算', path: '/mgr/fxzb/hsyb/hyybjs' },
    // { id: id(), title: '预报方案管理', path: '/mgr/fxzb/hsyb/ybfagl' },
    // { id: id(), title: '参数管理', path: '/mgr/fxzb/hsyb/csgl' },


    {
      path: '/mgr',
      element: <DashboardLayout />,
      children: [
        { path: 'home', element: <HomePage /> },

        //四预
        { path: 'sy/fhxzfx', element: <HomePage /> },
        { path: 'sy/tqyb', element: <HomePage /> },
        { path: 'sy/hsyy', element: <HomePage /> },

        //四预-洪水预报
        { path: 'sy/hsyb/hyybjs', element: <Hsybjs /> },
        { path: 'sy/hsyb/ybfagl', element: <Ybfagl /> },
        { path: 'sy/hsyb/csgl', element: <Csgl /> },

        // 调度规程
        { path: 'sy/ddgc', element: <Ddgc /> },

        // 防汛预案
        { path: 'sy/fxya', element: <Fxya /> },

        // 抢险物料
        { path: 'sy/qxwl', element: <Qxwl_Gc /> },

        // 抢险队伍
        { path: 'sy/qxdw', element: <Qxdw_Gc /> },

        
        // 工程安全监测
        { path: 'sq/qth/dbaqjc', element: <Bzt isHome={false}/> },
        { path: 'sq/qth/sksq', element: <Sksq /> },
        { path: 'sq/qth/hdsq', element: <Hdsq /> },
        { path: 'sq/qth/ssyq', element: <Ssyq /> },
        { path: 'sq/qth/trsq', element: <Trsq /> },
        { path: 'sq/qth/skyh', element: <Skyh /> },

        // 预警
        { path: 'gcaqjc/gcaqyj/bzt', element: <Bzt isHome={false}/> },
        { path: 'gcaqjc/gcaqyj/yhyj', element: <Yhyj /> },
        { path: 'gcaqjc/gcaqyj/yjgzpz', element: <Yjgzpz /> },

        //统计 
        { path: 'gcaqjc/sjtjcx/syjx', element: <Syjc /> },
        { path: 'gcaqjc/sjtjcx/sljx', element: <Sljc /> },
        { path: 'gcaqjc/sjtjcx/wyjx', element: <Wyjc /> },
        { path: 'gcaqjc/sjtjcx/czcx', element: <Czcx /> },
        { path: 'gcaqjc/sjtjcx/sjlr', element: <Sjlr /> },
        { path: 'gcaqjc/sjtjcx/ndsytjb', element: <Ndsytjb /> },
        { path: 'gcaqjc/sjtjcx/ndsltjb', element: <Ndsltjb /> },
        { path: 'gcaqjc/sjtjcx/ndwytjb', element: <Ndwytjb /> },

        // 工程安全分析
        { path: 'gcaqjc/gcaqfx/jrx', element: <Jrx /> },
        
        // 日常管理-水质整编
        { path: 'sg/btbb/rjswbb', element: <Rjswnbb /> },
        { path: 'sg/btbb/rjylnbb', element: <Rjylnbb /> },
        { path: 'sg/btbb/sdswbb', element: <Sdswrbb /> },
        { path: 'sg/btbb/sdjyrbb', element: <Sdjyrbb /> },
        { path: 'sg/xcxj/xcrw', element: <Xjrw /> },
        { path: 'sg/xcxj/xjwtcl', element: <Xjwtcl /> },
        { path: 'sg/xcxj/xjxpz', element: <Xjxpz/> },
        { path: 'sg/byfz/byxc', element: <Fzxc /> },
        { path: 'sg/byfz/bypc', element: <Bypc /> },
        { path: 'sg/zmjk', element: <Zmjk /> },
        { path: 'sg/wxyh', element: <Wxyh /> },
        { path: 'sg/aqgl/aqjcgl', element: <Aqjcgl /> },
        { path: 'sg/aqgl/fxgkqd', element: <Fxgkqd /> },
        { path: 'sg/aqgl/cxjgtz', element: <Cxjgtz /> },
        { path: 'sg/aqgl/aqjdtz', element: <Aqjdtz /> },
        { path: 'sg/aqgl/aqyhpc', element: <Aqyhpc /> },
        { path: 'sg/aqgl/aqsgdj', element: <Aqsgdj /> },
        { path: 'sg/gcdsj', element: <Gcdsj /> },
        { path: 'sg/szzb', element: <Szzb /> },
        { path: 'sg/krgl', element: <Krgl /> },
        { path: 'rcgl/stlljc', element: <Stlljc /> },
        { path: 'sg/zbgl/zbb', element: <Zbb /> },
        { path: 'sg/zbgl/zbrz', element: <Zbrz /> },
        // 日常管理-监督考核
        { path: 'sz/jdkh/khtj', element: <Khtj /> },
        { path: 'sz/jdkh/khzbgl', element: <Khzbgl /> },
        { path: 'sz/jdkh/khmbgl', element: <Khmbgl /> },
        { path: 'sz/jdkh/khwtzg', element: <Khwtzg /> },
        { path: 'sz/jdkh/khrwgl', element: <Khrwgl /> },


        // 供水兴利
        { path: 'gsxl/zfzl', element: <Zfzl /> },
        { path: 'gsxl/zfjk', element: <Zfjk /> },

        { path: 'szydd/diaodu', element: <Ddjl/> },
        { path: 'szydd/gsnlfx', element: <Gsnlfx /> },
        { path: 'szydd/gstjfx', element: <Gstjfx /> },
        { path: 'szydd/dxnjyzl', element: <Dxnjyzl /> },
        { path: 'szydd/skzfzl', element: <Skzfzl /> },

        { path: 'fxzb/jczw/yqz', element: <HomePage /> },
        { path: 'fxzb/jczw/sqz', element: <HomePage /> },
        // 视频监控
        { path: 'sq/qth/spjk', element: <Spjk /> },
        { path: 'sg/gjgl/aigj', element: <AiWarn /> },
        { path: 'sg/gjgl/gbyj', element: <Gbyj /> },

        // { path: 'fxzb/zbb', element: <Zbb /> },
        // { path: 'fxzb/txl', element: <Txl /> },


        { path: 'ysgzq/ssyq', element: <HomePage /> },
        { path: 'ysgzq/sssq', element: <HomePage /> },
        { path: 'ysgzq/sszq', element: <Sszq /> },
        { path: 'ysgzq/ssgq/yxqk', element: <Yxqk /> },
        { path: 'ysgzq/ssgq/gcxq', element: <Gcxq /> },
        { path: 'ysgzq/ssgq/dbaq', element: <Dbaq /> },
        { path: 'fxdd/dqxsfx', element: <HomePage /> },
        { path: 'fxdd/tqyb', element: <HomePage /> },
        { path: 'fxdd/hsyb/skhs', element: <Skhs /> },
        { path: 'fxdd/hsyb/hdhs', element: <Hdhs /> },
        { path: 'fxdd/ddjc/yjxy', element: <Yjxy /> },
        { path: 'fxdd/ddjc/ddzl', element: <Ddzl /> },
        { path: 'videoSurveillance', element: <VideoList /> },

        // 四全
        // 注册登记信息
        { path: 'sq/qfg/zcdjxx', element: <Zcdjxx /> },
        //库区要素
        { path: 'sq/qys/kqys', element: <Kqys /> },
        { path: 'sq/qys/xyys', element: <Xyys /> },
        { path: 'sq/qys/gcys', element: <Gcys /> },
        { path: 'sq/qzq/gcdsj', element: <Gcdsj /> },
        { path: 'sq/qys/qzqda', element: <Qzqda /> },

        // 四制-组织机构查看
        { path: 'sz/gltx/zzjgck', element: <Zzjgck /> },
        { path: 'sz/gltx/zrrgl', element: <Zrrgl /> },
        { path: 'sz/pxgl/pxjhgl', element: <Pxjhgl /> },
        { path: 'sz/pxgl/pxjlgl', element: <Pxjlgl /> },
        { path: 'sz/flfg', element: <Flfg /> },
        { path: 'sz/zdgl', element: <Zdgl /> },       
        { path: 'sz/szzf/ajdj', element: <Ajdj /> },       
        { path: 'sz/szzf/ajtj', element: <Ajtj /> },       
        { path: 'sz/szzf/clyj', element: <Clyj /> },     
        
        { path: 'sz/zsk/ddfa', element: <Ddfa /> },     
        { path: 'sz/zsk/ywgz', element: <Ywgz /> },     
        { path: 'sz/zsk/gcaq', element: <Gcaq /> },     
        
      ],
    },
    { path: '/login', element: <LoginPage /> },
  ])

  return element
}

export default AppRouters
