import Layout from "@/components/Layout/index.vue";
import Login from "@/components/Login/login.vue";
import Vue from "vue";
import Router from "vue-router";
Vue.use(Router);

export default new Router({
  mode: "history",
  routes: [
    {
      path: "/",
      redirect: "/login", // 默认重定向到登录页
    },
    {
      path: "/login",
      name: "Login",
      component: Login, // 登录页面
    },
    {
      path: "/previews",
      component: Layout, // 使用 Layout 布局组件
      children: [
        {
          path: "",
          name: "previews",
          component: () => import("@/views/previews/index.vue"),
        },
      ],
    },
    {
      path: "/settings",
      component: Layout, // 使用 Layout 布局组件
      children: [
        {
          path: "",
          name: "settings",
          component: () => import("@/views/settings/index.vue"),
        },
      ],
    },
    {
      path: "/about",
      component: Layout, // 使用 Layout 布局组件
      children: [
        {
          path: "",
          name: "about",
          component: () => import("@/views/about/index.vue"),
        },
      ],
    },
    {
      path: "*",
      redirect: "/login", // 匹配所有未定义的路由，重定向到登录页
    },
  ],
});
