import { createWebHistory, createRouter } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Index',
    component: () => import('./views/Index.vue'),
    children: [
      {
        path: '/Home',
        name: 'Home',
        component: () => import('./views/Home.vue'),
      },
      {
        path: '/About',
        name: 'About',
        component: () => import('./views/About.vue'),
      },
      {
        path: '/Service',
        name: 'Service',
        component: () => import('./views/Service.vue'),
      },
      {
        path: '/Apply',
        name: 'Apply',
        component: () => import('./views/Apply.vue'),
      },
    ]
  },
  {
    path: '/News',
    name: 'News',
    component: () => import('./views/News.vue'),
    meta: {
      title: '新闻资讯',
      noLogin: true,
    }
  },
  {
    path: `/NewsDetail`,
    name: 'NewsDetail',
    component: () => import('./views/NewsDetail.vue'),
    meta: {
      title: '新闻详情',
      noLogin: true,
    }
  },
  {
    path: '/Support',
    name: 'Support',
    component: () => import('./views/Support.vue'),
    meta: {
      title: '总部支持政策',
      noLogin: true,
    }
  },
  {
    path: '/Service/Demand',
    name: 'Demand',
    component: () => import('./views/Service/Demand.vue'),
    meta: {
      title: '需求分析',
      noLogin: true,
    }
  },
  {
    path: '/Service/Model',
    name: 'Model',
    component: () => import('./views/Service/Model.vue'),
    meta: {
      title: '模式设计',
      noLogin: true,
    }
  },
  {
    path: '/Service/Development',
    name: 'Development',
    component: () => import('./views/Service/Development.vue'),
    meta: {
      title: '系统开发',
      noLogin: true,
    }
  },
  {
    path: '/Service/Plan',
    name: 'Plan',
    component: () => import('./views/Service/Plan.vue'),
    meta: {
      title: '策划运营',
      noLogin: true,
    }
  },
  {
    path: '/Service/Pay',
    name: 'Pay',
    component: () => import('./views/Service/Pay.vue'),
    meta: {
      title: '支付代付',
      noLogin: true,
    }
  },
  {
    path: '/Service/Finance',
    name: 'Finance',
    component: () => import('./views/Service/Finance.vue'),
    meta: {
      title: '财税筹划',
      noLogin: true,
    }
  },
  {
    path: '/Service/Brand',
    name: 'Brand',
    component: () => import('./views/Service/Brand.vue'),
    meta: {
      title: '品牌管理',
      noLogin: true,
    }
  },
  {
    path: '/Service/Consultation',
    name: 'Consultation',
    component: () => import('./views/Service/Consultation.vue'),
    meta: {
      title: '企业咨询',
      noLogin: true,
    }
  },
  {
    path: '/Service/Resources',
    name: 'Resources',
    component: () => import('./views/Service/Resources.vue'),
    meta: {
      title: '资源整接',
      noLogin: true,
    }
  },
  {
    path: '/BusinessArea',
    name: 'BusinessArea',
    component: () => import('./views/BusinessArea.vue'),
    meta: {
      title: '业务范围',
      noLogin: true,
    }
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/404'
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
  /**
   * 页面跳转后的滚动行为
   * @param {object} to - 目标路由对象
   * @param {object} from - 来源路由对象
   * @param {object} savedPosition - 保存的滚动位置（仅在前进/后退时生效）
   * @returns {object} - 目标滚动位置
   */
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  },
})

// createApp(App).use(router).mount('#app')
export default router
