Przeglądaj źródła

fix nutui use language

wuzj 1 tydzień temu
rodzic
commit
150911253e

+ 1 - 11
babel.config.js

@@ -15,16 +15,6 @@ module.exports = {
       'corejs': false,
       'helpers': true,
       'regenerator': true
-    }],
-    [
-      "import",
-      {
-        "libraryName": "@nutui/nutui-taro",
-        "libraryDirectory": "dist/packages/_es",
-        "style": true,
-        "camel2DashComponentName": false
-      },
-      "nutui-taro"
-    ]
+    }]
   ]
 }

+ 4 - 4
components.d.ts

@@ -13,14 +13,14 @@ declare module 'vue' {
     HostOnly: typeof import('./src/components/HostOnly/index.vue')['default']
     NutButton: typeof import('@nutui/nutui-taro')['Button']
     NutEmpty: typeof import('@nutui/nutui-taro')['Empty']
+    NutInfiniteLoading: typeof import('@nutui/nutui-taro')['InfiniteLoading']
     NutInput: typeof import('@nutui/nutui-taro')['Input']
-    NutLoading: typeof import('@nutui/nutui-taro')['Loading']
     NutRadio: typeof import('@nutui/nutui-taro')['Radio']
-    NutRadiogroup: typeof import('@nutui/nutui-taro')['Radiogroup']
+    NutRadioGroup: typeof import('@nutui/nutui-taro')['RadioGroup']
+    NutRange: typeof import('@nutui/nutui-taro')['Range']
     NutRate: typeof import('@nutui/nutui-taro')['Rate']
     NutSearchbar: typeof import('@nutui/nutui-taro')['Searchbar']
-    NutSlider: typeof import('@nutui/nutui-taro')['Slider']
-    NutTabpane: typeof import('@nutui/nutui-taro')['Tabpane']
+    NutTabPane: typeof import('@nutui/nutui-taro')['TabPane']
     NutTabs: typeof import('@nutui/nutui-taro')['Tabs']
     PlayerList: typeof import('./src/components/PlayerList/index.vue')['default']
     PlayerOnly: typeof import('./src/components/PlayerOnly/index.vue')['default']

+ 26 - 2
config/index.ts

@@ -2,6 +2,20 @@ import { defineConfig, type UserConfigExport } from '@tarojs/cli'
 import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
 import { VueLoaderPlugin } from 'vue-loader'
 import { resolve } from 'path'
+import ComponentsPlugin from 'unplugin-vue-components/webpack'
+
+const NutUIResolver = () => {
+  return (name) => {
+    if (name.startsWith('Nut')) {
+      const partialName = name.slice(3)
+      return {
+        name: partialName,
+        from: '@nutui/nutui-taro',
+        sideEffects: `@nutui/nutui-taro/dist/packages/${partialName.toLowerCase()}/style`,
+      }
+    }
+  }
+}
 
 export default defineConfig({
   projectName: 'miniprogram-linejoy',
@@ -61,7 +75,12 @@ export default defineConfig({
     webpackChain(chain) {
       chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
 
-      // 为webpack添加路径别名
+      chain.plugin('unplugin-vue-components').use(
+        ComponentsPlugin({
+          resolvers: [NutUIResolver()],
+        })
+      )
+
       chain.resolve.alias
         .set('@', resolve(__dirname, '..', 'src'))
     }
@@ -86,7 +105,12 @@ export default defineConfig({
     webpackChain(chain) {
       chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
 
-      // 为webpack添加路径别名
+      chain.plugin('unplugin-vue-components').use(
+        ComponentsPlugin({
+          resolvers: [NutUIResolver()],
+        })
+      )
+
       chain.resolve.alias
         .set('@', resolve(__dirname, '..', 'src'))
     }

+ 0 - 1
package.json

@@ -58,7 +58,6 @@
     "@typescript-eslint/parser": "^6.2.0",
     "@vue/babel-plugin-jsx": "^1.0.6",
     "@vue/compiler-sfc": "^3.0.0",
-    "babel-plugin-import": "^1.13.8",
     "babel-preset-taro": "4.0.9",
     "css-loader": "3.4.2",
     "eslint": "^8.12.0",

+ 0 - 12
pnpm-lock.yaml

@@ -105,9 +105,6 @@ importers:
       '@vue/compiler-sfc':
         specifier: ^3.0.0
         version: 3.5.13
-      babel-plugin-import:
-        specifier: ^1.13.8
-        version: 1.13.8
       babel-preset-taro:
         specifier: 4.0.9
         version: 4.0.9(@babel/core@7.26.10)(@babel/plugin-transform-typescript@7.27.0(@babel/core@7.26.10))(@vue/babel-plugin-jsx@1.4.0(@babel/core@7.26.10))
@@ -2221,9 +2218,6 @@ packages:
   babel-plugin-dynamic-import-node@2.3.3:
     resolution: {integrity: sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==}
 
-  babel-plugin-import@1.13.8:
-    resolution: {integrity: sha512-36babpjra5m3gca44V6tSTomeBlPA7cHUynrE2WiQIm3rEGD9xy28MKsx5IdO45EbnpJY7Jrgd00C6Dwt/l/2Q==}
-
   babel-plugin-polyfill-corejs2@0.4.13:
     resolution: {integrity: sha512-3sX/eOms8kd3q2KZ6DAhKPc0dgm525Gqq5NtWKZ7QYYZEv57OQ54KtblzJzH1lQF/eQxO8KjWGIK9IPUJNus5g==}
     peerDependencies:
@@ -8628,12 +8622,6 @@ snapshots:
     dependencies:
       object.assign: 4.1.7
 
-  babel-plugin-import@1.13.8:
-    dependencies:
-      '@babel/helper-module-imports': 7.25.9
-    transitivePeerDependencies:
-      - supports-color
-
   babel-plugin-polyfill-corejs2@0.4.13(@babel/core@7.26.10):
     dependencies:
       '@babel/compat-data': 7.26.8

+ 9 - 9
src/pages/game-detail/index.vue

@@ -41,21 +41,21 @@
       
       <!-- 游戏详情选项卡 -->
       <nut-tabs v-model="activeTab" title-active-color="#3C92FB">
-        <nut-tabpane title="游戏介绍">
+        <nut-tab-pane title="游戏介绍">
           <view class="game-section">
             <view class="section-title">游戏介绍</view>
             <view class="section-content">{{ game.description }}</view>
           </view>
-        </nut-tabpane>
+        </nut-tab-pane>
         
-        <nut-tabpane title="游戏规则">
+        <nut-tab-pane title="游戏规则">
           <view class="game-section">
             <view class="section-title">游戏规则</view>
             <view class="section-content">{{ game.rules }}</view>
           </view>
-        </nut-tabpane>
+        </nut-tab-pane>
         
-        <nut-tabpane title="游戏提示">
+        <nut-tab-pane title="游戏提示">
           <view class="game-section">
             <view class="section-title">游戏提示</view>
             <view class="tip-list">
@@ -65,9 +65,9 @@
               </view>
             </view>
           </view>
-        </nut-tabpane>
+        </nut-tab-pane>
         
-        <nut-tabpane title="示例">
+        <nut-tab-pane title="示例">
           <view class="game-section" v-if="game.examples && game.examples.length > 0">
             <view v-for="(example, index) in game.examples" :key="index" class="example-item">
               <view class="example-question">
@@ -81,12 +81,12 @@
             </view>
           </view>
           <nut-empty v-else description="暂无示例" image="empty" />
-        </nut-tabpane>
+        </nut-tab-pane>
       </nut-tabs>
     </view>
     
     <view v-else-if="loading" class="loading-container">
-      <nut-loading size="24"></nut-loading>
+      <nut-infinite-loading size="24"></nut-infinite-loading>
       <text>加载中...</text>
     </view>
     

+ 12 - 12
src/pages/index/index.vue

@@ -5,7 +5,7 @@
     </view>
     
     <nut-tabs v-model="activeTab">
-      <nut-tabpane title="推荐">
+      <nut-tab-pane title="推荐">
         <view class="game-list" v-if="!gameStore.loading && filteredGames.length > 0">
           <game-card
             v-for="game in filteredGames"
@@ -23,12 +23,12 @@
         </view>
         <nut-empty v-else-if="!gameStore.loading && filteredGames.length === 0" description="没有找到相关游戏" image="empty" />
         <view class="loading-container" v-else>
-          <nut-loading size="20"></nut-loading>
+          <nut-infinite-loading size="20"></nut-infinite-loading>
           <text>加载中...</text>
         </view>
-      </nut-tabpane>
+      </nut-tab-pane>
       
-      <nut-tabpane title="热门">
+      <nut-tab-pane title="热门">
         <view class="game-list" v-if="!gameStore.loading && hotGames.length > 0">
           <game-card
             v-for="game in hotGames"
@@ -46,12 +46,12 @@
         </view>
         <nut-empty v-else-if="!gameStore.loading && hotGames.length === 0" description="暂无热门游戏" image="empty" />
         <view class="loading-container" v-else>
-          <nut-loading size="20"></nut-loading>
+          <nut-infinite-loading size="20"></nut-infinite-loading>
           <text>加载中...</text>
         </view>
-      </nut-tabpane>
+      </nut-tab-pane>
       
-      <nut-tabpane title="社交">
+      <nut-tab-pane title="社交">
         <view class="game-list" v-if="!gameStore.loading && socialGames.length > 0">
           <game-card
             v-for="game in socialGames"
@@ -69,12 +69,12 @@
         </view>
         <nut-empty v-else-if="!gameStore.loading && socialGames.length === 0" description="暂无社交游戏" image="empty" />
         <view class="loading-container" v-else>
-          <nut-loading size="20"></nut-loading>
+          <nut-infinite-loading size="20"></nut-infinite-loading>
           <text>加载中...</text>
         </view>
-      </nut-tabpane>
+      </nut-tab-pane>
       
-      <nut-tabpane title="音乐">
+      <nut-tab-pane title="音乐">
         <view class="game-list" v-if="!gameStore.loading && musicGames.length > 0">
           <game-card
             v-for="game in musicGames"
@@ -92,10 +92,10 @@
         </view>
         <nut-empty v-else-if="!gameStore.loading && musicGames.length === 0" description="暂无音乐游戏" image="empty" />
         <view class="loading-container" v-else>
-          <nut-loading size="20"></nut-loading>
+          <nut-infinite-loading size="20"></nut-infinite-loading>
           <text>加载中...</text>
         </view>
-      </nut-tabpane>
+      </nut-tab-pane>
     </nut-tabs>
   </view>
 </template>

+ 3 - 3
src/pages/room/create/index.vue

@@ -24,7 +24,7 @@
       <view class="setting-item">
         <view class="setting-label">最大人数</view>
         <view class="setting-slider">
-          <nut-slider v-model="maxPlayers" :min="2" :max="12"></nut-slider>
+          <nut-range v-model="maxPlayers" :min="2" :max="12"></nut-range>
           <view class="slider-value">{{ maxPlayers }}人</view>
         </view>
       </view>
@@ -32,10 +32,10 @@
       <view class="setting-item">
         <view class="setting-label">房间可见性</view>
         <view class="visibility-options">
-          <nut-radiogroup v-model="roomVisibility">
+          <nut-radio-group v-model="roomVisibility">
             <nut-radio label="private">仅限密码</nut-radio>
             <nut-radio label="public">公开房间</nut-radio>
-          </nut-radiogroup>
+          </nut-radio-group>
         </view>
       </view>