import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import layout from "@/layout/index.vue";
import scene from "@/scene/index.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    redirect: { name: "home" },
  },
  //智慧园区管理平台
  {
    path: "/system",
    name: "system",
    redirect: { name: "home" },
    component: layout,
    children: [
      {
        path: "home",
        name: "home",
        meta: {
          title: "首页",
        },
        components: {
          default: scene,
          // LeftSidebar: LeftSidebar 的缩写
          LeftSidebar: () => import("@/views/home/left.vue"),
          // 它们与 `<router-view>` 上的 `name` 属性匹配
          RightSidebar: () => import("@/views/home/right.vue"),
        },
      },
      {
        path: "source",
        name: "source",
        meta: {
          title: "源",
        },
        components: {
          default: scene,
          // LeftSidebar: LeftSidebar 的缩写
          LeftSidebar: () => import("@/views/source/left.vue"),
          // 它们与 `<router-view>` 上的 `name` 属性匹配
          RightSidebar: () => import("@/views/source/right.vue"),
        },
      },
      {
        path: "storage",
        name: "storage",
        meta: {
          title: "储",
        },
        components: {
          default: scene,
          // LeftSidebar: LeftSidebar 的缩写
          LeftSidebar: () => import("@/views/storage/left.vue"),
          // 它们与 `<router-view>` 上的 `name` 属性匹配
          RightSidebar: () => import("@/views/storage/right.vue"),
        },
      },
      {
        path: "soc",
        name: "soc",
        meta: {
          title: "荷",
        },
        components: {
          default: scene,
          // LeftSidebar: LeftSidebar 的缩写
          LeftSidebar: () => import("@/views/soc/left.vue"),
          // 它们与 `<router-view>` 上的 `name` 属性匹配
          RightSidebar: () => import("@/views/soc/right.vue"),
        },
      },
      {
        path: "net",
        name: "net",
        meta: {
          title: "网",
        },
        components: {
          default: scene,
          // LeftSidebar: LeftSidebar 的缩写
          LeftSidebar: () => import("@/views/net/left.vue"),
          // 它们与 `<router-view>` 上的 `name` 属性匹配
          RightSidebar: () => import("@/views/net/right.vue"),
        },
      },
      {
        path: "device",
        name: "device",
        meta: {
          title: "设备",
        },
        components: {
          default: scene,
          // LeftSidebar: LeftSidebar 的缩写
          LeftSidebar: () => import("@/views/device/left.vue"),
          // 它们与 `<router-view>` 上的 `name` 属性匹配
          RightSidebar: () => import("@/views/device/right.vue"),
        },
      },
    ],
  },
];

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

export default router;
