tang-ui-x 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +180 -158
  2. package/components/TActionSheet/index.uvue +37 -37
  3. package/components/TAvatar/index.uvue +31 -31
  4. package/components/TBadge/index.uvue +4 -4
  5. package/components/TButton/index.uvue +121 -121
  6. package/components/TCard/index.uvue +48 -48
  7. package/components/TCheckbox/index.uvue +54 -50
  8. package/components/TCheckboxGroup/index.uvue +33 -21
  9. package/components/TCol/index.uvue +8 -8
  10. package/components/TCollapse/index.uvue +21 -18
  11. package/components/TCollapseItem/index.uvue +53 -57
  12. package/components/TDateTimePicker/README.md +31 -31
  13. package/components/TDateTimePicker/index.uvue +699 -386
  14. package/components/TDialog/index.uvue +50 -50
  15. package/components/TEmpty/index.uvue +56 -41
  16. package/components/TErrorState/index.uvue +38 -38
  17. package/components/TForm/index.uvue +54 -31
  18. package/components/TForm/type.uts +0 -3
  19. package/components/TGrid/index.uvue +2 -7
  20. package/components/TGridItem/index.uvue +55 -55
  21. package/components/TIcon/index.uvue +6 -4
  22. package/components/TImage/index.uvue +36 -36
  23. package/components/TInput/index.uvue +150 -147
  24. package/components/TList/index.uvue +25 -25
  25. package/components/TListItem/index.uvue +35 -35
  26. package/components/TLoading/index.uvue +23 -23
  27. package/components/TNavBar/index.uvue +23 -23
  28. package/components/TNoticeBar/index.uvue +6 -6
  29. package/components/TPicker/index.uvue +48 -46
  30. package/components/TPopup/index.uvue +10 -10
  31. package/components/TRadioButton/index.uvue +81 -62
  32. package/components/TRadioGroup/index.uvue +35 -22
  33. package/components/TRate/index.uvue +25 -20
  34. package/components/TSearchBar/index.uvue +54 -54
  35. package/components/TSelect/index.uvue +13 -8
  36. package/components/TSlider/index.uvue +15 -15
  37. package/components/TSwiper/index.uvue +71 -71
  38. package/components/TSwitch/index.uvue +157 -149
  39. package/components/TSwitch/type.uts +6 -0
  40. package/components/TTextarea/index.uvue +42 -42
  41. package/components/Tabs/index.uvue +5 -3
  42. package/components/Tags/index.uvue +2 -3
  43. package/composables/i18n/manager.uts +68 -126
  44. package/composables/useI18n.uts +2 -2
  45. package/composables/useModal.uts +13 -13
  46. package/composables/useToast.uts +28 -12
  47. package/index.uts +2 -2
  48. package/package.json +50 -21
  49. package/static/tailwind.css +2017 -0
  50. package/static/theme.scss +235 -0
  51. package/types/index.d.ts +251 -0
  52. package/composables/i18n/manager-demo.uts +0 -104
  53. package/composables/i18n/manager.test.uts +0 -182
  54. package/composables/i18n/register-demo.uts +0 -125
  55. package/composables/i18n/task22-verification.uts +0 -198
  56. package/composables/i18n/task23-verification.uts +0 -343
  57. package/composables/i18n/task8-demo.uts +0 -93
  58. package/composables/i18n/task8-verification.uts +0 -98
  59. package/composables/i18n/test-task23.uts +0 -9
  60. package/composables/i18n/useI18n-verification.uts +0 -105
  61. package/composables/i18n/validation-demo.uts +0 -45
  62. package/composables/i18n/validation-test.uts +0 -106
  63. package/locales/cross-platform-verification.uts +0 -510
  64. package/locales/init-verification.uts +0 -101
  65. package/locales/run-verification.uts +0 -16
package/README.md CHANGED
@@ -65,8 +65,8 @@ pnpm add tang-ui-x
65
65
  </template>
66
66
 
67
67
  <script module="TButton" lang="uts">
68
- import TButton from 'tang-ui-x/components/TButton/index.uvue'
69
- export default TButton
68
+ import TButton from 'tang-ui-x/components/TButton/index.uvue'
69
+ export default TButton
70
70
  </script>
