import { createRouter, createWebHistory } from "vue-router";
import AppShell from "../layouts/AppShell.vue";

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: "/",
      component: AppShell,
      children: [
        { path: "", redirect: "/overview" },
        { path: "overview", name: "overview", meta: { title: "工作总览" }, component: () => import("../views/overview/OverviewView.vue") },
        { path: "gis", name: "gis", meta: { title: "GIS 态势" }, component: () => import("../views/gis/GisView.vue") },
        { path: "runs/:runId?", name: "runs", meta: { title: "全链路运行" }, component: () => import("../views/runs/RunsView.vue") },
        { path: "planning", name: "planning", meta: { title: "巡检计划" }, component: () => import("../views/planning/PlanningView.vue") },
        { path: "tasks/:taskId?", name: "tasks", meta: { title: "巡检任务" }, component: () => import("../views/tasks/TasksView.vue") },
        { path: "routes", name: "routes", meta: { title: "航线中心" }, component: () => import("../views/routes/RoutesView.vue") },
        { path: "uav-operations", name: "uav-operations", meta: { title: "无人机运行" }, component: () => import("../views/uav-operations/UavOperationsView.vue") },
        { path: "resources/:resourceId?", name: "resources", meta: { title: "数据资源" }, component: () => import("../views/resources/ResourcesView.vue") },
        { path: "analysis/:entityType?/:entityId?", name: "analysis", meta: { title: "智能分析" }, component: () => import("../views/analysis/AnalysisView.vue") },
        { path: "alarms/:alarmId?", name: "alarms", meta: { title: "告警中心" }, component: () => import("../views/alarms/AlarmsView.vue") },
        { path: "workorders/:workorderId?", name: "workorders", meta: { title: "工单中心" }, component: () => import("../views/workorders/WorkordersView.vue") },
        { path: "algorithm-assets/:entityType?/:entityId?", name: "algorithm-assets", meta: { title: "样本与模型" }, component: () => import("../views/algorithm-assets/AlgorithmAssetsView.vue") },
        { path: "archives", name: "archives", meta: { title: "报告归档" }, component: () => import("../views/archives/ArchivesView.vue") },
        { path: "operations", name: "operations", meta: { title: "系统运维" }, component: () => import("../views/operations/OperationsView.vue") }
      ]
    },
    { path: "/:pathMatch(.*)*", redirect: "/overview" }
  ],
  scrollBehavior: () => ({ top: 0 })
});

export default router;
