import { createRouter, createWebHistory } from "vue-router";
import Home from "../views/Home.vue";
import About from "../views/About.vue";
import ThinkTankDetail from "@/views/ThinkTankDetail/index.vue";
import ReportDetail from "@/views/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 DeepDigLayout from "@/views/bill/deepDig/index.vue";
import DeepDigProcessOverview from "@/views/bill/deepDig/processOverview/index.vue";
import DeepDigProcessAnalysis from "@/views/bill/deepDig/processAnalysis/index.vue";
import DeepDigProgressOverview from "@/views/bill/deepDig/progressAnalysis/index.vue";
import InfluenceLayout from "@/views/bill/influence/index.vue";
import InfluenceIndustry from "@/views/bill/influence/industry/index.vue";
import InfluenceScientificResearch from "@/views/bill/influence/scientificResearch/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 OverviewLayout 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";

const routes = [
	// 智库系统的主要路由
	{
		path: "/",
		name: "Home",
		component: Home,
		meta: {
			title: "首页"
		}
	},
	{
		path: "/about",
		name: "About",
		component: About,
		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: "DeepDigLayout",
				component: DeepDigLayout,
				redirect: "/billLayout/deepDig/processOverview",
				meta: {
					title: "深度挖掘"
				},
				children: [
					{
						path: "processOverview",
						name: "DeepDigProcessOverview",
						component: DeepDigProcessOverview,
						meta: { title: "流程概要" }
					},
					{
						path: "processAnalysis",
						name: "DeepDigProcessAnalysis",
						component: DeepDigProcessAnalysis,
						meta: { title: "流程分析" }
					},
					{
						path: "progressAnalysis",
						name: "DeepDigProgressAnalysis",
						component: DeepDigProgressOverview,
						meta: { title: "进程分析" }
					}
				]
			},
			// 影响分析路由
			{
				path: "influence",
				name: "InfluenceLayout",
				component: InfluenceLayout,
				redirect: "/billLayout/influence/industry",
				meta: {
					title: "影响分析"
				},
				children: [
					{
						path: "industry",
						name: "InfluenceIndustry",
						component: InfluenceIndustry,
						meta: { title: "对华产业影响" }
					},
					{
						path: "scientificResearch",
						name: "InfluenceScientificResearch",
						component: InfluenceScientificResearch,
						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: "OverviewLayout",
				component: OverviewLayout,
				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: "/analysis",
		name: "analysis",
		component: () => import("@/views/analysis/index.vue"),
		meta: {
			title: "分析页"
		}
	},
	{
		path: "/infoplatform",
		name: "infoplatform",
		component: () => import("@/views/infoPlatform/index.vue"),
		meta: {
			title: "信息平台"
		}
	},
	{
		path: "/rulelimit",
		name: "rulelimit",
		component: () => import("@/views/ruleLimit/index.vue"),
		meta: {
			title: "规则限制"
		}
	},
	{
		path: "/ruledetail",
		name: "ruledetail",
		component: () => import("@/views/ruleDetail/index.vue"),
		meta: {
			title: "规则详情"
		}
	},
	{
		path: "/researchfunding",
		name: "researchfunding",
		component: () => import("@/views/researchFunding/index.vue"),
		meta: {
			title: "科研资助"
		}
	},
	{
		path: "/decree",
		name: "decree",
		component: () => import("@/views/decree/index.vue"),
		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;
