import { createRouter, createWebHistory } from "vue-router";

//中美博弈概览
import overView from "@/views/overView/index.vue";
//新闻速览
import newsBrief from "@/views/newsBrief/index.vue"
// 风险信号
import RiskSignal from "@/views/riskSignal/index.vue"
// 智库相关
import thinkTank from "../views/thinkTank/index.vue";
import ThinkTankDetail from "@/views/thinkTank/ThinkTankDetail/index.vue";
import ReportDetail from "@/views/thinkTank/ReportDetail/index.vue";

// 法案相关
import BillHome from "@/views/bill/billHome/index.vue";
import BillLayoutContainer from "@/views/bill/billLayout/index.vue";
import BillLayout from "@/views/bill/index.vue";
import BillIntroduction from "@/views/bill/introdoction/index.vue";
import BillBackground from "@/views/bill/background/index.vue";
import BillTemplate from "@/views/bill/template/index.vue";
import BillDeepDigLayout from "@/views/bill/deepDig/index.vue";
import BillDeepDigProcessOverview from "@/views/bill/deepDig/processOverview/index.vue";
import BillDeepDigProcessAnalysis from "@/views/bill/deepDig/processAnalysis/index.vue";
import BillDeepDigPoliContribution from "@/views/bill/deepDig/poliContribution/index.vue";
import BillInfluenceLayout from "@/views/bill/influence/index.vue";
import BillInfluenceIndustry from "@/views/bill/influence/industry/index.vue";
import BillInfluenceScientificResearch from "@/views/bill/influence/scientificResearch/index.vue";
import BillRelevantCircumstance from "@/views/bill/relevantCircumstance/index.vue";

// 出口管制
import ExportControl from "@/views/exportControl/index.vue";

// 政令
import Decree from "@/views/decree/decreeHome/index.vue";
import DecreeLayoutContainer from "@/views/decree/decreeLayout/index.vue";
import DecreeOverviewLayout from "@/views/decree/decreeLayout/overview/index.vue";
import DecreeIntroduction from "@/views/decree/decreeLayout/overview/introduction/index.vue";
import DecreeBackground from "@/views/decree/decreeLayout/overview/background/index.vue";
import DecreeDeepDig from "@/views/decree/decreeLayout/deepdig/index.vue";
import DecreeInfluence from "@/views/decree/decreeLayout/influence/index.vue";

// 市场准入限制
import MarketAccessRestrictions from "@/views/marketAccessRestrictions/marketAccessHome/index.vue";
import MarketAccessLayout from "@/views/marketAccessRestrictions/marketAccessLayout/index.vue";
import MarketAccessOverview from "@/views/marketAccessRestrictions/marketAccessLayout/overview/index.vue";
import MarketAccessCase from "@/views/marketAccessRestrictions/marketAccessLayout/case/index.vue";
import MarketSingleCaseLayout from "@/views/marketAccessRestrictions/singleCaseLayout/index.vue";
import MarketSingleCaseOverview from "@/views/marketAccessRestrictions/singleCaseLayout/overview/index.vue";
import MarketSingleCaseDeepdig from "@/views/marketAccessRestrictions/singleCaseLayout/deepdig/index.vue";

// 投融资限制
import Finance from "@/views/finance/index.vue";

// 智能写报
import WrittingAsstaint from "@/views/writtingAsstaint/index.vue";
// 门户
import Portal1 from "@/views/portals/portal1/index.vue";
import Portal2 from "@/views/portals/portal2/index.vue";

// 综合搜索
import ComprehensiveSearch from '@/views/comprehensiveSearch/index.vue'
import SearchResults from '@/views/comprehensiveSearch/searchResults/index.vue'
import Chat from '@/views/comprehensiveSearch/chat/index.vue'