71
71
  ```
72
72
 
@@ -178,37 +178,37 @@ const languages = getAvailableLocales() // ['zh-CN', 'en-US', 'zh-TW']
178
178
  添加组件库未内置的语言(如日语、韩语等):
179
179
 
180
180
  ```typescript
181
- import { registerLocale, setLanguage } from 'tang-ui-x'
181
+ import { registerLocale, setLanguage } from "tang-ui-x";
182
182
 
183
183
  // 注册日语语言包
184
- registerLocale('ja-JP', {
184
+ registerLocale("ja-JP", {
185
185
  common: {
186
- confirm: '確認',
187
- cancel: 'キャンセル',
188
- ok: 'OK',
189
- close: '閉じる',
190
- loading: '読み込み中...',
191
- noData: 'データなし'
186
+ confirm: "確認",
187
+ cancel: "キャンセル",
188
+ ok: "OK",
189
+ close: "閉じる",
190
+ loading: "読み込み中...",
191
+ noData: "データなし",
192
192
  },
193
193
  dialog: {
194
- title: 'ヒント',
195
- confirmText: '確認',
196
- cancelText: 'キャンセル'
194
+ title: "ヒント",
195
+ confirmText: "確認",
196
+ cancelText: "キャンセル",
197
197
  },
198
198
  empty: {
199
- title: 'データなし',
200
- description: '関連コンテンツがありません',
201
- actionText: '更新'
199
+ title: "データなし",
200
+ description: "関連コンテンツがありません",
201
+ actionText: "更新",
202
202
  },
203
203
  searchBar: {
204
- placeholder: '検索キーワードを入力',
205
- cancelText: 'キャンセル'
206
- }
204
+ placeholder: "検索キーワードを入力",
205
+ cancelText: "キャンセル",
206
+ },
207
207
  // ... 其他组件模块
208
- })
208
+ });
209
209
 
210
210
  // 切换到日语
211
- setLanguage('ja-JP')
211
+ setLanguage("ja-JP");
212
212
  ```
213
213
 
214
214
  #### 方式二:覆盖默认翻译
@@ -216,17 +216,17 @@ setLanguage('ja-JP')
216
216
  只覆盖部分翻译文本,其他保持默认:
217
217
 
218
218
  ```typescript
219
- import { registerLocale } from 'tang-ui-x'
219
+ import { registerLocale } from "tang-ui-x";
220
220
 
221
221
  // 自定义简体中文的部分翻译
222
- registerLocale('zh-CN', {
222
+ registerLocale("zh-CN", {
223
223
  common: {
224
- confirm: '好的', // 覆盖默认的"确定"
225
- cancel: '算了' // 覆盖默认的"取消"
224
+ confirm: "好的", // 覆盖默认的"确定"
225
+ cancel: "算了", // 覆盖默认的"取消"
226
226
  // 其他键(ok, close, loading 等)保持默认值
227
- }
227
+ },
228
228
  // 其他模块(dialog, empty 等)保持默认翻译
229
- })
229
+ });
230
230
  ```
231
231
 
232
232
  ### 语言包注册模式
@@ -238,6 +238,7 @@ Tang UI X 提供了两种语言包注册模式,以满足不同的使用场景
238
238
  合并模式会将新语言包与现有语言包合并,新内容覆盖旧内容,但未覆盖的内容会被保留。这是 `registerLocale` 函数的默认行为。
239
239
 
240
240
  **使用场景:**
241
+
241
242
  - 只想覆盖部分翻译文本
242
243
  - 添加新的翻译键而不影响现有翻译
243
244
  - 逐步自定义组件库的翻译
@@ -245,17 +246,17 @@ Tang UI X 提供了两种语言包注册模式,以满足不同的使用场景
245
246
  **示例 1:覆盖部分通用文本**
246
247
 
247
248
  ```typescript
248
- import { registerLocale } from 'tang-ui-x'
249
+ import { registerLocale } from "tang-ui-x";
249
250
 
250
251
  // 只覆盖 common 模块的部分键
