import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/main.vue'
import iframeView from '@/views/iframeRoute.vue'
import login from '@/views/login.vue'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/login',
      name: 'login',
      component: login
    },
    {
      path: '/details/:title',
      name: 'Details',
      component: () => import('../views/Details.vue')
    },
    {
      path: '/admin',
      name: 'admin',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/admin.vue')
    },
    {
      path: "/iframe/:title/:id",
      name: "iframe",
      meta: { title: "动态路由" },
      component: iframeView
    }
  ]
})

export default router
