import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import home from "./home";

import list from "./list";
import list2 from "./list/list2";
import list3 from "./list/list3";

import BasicLayout from "./backend/components/layout/BasicLayout";
import Backend from "./backend";
import Total from "./backend/total";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "Home",
    component: home,
    children: [],
  },
  {
    path: "/list",
    name: "list",
    component: list,
    children: [],
  },
  {
    path: "/list2",
    name: "list2",
    component: list2,
  },
  {
    path: "/list3",
    name: "list3",
    component: list3,
  },
  {
    path: "/backend",
    name: "backend",
    component: BasicLayout,
    redirect: "/backend/upload",
    children: [
      {
        path: "/backend/upload",
        name: "upload",
        component: Backend,
        meta: { title: "上传管理" },
      },
      {
        path: "/backend/total",
        name: "total",
        component: Total,
        meta: { title: "上传统计" },
      },
    ],
  },
];

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

export const menuData = routes.find((e) => {
  return e.name == "backend";
});
export default router;