const routes = [
  // 智能写报
  {
    path: "/writtingAsstaint",
    name: "writtingAsstaint",
    component: WrittingAsstaint,
    meta: {
      title: "智能写报"
    }
  },

  {
    path: "/",
    redirect: "/overView"
  },

  // 中美博弈概览页面路由
  {
    path: "/overView",
    name: "overView",
    component: overView,
    meta: {
      title: "中美博弈概览"
    }
  },
  //新闻速览页面路由
  {
    path: "/newsBrief",
    name: "newsBrief",
    component: newsBrief,
    meta: {
      title: "新闻速览"
    }
  },
    //风险信号页面路由
  {
    path: "/riskSignal",
    name: "riskSignal",
    component: RiskSignal,
    meta: {
      title: "风险信号"
    }
  },
  // 智库系统的主要路由
  {
    path: "/thinkTank",
    name: "thinkTank",
    component: thinkTank,
    meta: {
      title: "首页"
    }
  },
  {
    path: "/think-tank/:id",
    name: "ThinkTankDetail",
    component: ThinkTankDetail,
    meta: {
      title: "智库详情"
    }
  },
  {
    path: "/report/:id",
    name: "ReportDetail",
    component: ReportDetail,
    meta: {
      title: "报告详情"
    }
  },

  // 法案系统路由
  {
    path: "/billHome",
    name: "BillHome",
    component: BillHome,
    meta: {
      title: "法案首页"
    }
  },
  {
    path: "/billLayout",
    name: "BillLayoutContainer",
    component: BillLayoutContainer,
    redirect: "/billLayout/bill",
    meta: {
      title: "法案布局"
    },
    children: [
      // 法案分析路由
      {
        path: "bill",
        name: "BillLayout",
        component: BillLayout,
        redirect: "/billLayout/bill/introduction",
        meta: {
          title: "法案分析"
        },
        children: [
          {
            path: "introduction",
            name: "BillIntroduction",
            component: BillIntroduction,
            meta: { title: "法案简介" }
          },
          {
            path: "background",
            name: "BillBackground",
            component: BillBackground,
            meta: { title: "法案背景" }
          },
          {
            path: "template",
            name: "BillTemplate",
            component: BillTemplate,
            meta: { title: "内容概要" }
          }
        ]
      },
      // 深度挖掘路由
      {
        path: "deepDig",
        name: "BillDeepDigLayout",
        component: BillDeepDigLayout,
        redirect: "/billLayout/deepDig/processOverview",
        meta: {
          title: "深度挖掘"
        },
        children: [
          {
            path: "processOverview",
            name: "BillDeepDigProcessOverview",
            component: BillDeepDigProcessOverview,
            meta: { title: "流程概要" }
          },
          {
            path: "processAnalysis",
            name: "BillDeepDigProcessAnalysis",
            component: BillDeepDigProcessAnalysis,
            meta: { title: "流程分析" }
          },
          {
            path: "poliContribution",
            name: "BillDeepDigPoliContribution",
            component: BillDeepDigPoliContribution,
            meta: { title: "政治献金" }
          }
        ]
      },
      // 影响分析路由
      {
        path: "influence",
        name: "BillInfluenceLayout",
        component: BillInfluenceLayout,
        redirect: "/billLayout/influence/industry",
        meta: {
          title: "影响分析"
        },
        children: [
          {
            path: "industry",
            name: "BillInfluenceIndustry",
            component: BillInfluenceIndustry,
            meta: { title: "对华产业影响" }
          },
          {
            path: "scientificResearch",
            name: "BillInfluenceScientificResearch",
            component: BillInfluenceScientificResearch,
            meta: { title: "对华科研影响" }
          }
        ]
      },
      {
        path: "relevantCircumstance",
        name: "BillRelevantCircumstance",
        component: BillRelevantCircumstance,
        meta: {
          title: "相关情况"
        }
      }
    ]
  },

  // 出口管制首页
  {
    path: "/exportControl",
    name: "ExportControl",
    component: ExportControl,
    meta: {
      title: "出口管制"
    }
  },

  // 政令首页
  {
    path: "/decree",
    name: "Decree",
    component: Decree,
    meta: {
      title: "政令"
    }
  },
  {
    path: "/decreeLayout",
    name: "DecreeLayoutContainer",
    component: DecreeLayoutContainer,
    redirect: "/decreeLayout/overview",
    meta: {
      title: "政令布局"
    },
    children: [
      {
        path: "overview",
        name: "DecreeOverviewLayout",
        component: DecreeOverviewLayout,
        redirect: "/decreeLayout/overview/introduction",
        meta: {
          title: "政令概况"
        },
        children: [
          {
            path: "introduction",
            name: "DecreeIntroduction",
            component: DecreeIntroduction,
            meta: { title: "政令简介" }
          },
          {
            path: "background",
            name: "DecreeBackground",
            component: DecreeBackground,
            meta: { title: "政令背景" }
          }
        ]
      },
      // 深度挖掘路由
      {
        path: "deepDig",
        name: "DeepDig",
        component: DecreeDeepDig,
        meta: {
          title: "深度挖掘"
        }
      },
      // 影响分析路由
      {
        path: "influence",
        name: "DecreeInfluence",
        component: DecreeInfluence,
        meta: {
          title: "影响分析"
        }
      }
    ]
  },

  // 市场准入限制首页
  {
    path: "/marketAccessRestrictions",
    name: "MarketAccessRestrictions",
    component: MarketAccessRestrictions,
    meta: {
      title: "市场准入限制"
    }
  },
  {
    path: "/marketAccessLayout",
    name: "MarketAccessLayout",
    component: MarketAccessLayout,
    redirect: "/marketAccessLayout/overview",
    meta: {
      title: "市场准入限制布局"
    },
    children: [
      {
        path: "overview",
        name: "MarketAccessOverview",
        component: MarketAccessOverview,
        meta: {
          title: "调查概况"
        }
      },
      {
        path: "case",
        name: "MarketAccessCase",
        component: MarketAccessCase,
        meta: {
          title: "调查案件"
        }
      }
    ]
  },
  {
    path: "/marketSingleCaseLayout",
    name: "MarketSingleCaseLayout",
    component: MarketSingleCaseLayout,
    redirect: "/marketSingleCaseLayout/overview",
    meta: {
      title: "单次调查案件布局"
    },
    children: [
      {
        path: "overview",
        name: "MarketSingleCaseOverview",
        component: MarketSingleCaseOverview,
        meta: {
          title: "调查简介"
        }
      },
      {
        path: "deepdig",
        name: "MarketSingleCaseDeepdig",
        component: MarketSingleCaseDeepdig,
        meta: {
          title: "深度挖掘"
        }
      }
    ]
  },

  // 出口管制转移过来的页面
  {
    path: "/exportControl/analysis",
    name: "analysis",
    component: () => import("@/views/exportControl/analysis/index.vue"),
    meta: {
      title: "分析页"
    }
  },
  {
    path: "/exportControl/infoplatform",
    name: "infoplatform",
    component: () => import("@/views/exportControl/infoPlatform/index.vue"),
    meta: {
      title: "信息平台"
    }
  },
  {
    path: "/exportControl/rulelimit",
    name: "rulelimit",
    component: () => import("@/views/exportControl/ruleLimit/index.vue"),
    meta: {
      title: "规则限制"
    }
  },
  {
    path: "/exportControl/ruledetail",
    name: "ruledetail",
    component: () => import("@/views/exportControl/ruleDetail/index.vue"),
    meta: {
      title: "规则详情"
    }
  },
  {
    path: "/exportControl/researchfunding",
    name: "researchfunding",
    component: () => import("@/views/exportControl/researchFunding/index.vue"),
    meta: {
      title: "科研资助"
    }
  },

  // 投融资限制
  {
    path: "/finance",
    name: "finance",
    component: Finance,
    meta: {
      title: "投融资限制"
    }
  },


  // 门户
  {
    path: "/portal1",
    name: "portal1",
    component: Portal1,
    meta: {
      title: "门户1"
    }
  },
  {
    path: "/portal2",
    name: "portal2",
    component: Portal2,
    meta: {
      title: "门户2"
    }
  },

  // 综合搜索
  {
    path: "/comprehensiveSearch",
    name: "comprehensiveSearch",
    component: ComprehensiveSearch,
    meta: {
      title: "综合搜索"
    }
  },
  {
    path: "/searchResults",
    name: "searchResults",
    component: SearchResults,
    meta: {
      title: "搜索结果"
    }
  },
  {
    path: "/chat",
    name: "chat",
    component: Chat,
    meta: {
      title: "智能问答"
    }
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

// 路由守卫 - 设置页面标题
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    // document.title = `${to.meta.title} - Think Tank`
  }
  next();
});

export default router;
