import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'

export default defineUniPages({
  easycom: {
    autoscan: true,
    custom: {
      '^u-(.*)': 'uview-plus/components/u-$1/u-$1.vue',
      '^uni-(.*)': '@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue',
      '^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)':
        'z-paging/components/z-paging$1/z-paging$1.vue',
    },
  },
  pages: [
    {
      path: 'pages/index/home/index',
      aliasPath: '/',
      meta: {
        key: 'home',
      },
      style: {
        navigationBarTitleText: '',
      },
    },
    {
      path: 'pages/index/order/index',
      aliasPath: '/order',
      meta: {
        key: 'order',
      },
      style: {
        navigationBarTitleText: '订单',
      },
    },
    {
      path: 'pages/index/personal/index',
      aliasPath: '/personal',
      meta: {
        key: 'personal',
      },
      style: {
        navigationBarTitleText: '我的',
      },
    },
    {
      path: 'pages/login/index',
      aliasPath: '/login',
      style: {
        // navigationStyle: 'custom',
        navigationBarTitleText: '登录',
      },
    },
    {
      path: 'pages/errors/404/index',
      aliasPath: '/404',
      style: {
        navigationBarTitleText: '404',
      },
    },
  ],
  subPackages: [
    {
      root: 'pages/webview',
      pages: [
        {
          path: 'index',
          aliasPath: '/webview',
          style: {
            navigationBarTitleText: 'webview',
          },
        },
      ],
    },
    {
      root: 'pages/form',
      name: 'form',
      pages: [
        {
          path: 'index',
          aliasPath: '/form',
          style: {
            navigationBarTitleText: '填写订单',
          },
        },
        {
          path: 'complete',
          aliasPath: '/complete',
          style: {
            navigationBarTitleText: '订单完成',
          },
        },
      ],
    },
    {
      root: 'pages/other',
      name: 'other',
      pages: [
        {
          path: 'income-details',
          aliasPath: '/income-details',
          style: {
            navigationBarTitleText: '收入详情',
          },
        },
        {
          path: 'edit-userinfo',
          aliasPath: '/edit-userinfo',
          style: {
            navigationBarTitleText: '编辑资料',
          },
        },
        {
          path: 'switch',
          aliasPath: '/switch',
          style: {
            navigationBarTitleText: '成为陪诊师',
          },
        },
      ],
    },
    // {
    //   root: 'pages/middleware',
    //   pages: [
    //     {
    //       path: 'index',
    //       aliasPath: '/middleware',
    //       meta: {
    //         middleware: ['realname'],
    //       },
    //       style: {
    //         navigationBarTitleText: '路由中间件',
    //       },
    //     },
    //   ],
    // },
    {
      root: 'pages/statement',
      pages: [
        {
          path: 'index',
          aliasPath: '/statement',
          style: {
            navigationBarTitleText: '产品服务协议',
          },
        },
      ],
    },
    {
      root: 'pages/realname',
      pages: [
        {
          path: 'index',
          aliasPath: '/realname',
          style: {
            navigationBarTitleText: '实名认证',
          },
        },
      ],
    },
    {
      root: 'pages/contact',
      pages: [
        {
          path: 'index',
          aliasPath: '/contact',
          style: {
            navigationBarTitleText: '联系我们',
          },
        },
      ],
    },
  ],
  preloadRule: {
    "pages/index/home/index": {
      network: "all",
      packages: ["pages/form", "pages/other"]  // 在 pages/index 页面中预加载名为 pack1 分包内容
    }
  },
  tabBar: {
    // color: '#999999',
    // selectedColor: '#018d71',
    // backgroundColor: '#F8F8F8',
    list: [
      {
        // iconPath: 'static/tabbar/tab-home.png',
        // selectedIconPath: 'static/tabbar/tab-home-active.png',
        pagePath: 'pages/index/home/index',
        // text: '主页',
      },
      {
        // iconPath: 'static/tabbar/tab-example.png',
        // selectedIconPath: 'static/tabbar/tab-example-active.png',
        pagePath: 'pages/index/order/index',
        // text: '示例',
      },
      {
        // iconPath: 'static/tabbar/tab-personal.png',
        // selectedIconPath: 'static/tabbar/tab-personal-active.png',
        pagePath: 'pages/index/personal/index',
        // text: '我的', 
      },
    ],
  },
  globalStyle: {
    navigationBarTextStyle: 'white',
    navigationBarTitleText: '',
    navigationBarBackgroundColor: '#FF8CA6',
    backgroundColor: '#ffffff',
    // navigationStyle: "custom",
    "usingComponents": {
      // "van-cell": "/wxcomponents/vant-weapp/cell",
      // "van-checkbox": "/wxcomponents/vant-weapp/checkbox",
      // "van-cell-group": "/wxcomponents/vant-weapp/cell-group",
      // "van-checkbox-group": "/wxcomponents/vant-weapp/checkbox-group",
      "van-rate": "/wxcomponents/vant-weapp/rate",
      "van-icon": "/wxcomponents/vant-weapp/icon"
      // "van-tabbar": "/wxcomponents/@vant/weapp/tabbar/index",
      // "van-tabbar-item": "/wxcomponents/@vant/weapp/tabbar-item/index"
    }
  },
  // condition: {
  //   current: 0,
  //   list: [
  //     {
  //       name: 'pages/contact/index',
  //       path: 'pages/contact/index',
  //     },
  //   ],
  // },
})
