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

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    name: "index",
    component: () => import("../views/index"),
    children: [
      {
        path: "",
        name: "index",
        component: () => import("../views/home"),
      },
      {
        path: "/music",
        name: "music",
        component: () => import("../views/music"),
      },
      {
        path: "/video",
        name: "video",
        component: () => import("../views/video"),
      },
      {
        path: "/down",
        name: "down",
        component: () => import("../views/down"),
      },
    ],
  },
  {
    path: "/search",
    name: "search",
    component: () => import("../views/search"),
  },
  {
    path: "/videoDetail",
    name: "videoDetail",
    component: () => import("../views/video/detail"),
  },
  {
    path: "/musicAlum",
    name: "musicAlum",
    component: () => import("../views/music/album"),
  },
  {
    path: "/musicDetail",
    name: "musicDetail",
    component: () => import("../views/musicDetail"),
  },
];
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
router.beforeEach((_to, _form, _next) => {
  window.scrollTo({
    top: 0,
  });
  _next();
});
export default router;
