import { createRouter, createWebHashHistory } from "vue-router";
import layout from "../components/layout/index.vue";
// import children from "../components/children/index.vue";

const routes = [
  {
    path: "/login",
    name: "/login",
    meta: { title: "登录", isLogin: false },
    component: () => import("@/views/login/index"),
  },
  {
    path: "/",
    name: "app",
    redirect: "/index",
    meta: { title: "首页" },
    component: layout,
    children: [
      {
        path: "/index",
        name: "/index",
        meta: {
          title: "首页",
          breadcrumb: false,
          isMenu: false,
          isSubMenu: false,
        },
        component: () => import("@/views/index/index"),
      },
    ],
  },
  {
    path: "/404",
    name: "/404",
    meta: { title: "404", isBreadcrumb: false, isMenu: false },
    component: () => import("@/views/404"),
  },
];
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { left: 0, top: 0 };
    }
  },
});

export default router;