251
- registerLocale('zh-CN', {
252
+ registerLocale("zh-CN", {
252
253
  common: {
253
- confirm: '好的', // 覆盖默认的"确定"
254
- cancel: '算了' // 覆盖默认的"取消"
254
+ confirm: "好的", // 覆盖默认的"确定"
255
+ cancel: "算了", // 覆盖默认的"取消"
255
256
  // ok, close, loading, noData 等其他键保持默认值
256
- }
257
+ },
257
258
  // dialog, empty, searchBar 等其他模块保持默认翻译
258
- })
259
+ });
259
260
 
260
261
  // 结果:
261
262
  // - common.confirm → "好的"(已覆盖)
@@ -269,21 +270,21 @@ registerLocale('zh-CN', {
269
270
  **示例 2:添加新的翻译键**
270
271
 
271
272
  ```typescript
272
- import { registerLocale } from 'tang-ui-x'
273
+ import { registerLocale } from "tang-ui-x";
273
274
 
274
275
  // 为现有语言添加新的翻译键
275
- registerLocale('zh-CN', {
276
+ registerLocale("zh-CN", {
276
277
  common: {
277
- save: '保存', // 新增键
278
- delete: '删除', // 新增键
279
- edit: '编辑' // 新增键
278
+ save: "保存", // 新增键
279
+ delete: "删除", // 新增键
280
+ edit: "编辑", // 新增键
280
281
  },
281
282
  // 添加新的自定义模块
282
283
  myComponent: {
283
- title: '我的组件',
284
- description: '这是自定义组件'
285
- }
286
- })
284
+ title: "我的组件",
285
+ description: "这是自定义组件",
286
+ },
287
+ });
287
288
 
288
289
  // 原有的所有翻译都会保留,只是新增了这些键
289
290
  ```
@@ -291,14 +292,18 @@ registerLocale('zh-CN', {
291
292
  **示例 3:使用 registerLocaleWithMode 显式指定合并模式**
292
293
 
293
294
  ```typescript
294
- import { registerLocaleWithMode } from 'tang-ui-x'
295
+ import { registerLocaleWithMode } from "tang-ui-x";
295
296
 
296
297
  // 显式指定合并模式(与 registerLocale 效果相同)
297
- registerLocaleWithMode('zh-CN', {
298
- common: {
299
- confirm: '好的'
300
- }
301
- }, 'merge')
298
+ registerLocaleWithMode(
299
+ "zh-CN",
300
+ {
301
+ common: {
302
+ confirm: "好的",
303
+ },
304
+ },
305
+ "merge",
306
+ );
302
307
  ```
303
308
 
304
309
  #### 替换模式
@@ -306,6 +311,7 @@ registerLocaleWithMode('zh-CN', {
306
311
  替换模式会完全替换现有语言包,不保留任何原有内容。使用此模式时,您需要提供完整的语言包,否则缺失的模块和键将无法使用。
307
312
 
308
313
  **使用场景:**
314
+
309
315
  - 完全自定义某个语言的所有翻译
310
316
  - 从外部 JSON 文件加载完整的语言包
311
317
  - 确保语言包的完整性和一致性
@@ -313,34 +319,34 @@ registerLocaleWithMode('zh-CN', {
313
319
  **方式 1:使用 replaceLocale 函数**
314
320
 
315
321
  ```typescript
316
- import { replaceLocale } from 'tang-ui-x'
322
+ import { replaceLocale } from "tang-ui-x";
317
323
 
318
324
  // 完全替换简体中文语言包
319
- replaceLocale('zh-CN', {
325
+ replaceLocale("zh-CN", {
320
326
  common: {
321
- confirm: '好的',
322
- cancel: '取消',
323
- ok: 'OK',
324
- close: '关闭',
325
- loading: '加载中...',
326
- noData: '暂无数据'
327
+ confirm: "好的",
328
+ cancel: "取消",
329
+ ok: "OK",
330
+ close: "关闭",
331
+ loading: "加载中...",
332
+ noData: "暂无数据",
327
333
  },
328
334
  dialog: {
329
- title: '提示',
330
- confirmText: '好的',
331
- cancelText: '取消'
335
+ title: "提示",
336
+ confirmText: "好的",
337
+ cancelText: "取消",
332
338
  },
333
339
  empty: {
334
- title: '暂无数据',
335
- description: '当前没有相关内容',
336
- actionText: '刷新试试'
340
+ title: "暂无数据",
341
+ description: "当前没有相关内容",
342
+ actionText: "刷新试试",
337
343
  },
338
344
  searchBar: {
339
- placeholder: '请输入搜索关键词',
340
- cancelText: '取消'
341
- }
345
+ placeholder: "请输入搜索关键词",
346
+ cancelText: "取消",
347
+ },
342
348
  // 必须提供所有组件模块,否则缺失的模块将无法使用
343
- })
349
+ });
344
350
 
345
351
  // 注意:原有的所有翻译都被清除,只保留新提供的内容
346
352
  ```
@@ -348,21 +354,25 @@ replaceLocale('zh-CN', {
348
354
  **方式 2:使用 registerLocaleWithMode 指定替换模式**
349
355
 
350
356
  ```typescript
351
- import { registerLocaleWithMode } from 'tang-ui-x'
357
+ import { registerLocaleWithMode } from "tang-ui-x";
352
358
 
353
359
  // 使用替换模式注册语言包
354
- registerLocaleWithMode('zh-CN', {
355
- common: {
356
- confirm: '好的',
357
- cancel: '取消'
358
- // ... 其他键
360
+ registerLocaleWithMode(
361
+ "zh-CN",
362
+ {
363
+ common: {
364
+ confirm: "好的",
365
+ cancel: "取消",
366
+ // ... 其他键
367
+ },
368
+ dialog: {
369
+ title: "提示",
370
+ // ... 其他键
371
+ },
372
+ // ... 其他模块
359
373
  },
360
- dialog: {
361
- title: '提示'
362
- // ... 其他键
363
- }
364
- // ... 其他模块
365
- }, 'replace')
374
+ "replace",
375
+ );
366
376
  ```
367
377
 
368
378
  #### 从 JSON 文件注册语言包
@@ -402,63 +412,65 @@ registerLocaleWithMode('zh-CN', {
402
412
  **使用合并模式加载 JSON 文件:**
403
413
 
404
414
  ```typescript
405
- import { registerLocale } from 'tang-ui-x'
406
- import customZhCN from './locales/custom-zh-CN.json'
415
+ import { registerLocale } from "tang-ui-x";
416
+ import customZhCN from "./locales/custom-zh-CN.json";
407
417
 
408
418
  // 合并模式:保留未覆盖的默认翻译
409
- registerLocale('zh-CN', customZhCN)
419
+ registerLocale("zh-CN", customZhCN);
410
420
  ```
411
421
 
412
422
  **使用替换模式加载 JSON 文件:**
413
423
 
414
424
  ```typescript
415
- import { replaceLocale } from 'tang-ui-x'
416
- import completeZhCN from './locales/complete-zh-CN.json'
425
+ import { replaceLocale } from "tang-ui-x";
426
+ import completeZhCN from "./locales/complete-zh-CN.json";
417
427
 
418
428
  // 替换模式:完全替换,不保留默认翻译
419
- replaceLocale('zh-CN', completeZhCN)
429
+ replaceLocale("zh-CN", completeZhCN);
420
430
  ```
421
431
 
422
432
  **从多个 JSON 文件组合语言包:**
423
433
 
424
434
  ```typescript
425
- import { registerLocale } from 'tang-ui-x'
426
- import commonTranslations from './locales/common.json'
427
- import dialogTranslations from './locales/dialog.json'
428
- import emptyTranslations from './locales/empty.json'
435
+ import { registerLocale } from "tang-ui-x";
436
+ import commonTranslations from "./locales/common.json";
437
+ import dialogTranslations from "./locales/dialog.json";
438
+ import emptyTranslations from "./locales/empty.json";
429
439
 
430
440
  // 组合多个 JSON 文件
431
441
  const customLocale = {
432
442
  common: commonTranslations,
433
443
  dialog: dialogTranslations,
434
- empty: emptyTranslations
435
- }
444
+ empty: emptyTranslations,
445
+ };
436
446
 
437
447
  // 注册组合后的语言包
438
- registerLocale('zh-CN', customLocale)
448
+ registerLocale("zh-CN", customLocale);
439
449
  ```
440
450
 
441
451
  #### 两种模式的对比
442
452
 
443
- | 特性 | 合并模式(merge) | 替换模式(replace) |
444
- |------|------------------|-------------------|
445
- | **默认行为** | ✓ 是(registerLocale) | ✗ 否(需显式使用) |
446
- | **保留原有内容** | ✓ 是 | ✗ 否 |
447
- | **覆盖指定键** | ✓ 是 | ✓ 是 |
448
- | **需要完整语言包** | ✗ 否 | ✓ 是 |
449
- | **适合部分自定义** | ✓ 是 | ✗ 否 |
450
- | **适合完全自定义** | ✗ 否 | ✓ 是 |
451
- | **使用函数** | registerLocale<br>registerLocaleWithMode(..., 'merge') | replaceLocale<br>registerLocaleWithMode(..., 'replace') |
453
+ | 特性 | 合并模式(merge) | 替换模式(replace) |
454
+ | ------------------ | ------------------------------------------------------ | ------------------------------------------------------- |
455
+ | **默认行为** | ✓ 是(registerLocale) | ✗ 否(需显式使用) |
456
+ | **保留原有内容** | ✓ 是 | ✗ 否 |
457
+ | **覆盖指定键** | ✓ 是 | ✓ 是 |
458
+ | **需要完整语言包** | ✗ 否 | ✓ 是 |
459
+ | **适合部分自定义** | ✓ 是 | ✗ 否 |
460
+ | **适合完全自定义** | ✗ 否 | ✓ 是 |
461
+ | **使用函数** | registerLocale<br>registerLocaleWithMode(..., 'merge') | replaceLocale<br>registerLocaleWithMode(..., 'replace') |
452
462
 
453
463
  #### 选择合适的模式
454
464
 
455
465
  **使用合并模式的情况:**
466
+
456
467
  - ✓ 只想修改少数几个翻译文本
457
468
  - ✓ 想要添加新的翻译键
458
469
  - ✓ 希望保留组件库的默认翻译作为后备
459
470
  - ✓ 逐步自定义翻译,不想一次性提供所有内容
460
471
 
461
472
  **使用替换模式的情况:**
473
+
462
474
  - ✓ 需要完全控制语言包内容
463
475
  - ✓ 从外部系统或 CMS 加载完整的翻译
464
476
  - ✓ 确保翻译的完整性和一致性
@@ -509,13 +521,13 @@ async function loadFromJSON() {
509
521
  // 假设从服务器获取语言包
510
522
  const response = await fetch('/api/locales/zh-CN.json')
511
523
  const localeData = await response.json()
512
-
524
+
513
525
  // 使用合并模式
514
526
  registerLocale('zh-CN', localeData)
515
-
527
+
516
528
  // 或使用替换模式
517
529
  // replaceLocale('zh-CN', localeData)
518
-
530
+
519
531
  console.log('已从 JSON 加载语言包')
520
532
  } catch (error) {
521
533
  console.error('加载语言包失败:', error)
@@ -528,7 +540,7 @@ function explicitMode() {
528
540
  registerLocaleWithMode('zh-CN', {
529
541
  common: { confirm: '好的' }
530
542
  }, 'merge')
531
-
543
+
532
544
  // 替换模式
533
545
  registerLocaleWithMode('en-US', {
534
546
  common: {
@@ -575,27 +587,27 @@ function explicitMode() {
575
587
  loading: '加载中...',
576
588
  noData: '暂无数据'
577
589
  },
578
-
590
+
579
591
  // 对话框模块
580
592
  dialog: {
581
593
  title: '提示',
582
594
  confirmText: '确定',
583
595
  cancelText: '取消'
584
596
  },
585
-
597
+
586
598
  // 空状态模块
587
599
  empty: {
588
600
  title: '暂无数据',
589
601
  description: '当前没有相关内容',
590
602
  actionText: '刷新试试'
591
603
  },
592
-
604
+
593
605
  // 搜索框模块
594
606
  searchBar: {
595
607
  placeholder: '请输入搜索关键词',
596
608
  cancelText: '取消'
597
609
  }
598
-
610
+
599
611
  // ... 其他组件模块
600
612
  }
601
613
  ```
@@ -618,17 +630,17 @@ function explicitMode() {
618
630
  <view>
619
631
  <!-- 使用默认翻译 -->
620
632
  <TEmpty />
621
-
633
+
622
634
  <!-- 使用自定义文本(优先级高于翻译) -->
623
- <TEmpty
624
- title="没有找到结果"
635
+ <TEmpty
636
+ title="没有找到结果"
625
637
  description="请尝试其他搜索条件"
626
638
  actionText="重新搜索"
627
639
  />
628
-
640
+
629
641
  <!-- 使用默认翻译,但会随语言切换自动更新 -->
630
642
  <TSearchBar />
631
-
643
+
632
644
  <!-- 使用自定义占位符 -->
633
645
  <TSearchBar placeholder="搜索商品" />
634
646
  </view>
@@ -641,24 +653,24 @@ function explicitMode() {
641
653
 
642
654
  ```typescript
643
655
  // 定义带占位符的翻译
644
- registerLocale('zh-CN', {
656
+ registerLocale("zh-CN", {
645
657
  common: {
646
- hello: '你好,{name}',
647
- itemCount: '共 {count} 个项目',
648
- welcome: '{user},欢迎回来!'
649
- }
650
- })
658
+ hello: "你好,{name}",
659
+ itemCount: "共 {count} 个项目",
660
+ welcome: "{user},欢迎回来!",
661
+ },
662
+ });
651
663
 
652
664
  // 使用参数
653
- const { $t } = useI18n()
665
+ const { $t } = useI18n();
654
666
 
655
- const greeting = $t('common.hello', { name: '张三' })
667
+ const greeting = $t("common.hello", { name: "张三" });
656
668
  // 结果: "你好,张三"
657
669
 
658
- const count = $t('common.itemCount', { count: 5 })
670
+ const count = $t("common.itemCount", { count: 5 });
659
671
  // 结果: "共 5 个项目"
660
672
 
661
- const welcome = $t('common.welcome', { user: 'Admin' })
673
+ const welcome = $t("common.welcome", { user: "Admin" });
662
674
  // 结果: "Admin,欢迎回来!"
663
675
  ```
664
676
 
@@ -683,11 +695,11 @@ const description = computed(() => $t('empty.description'))
683
695
  <text>{{ title }}</text>
684
696
  <text>{{ description }}</text>
685
697
  <text>当前语言: {{ locale }}</text>
686
-
698
+
687
699
  <!-- 组件内的文本也会自动更新 -->
688
700
  <TEmpty />
689
701
  <TSearchBar />
690
-
702
+
691
703
  <button @click="setLocale('en-US')">English</button>
692
704
  <button @click="setLocale('zh-CN')">中文</button>
693
705
  </view>
@@ -726,10 +738,10 @@ function switchLanguage(code: string) {
726
738
  <template>
727
739
  <view class="language-switcher">
728
740
  <text class="title">选择语言 / Select Language</text>
729
-
741
+
730
742
  <view class="language-list">
731
- <view
732
- v-for="lang in availableLocales"
743
+ <view
744
+ v-for="lang in availableLocales"
733
745
  :key="lang"
734
746
  class="language-item"
735
747
  :class="{ active: locale === lang }"
@@ -739,7 +751,7 @@ function switchLanguage(code: string) {
739
751
  <text v-if="locale === lang" class="check">✓</text>
740
752
  </view>
741
753
  </view>
742
-
754
+
743
755
  <text class="current">当前语言: {{ languageNames[locale] }}</text>
744
756
  </view>
745
757
  </template>
@@ -798,39 +810,41 @@ function switchLanguage(code: string) {
798
810
  #### 步骤 1: 导入 useI18n
799
811
 
800
812
  ```typescript
801
- import { useI18n } from 'tang-ui-x'
813
+ import { useI18n } from "tang-ui-x";
802
814
  ```
803
815
 
804
816
  #### 步骤 2: 在 setup 中获取翻译函数
805
817
 
806
818
  ```typescript
807
- const { $t } = useI18n()
819
+ const { $t } = useI18n();
808
820
  ```
809
821
 
810
822
  #### 步骤 3: 替换硬编码文本
811
823
 
812
824
  ```typescript
813
825
  // 之前
814
- const confirmText = '确定'
826
+ const confirmText = "确定";
815
827
 
816
828
  // 之后
817
- const confirmText = $t('common.confirm')
829
+ const confirmText = $t("common.confirm");
818
830
  ```
819
831
 
820
832
  #### 步骤 4: 支持用户覆盖(推荐)
821
833
 
822
834
  ```typescript
823
835
  interface Props {
824
- title?: string
825
- description?: string
836
+ title?: string;
837
+ description?: string;
826
838
  }
827
839
 
828
- const props = defineProps<Props>()
829
- const { $t } = useI18n()
840
+ const props = defineProps<Props>();
841
+ const { $t } = useI18n();
830
842
 
831
843
  // 优先使用用户传入的值,否则使用翻译
832
- const displayTitle = computed(() => props.title || $t('empty.title'))
833
- const displayDescription = computed(() => props.description || $t('empty.description'))
844
+ const displayTitle = computed(() => props.title || $t("empty.title"));
845
+ const displayDescription = computed(
846
+ () => props.description || $t("empty.description"),
847
+ );
834
848
  ```
835
849
 
836
850
  #### 步骤 5: 更新模板
@@ -890,10 +904,10 @@ function handleAction() {
890
904
 
891
905
  ```typescript
892
906
  {
893
- $t: (key: string, params?: Record<string, any>) => string
894
- locale: ComputedRef<string>
895
- availableLocales: ComputedRef<string[]>
896
- setLocale: (locale: string) => boolean
907
+ $t: (key: string, params?: Record<string, any>) => string;
908
+ locale: ComputedRef;
909
+ availableLocales: ComputedRef<string[]>;
910
+ setLocale: (locale: string) => boolean;
897
911
  }
898
912
  ```
899
913
 
@@ -934,8 +948,10 @@ function handleAction() {
934
948
  A: 使用 `registerLocale` 函数注册新语言包,然后使用 `setLanguage` 切换。
935
949
 
936
950
  ```typescript
937
- registerLocale('ja-JP', { /* 日语翻译 */ })
938
- setLanguage('ja-JP')
951
+ registerLocale("ja-JP", {
952
+ /* 日语翻译 */
953
+ });
954
+ setLanguage("ja-JP");
939
955
  ```
940
956
 
941
957
  #### Q: 如何覆盖默认翻译?
@@ -943,11 +959,11 @@ setLanguage('ja-JP')
943
959
  A: 使用 `registerLocale` 注册同语言代码的语言包,只需包含要覆盖的键。
944
960
 
945
961
  ```typescript
946
- registerLocale('zh-CN', {
962
+ registerLocale("zh-CN", {
947
963
  common: {
948
- confirm: '好的' // 只覆盖这一个键
949
- }
950
- })
964
+ confirm: "好的", // 只覆盖这一个键
965
+ },
966
+ });
951
967
  ```
952
968
 
953
969
  #### Q: 组件的文本不随语言切换更新?
@@ -956,10 +972,10 @@ A: 确保使用 `computed` 包装翻译文本:
956
972
 
957
973
  ```typescript
958
974
  // ❌ 错误:不会更新
959
- const title = $t('common.title')
975
+ const title = $t("common.title");
960
976
 
961
977
  // ✓ 正确:会自动更新
962
- const title = computed(() => $t('common.title'))
978
+ const title = computed(() => $t("common.title"));
963
979
  ```
964
980
 
965
981
  #### Q: 如何在组件外使用翻译?
@@ -967,9 +983,9 @@ const title = computed(() => $t('common.title'))
967
983
  A: 使用全局函数或直接访问 I18nManager:
968
984
 
969
985
  ```typescript
970
- import { getCurrentLocale } from 'tang-ui-x'
986
+ import { getCurrentLocale } from "tang-ui-x";
971
987
 
972
- const locale = getCurrentLocale()
988
+ const locale = getCurrentLocale();
973
989
  ```
974
990
 
975
991
  #### Q: 支持哪些语言?
@@ -999,8 +1015,8 @@ i18n 系统已在以下平台测试并验证:
999
1015
 
1000
1016
  ```typescript
1001
1017
  // ✓ 使用静态导入(跨平台兼容)
1002
- import zhCNCommon from '../locales/zh-CN/common.json'
1003
- import enUSCommon from '../locales/en-US/common.json'
1018
+ import zhCNCommon from "../locales/zh-CN/common.json";
1019
+ import enUSCommon from "../locales/en-US/common.json";
1004
1020
 
1005
1021
  // ✗ 避免动态导入(小程序不支持)
1006
1022
  // const module = await import(`../locales/${locale}/common.json`)
@@ -1016,8 +1032,8 @@ i18n 系统使用同步初始化方式,避免异步操作可能带来的平台
1016
1032
 
1017
1033
  ```typescript
1018
1034
  // 同步初始化,所有平台都支持
1019
- import { useI18n } from 'tang-ui-x'
1020
- const { $t } = useI18n()
1035
+ import { useI18n } from "tang-ui-x";
1036
+ const { $t } = useI18n();
1021
1037
  ```
1022
1038
 
1023
1039
  **4. JSON 文件处理**
@@ -1076,7 +1092,7 @@ function switchLanguage(lang: string) {
1076
1092
  <button @click="switchLanguage('zh-CN')">中文</button>
1077
1093
  <button @click="switchLanguage('en-US')">English</button>
1078
1094
  <button @click="switchLanguage('zh-TW')">繁體中文</button>
1079
-
1095
+
1080
1096
  <text>当前语言: {{ locale }}</text>
1081
1097
  </view>
1082
1098
  </template>
@@ -1094,6 +1110,7 @@ function switchLanguage(lang: string) {
1094
1110
  ## 📚 组件列表
1095
1111
 
1096
1112
  ### 基础组件 (5个)
1113
+
1097
1114
  - TButton - 按钮
1098
1115
  - TIcon - 图标
1099
1116
  - TText - 文本
@@ -1101,6 +1118,7 @@ function switchLanguage(lang: string) {
1101
1118
  - TDivider - 分割线
1102
1119
 
1103
1120
  ### 布局组件 (8个)
1121
+
1104
1122
  - TCard - 卡片
1105
1123
  - TList - 列表
1106
1124
  - TListItem - 列表项
@@ -1111,6 +1129,7 @@ function switchLanguage(lang: string) {
1111
1129
  - TCol - 栅格列
1112
1130
 
1113
1131
  ### 表单组件 (13个)
1132
+
1114
1133
  - TInput - 输入框
1115
1134
  - TNumberInput - 数字输入
1116
1135
  - TTextarea - 多行文本输入
@@ -1126,6 +1145,7 @@ function switchLanguage(lang: string) {
1126
1145
  - TPicker - 选择器
1127
1146
 
1128
1147
  ### 数据展示 (9个)
1148
+
1129
1149
  - Tags - 标签
1130
1150
  - TBadge - 徽标
1131
1151
  - TAvatar - 头像
@@ -1138,6 +1158,7 @@ function switchLanguage(lang: string) {
1138
1158
  - TSwiper - 轮播图
1139
1159
 
1140
1160
  ### 反馈组件 (5个)
1161
+
1141
1162
  - TLoading - 加载
1142
1163
  - TToast - 轻提示
1143
1164
  - TDialog - 对话框
@@ -1145,6 +1166,7 @@ function switchLanguage(lang: string) {
1145
1166
  - TActionSheet - 动作面板
1146
1167
 
1147
1168
  ### 导航组件 (2个)
1169
+
1148
1170
  - Tabs - 标签页
1149
1171
  - TNavBar - 导航栏
1150
1172