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: 'orders',
          name: 'Orders',
          component: () => import('@/views/merchant/Orders/index.vue'),
          meta: { title: '订单管理', icon: 'Document' },
          redirect: 'pending', // 当访问 /merchant/orders 时，重定向到其子路由 'pending'
          children: [
            {
              path: 'pending',
              name: 'OrdersPending',
              component: () => import('@/views/merchant/Orders/Pending.vue'),
              meta: { title: '待办订单' },
            },
            {
              path: 'refund',
              name: 'OrdersRefund',
              component: () => import('@/views/merchant/Orders/Refund.vue'),
              meta: { title: '退款管理' },
            },
          ],
        },

        // 顾客评价模块
        {
          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: 'reply-management',
              name: 'ReviewReplyManagement',
              component: () => import('@/views/merchant/Reviews/ReplyManagement.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: 'finance',
          name: 'Finance',
          component: () => import('@/views/merchant/Finance/index.vue'),
          meta: { title: '财务管理', icon: 'Coin' },
          redirect: 'daily-revenue',
          children: [
            {
              path: 'daily-revenue',
              name: 'DailyRevenue',
              component: () => import('@/views/merchant/Finance/DailyRevenue.vue'),
              meta: { title: '每日收益' },
            },
            {
              path: 'revenue-management',
              name: 'RevenueManagement',
              component: () => import('@/views/merchant/Finance/RevenueManagement.vue'),
              meta: { title: '收支管理' },
            },
            {
              path: 'finance-download',
              name: 'FinanceDownload',
              component: () => import('@/views/merchant/Finance/FinanceDownload.vue'),
              meta: { title: '财务下载' },
            },
            {
              path: 'account-collection',
              name: 'AccountCollection',
              component: () => import('@/views/merchant/Finance/AccountCollection.vue'),
              meta: { title: '收款账号' },
            },
          ],
        },
      ],
    },
  ],
})

export default merchantRouter
