Jelajahi Sumber

refactor(tabbar): 将tabbar配置抽离为单独模块以提高可维护性

将pages.config.ts中的tabbar配置抽离到单独的tabbarList.ts文件
移除pages.json中无用的__esModule字段
feige996 10 bulan lalu
induk
melakukan
9a34868fb7
3 mengubah file dengan 29 tambahan dan 28 penghapusan
  1. 2 27
      pages.config.ts
  2. 27 0
      src/components/fg-tabbar/tabbarList.ts
  3. 0 1
      src/pages.json

+ 2 - 27
pages.config.ts

@@ -1,4 +1,5 @@
 import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
+import tabbarList from './src/components/fg-tabbar/tabbarList'
 
 export default defineUniPages({
   globalStyle: {
@@ -28,32 +29,6 @@ export default defineUniPages({
     fontSize: '10px',
     iconWidth: '24px',
     spacing: '3px',
-    list: [
-      // 注意tabbar路由需要使用 layout:tabbar 布局
-      {
-        pagePath: 'pages/index/index',
-        text: '首页',
-        icon: 'home',
-        iconType: 'wot',
-      },
-      {
-        pagePath: 'pages/about/about',
-        text: '关于',
-        icon: 'i-carbon-code',
-        iconType: 'unocss',
-      },
-      // {
-      //   pagePath: 'pages/my/index',
-      //   text: '我的',
-      //   icon: '/static/logo.svg',
-      //   iconType: 'local',
-      // },
-      // {
-      //   pagePath: 'pages/mine/index',
-      //   text: '我的',
-      //   icon: 'iconfont icon-my',
-      //   iconType: 'iconfont',
-      // },
-    ],
+    list: tabbarList as any,
   },
 })

+ 27 - 0
src/components/fg-tabbar/tabbarList.ts

@@ -0,0 +1,27 @@
+export default [
+  // 注意tabbar路由需要使用 layout:tabbar 布局
+  {
+    pagePath: 'pages/index/index',
+    text: '首页',
+    icon: 'home',
+    iconType: 'wot',
+  },
+  {
+    pagePath: 'pages/about/about',
+    text: '关于',
+    icon: 'i-carbon-code',
+    iconType: 'unocss',
+  },
+  // {
+  //   pagePath: 'pages/my/index',
+  //   text: '我的',
+  //   icon: '/static/logo.svg',
+  //   iconType: 'local',
+  // },
+  // {
+  //   pagePath: 'pages/mine/index',
+  //   text: '我的',
+  //   icon: 'iconfont icon-my',
+  //   iconType: 'iconfont',
+  // },
+]

+ 0 - 1
src/pages.json

@@ -39,7 +39,6 @@
       }
     ]
   },
-  "__esModule": true,
   "pages": [
     {
       "path": "pages/index/index",