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

const merchantRouter = createRouter({
  history: createWebHistory('/'),
  routes: [
    {
      path: '/merchant',
      component: () => import('@/views/merchant/Home.vue'), // 主布局组件
      redirect: '/merchant/dashboard', // 当访问 /merchant 时，重定向到 /merchant/dashboard
      children: [
        // 首页 - 默认路由
        {
          path: 'dashboard',
          name: 'Dashboard',
          component: () => import('@/views/merchant/Dashboard/index.vue'),
          meta: { title: '首页', icon: 'HomeFilled' },
        },

        // 顾客评价模块
        {
          path: 'reviews',
          name: 'Reviews',
          component: () => import('@/views/merchant/Reviews/index.vue'),
          meta: { title: '顾客评价', icon: 'Star' },
          redirect: 'store-reviews',
          children: [
            {
              path: 'store-reviews',
              name: 'StoreReviews',
              component: () => import('@/views/merchant/Reviews/StoreReviews.vue'),
              meta: { title: '门店评价' },
            }
          ],
        },

        // 商品管理模块
        {
          path: 'products',
          name: 'Products',
          component: () => import('@/views/merchant/Products/index.vue'),
          meta: { title: '商品管理', icon: 'Goods' },
          redirect: 'list',
          children: [
            {
              path: 'list',
              name: 'ProductList',
              component: () => import('@/views/merchant/Products/ProductList.vue'),
              meta: { title: '菜品列表' },
            },
          ],
        },

        // 门店管理模块
        {
          path: 'stores',
          name: 'Stores',
          component: () => import('@/views/merchant/Stores/index.vue'),
          meta: { title: '门店管理', icon: 'Shop' },
          redirect: 'store-info',
          children: [
            {
              path: 'store-info',
              name: 'StoreInfo',
              component: () => import('@/views/merchant/Stores/StoreInfo.vue'),
              meta: { title: '门店信息' },
            },
          ],
        },

        // 订单管理模块
        {
          path: 'order',
          name: 'order',
          component: () => import('@/views/merchant/order/index.vue'),
          meta: { title: '订单管理', icon: 'Document' },
          redirect: 'pending', // 当访问 /merchant/order 时，重定向到其子路由 'pending'
          children: [
            {
              path: 'OrderManager',
              name: 'OrderManager',
              component: () => import('@/views/merchant/order/OrderManager.vue'),
              meta: { title: '待办订单' },
            }
          ],
        },
      ],
    },
  ],
})

export default merchantRouter
