tang-ui-x 1.1.0 → 1.1.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 (89) hide show
  1. package/README.md +1003 -0
  2. package/components/TActionSheet/index.uvue +15 -2
  3. package/components/TCollapse/index.uvue +1 -1
  4. package/components/TCollapse/type.uts +3 -1
  5. package/components/TCollapseItem/index.uvue +22 -26
  6. package/components/TDialog/index.uvue +19 -4
  7. package/components/TEmpty/index.uvue +28 -14
  8. package/components/TForm/index.uvue +60 -26
  9. package/components/TForm/type.uts +4 -0
  10. package/components/TInput/index.uvue +24 -5
  11. package/components/TInput/type.uts +10 -0
  12. package/components/TPicker/index.uvue +26 -6
  13. package/components/TRadioButton/README.md +117 -0
  14. package/components/TRadioButton/index.uvue +69 -64
  15. package/components/TSearchBar/index.uvue +19 -4
  16. package/composables/i18n/error.uts +82 -0
  17. package/composables/i18n/index.uts +188 -0
  18. package/composables/i18n/manager-demo.uts +104 -0
  19. package/composables/i18n/manager.test.uts +182 -0
  20. package/composables/i18n/manager.uts +336 -0
  21. package/composables/i18n/register-demo.uts +125 -0
  22. package/composables/i18n/task22-verification.uts +198 -0
  23. package/composables/i18n/task23-verification.uts +343 -0
  24. package/composables/i18n/task8-demo.uts +93 -0
  25. package/composables/i18n/task8-verification.uts +98 -0
  26. package/composables/i18n/test-task23.uts +9 -0
  27. package/composables/i18n/types.uts +46 -0
  28. package/composables/i18n/useI18n-verification.uts +105 -0
  29. package/composables/i18n/validation-demo.uts +45 -0
  30. package/composables/i18n/validation-test.uts +106 -0
  31. package/composables/useI18n.uts +77 -0
  32. package/index.uts +23 -0
  33. package/locales/cross-platform-verification.uts +510 -0
  34. package/locales/en-US/actionSheet.json +3 -0
  35. package/locales/en-US/common.json +10 -0
  36. package/locales/en-US/dialog.json +5 -0
  37. package/locales/en-US/empty.json +5 -0
  38. package/locales/en-US/errorState.json +5 -0
  39. package/locales/en-US/examplePages.json +1236 -0
  40. package/locales/en-US/examples.json +218 -0
  41. package/locales/en-US/form.json +11 -0
  42. package/locales/en-US/input.json +3 -0
  43. package/locales/en-US/list.json +5 -0
  44. package/locales/en-US/loading.json +3 -0
  45. package/locales/en-US/navBar.json +4 -0
  46. package/locales/en-US/noticeBar.json +3 -0
  47. package/locales/en-US/picker.json +5 -0
  48. package/locales/en-US/searchBar.json +4 -0
  49. package/locales/en-US/textarea.json +3 -0
  50. package/locales/en-US/toast.json +6 -0
  51. package/locales/index.uts +79 -0
  52. package/locales/init-verification.uts +101 -0
  53. package/locales/loader.uts +251 -0
  54. package/locales/run-verification.uts +16 -0
  55. package/locales/zh-CN/actionSheet.json +3 -0
  56. package/locales/zh-CN/common.json +10 -0
  57. package/locales/zh-CN/dialog.json +5 -0
  58. package/locales/zh-CN/empty.json +5 -0
  59. package/locales/zh-CN/errorState.json +5 -0
  60. package/locales/zh-CN/examplePages.json +1236 -0
  61. package/locales/zh-CN/examples.json +218 -0
  62. package/locales/zh-CN/form.json +11 -0
  63. package/locales/zh-CN/input.json +3 -0
  64. package/locales/zh-CN/list.json +5 -0
  65. package/locales/zh-CN/loading.json +3 -0
  66. package/locales/zh-CN/navBar.json +4 -0
  67. package/locales/zh-CN/noticeBar.json +3 -0
  68. package/locales/zh-CN/picker.json +5 -0
  69. package/locales/zh-CN/searchBar.json +4 -0
  70. package/locales/zh-CN/textarea.json +3 -0
  71. package/locales/zh-CN/toast.json +6 -0
  72. package/locales/zh-TW/actionSheet.json +3 -0
  73. package/locales/zh-TW/common.json +8 -0
  74. package/locales/zh-TW/dialog.json +5 -0
  75. package/locales/zh-TW/empty.json +5 -0
  76. package/locales/zh-TW/errorState.json +5 -0
  77. package/locales/zh-TW/examplePages.json +705 -0
  78. package/locales/zh-TW/examples.json +218 -0
  79. package/locales/zh-TW/form.json +11 -0
  80. package/locales/zh-TW/input.json +3 -0
  81. package/locales/zh-TW/list.json +5 -0
  82. package/locales/zh-TW/loading.json +3 -0
  83. package/locales/zh-TW/navBar.json +4 -0
  84. package/locales/zh-TW/noticeBar.json +3 -0
  85. package/locales/zh-TW/picker.json +5 -0
  86. package/locales/zh-TW/searchBar.json +4 -0
  87. package/locales/zh-TW/textarea.json +3 -0
  88. package/locales/zh-TW/toast.json +6 -0
  89. package/package.json +49 -47
@@ -0,0 +1,251 @@
1
+ /**
2
+ * JSON 文件加载器
3
+ * 负责加载和管理 JSON 语言包
4
+ * 使用静态导入确保跨平台兼容性
5
+ */
6
+
7
+ import type { ModularLocaleMessages } from '../composables/i18n/types.uts'
8
+
9
+ // ============================================
10
+ // 静态导入所有 JSON 文件
11
+ // ============================================
12
+
13
+ // 简体中文 (zh-CN)
14
+ import zhCNActionSheet from './zh-CN/actionSheet.json'
15
+ import zhCNCommon from './zh-CN/common.json'
16
+ import zhCNDialog from './zh-CN/dialog.json'
17
+ import zhCNEmpty from './zh-CN/empty.json'
18
+ import zhCNErrorState from './zh-CN/errorState.json'
19
+ import zhCNExamples from './zh-CN/examples.json'
20
+ import zhCNExamplePages from './zh-CN/examplePages.json'
21
+ import zhCNForm from './zh-CN/form.json'
22
+ import zhCNInput from './zh-CN/input.json'
23
+ import zhCNList from './zh-CN/list.json'
24
+ import zhCNLoading from './zh-CN/loading.json'
25
+ import zhCNNavBar from './zh-CN/navBar.json'
26
+ import zhCNNoticeBar from './zh-CN/noticeBar.json'
27
+ import zhCNPicker from './zh-CN/picker.json'
28
+ import zhCNSearchBar from './zh-CN/searchBar.json'
29
+ import zhCNTextarea from './zh-CN/textarea.json'
30
+ import zhCNToast from './zh-CN/toast.json'
31
+
32
+ // 英语 (en-US)
33
+ import enUSActionSheet from './en-US/actionSheet.json'
34
+ import enUSCommon from './en-US/common.json'
35
+ import enUSDialog from './en-US/dialog.json'
36
+ import enUSEmpty from './en-US/empty.json'
37
+ import enUSErrorState from './en-US/errorState.json'
38
+ import enUSExamples from './en-US/examples.json'
39
+ import enUSExamplePages from './en-US/examplePages.json'
40
+ import enUSForm from './en-US/form.json'
41
+ import enUSInput from './en-US/input.json'
42
+ import enUSList from './en-US/list.json'
43
+ import enUSLoading from './en-US/loading.json'
44
+ import enUSNavBar from './en-US/navBar.json'
45
+ import enUSNoticeBar from './en-US/noticeBar.json'
46
+ import enUSPicker from './en-US/picker.json'
47
+ import enUSSearchBar from './en-US/searchBar.json'
48
+ import enUSTextarea from './en-US/textarea.json'
49
+ import enUSToast from './en-US/toast.json'
50
+
51
+ // 繁体中文 (zh-TW)
52
+ import zhTWActionSheet from './zh-TW/actionSheet.json'
53
+ import zhTWCommon from './zh-TW/common.json'
54
+ import zhTWDialog from './zh-TW/dialog.json'
55
+ import zhTWEmpty from './zh-TW/empty.json'
56
+ import zhTWErrorState from './zh-TW/errorState.json'
57
+ import zhTWExamples from './zh-TW/examples.json'
58
+ import zhTWExamplePages from './zh-TW/examplePages.json'
59
+ import zhTWForm from './zh-TW/form.json'
60
+ import zhTWInput from './zh-TW/input.json'
61
+ import zhTWList from './zh-TW/list.json'
62
+ import zhTWLoading from './zh-TW/loading.json'
63
+ import zhTWNavBar from './zh-TW/navBar.json'
64
+ import zhTWNoticeBar from './zh-TW/noticeBar.json'
65
+ import zhTWPicker from './zh-TW/picker.json'
66
+ import zhTWSearchBar from './zh-TW/searchBar.json'
67
+ import zhTWTextarea from './zh-TW/textarea.json'
68
+ import zhTWToast from './zh-TW/toast.json'
69
+
70
+ // ============================================
71
+ // 创建静态导入映射表
72
+ // ============================================
73
+
74
+ /**
75
+ * 简体中文模块映射
76
+ */
77
+ const zhCNModules: ModularLocaleMessages = {
78
+ actionSheet: zhCNActionSheet,
79
+ common: zhCNCommon,
80
+ dialog: zhCNDialog,
81
+ empty: zhCNEmpty,
82
+ errorState: zhCNErrorState,
83
+ examples: zhCNExamples,
84
+ examplePages: zhCNExamplePages,
85
+ form: zhCNForm,
86
+ input: zhCNInput,
87
+ list: zhCNList,
88
+ loading: zhCNLoading,
89
+ navBar: zhCNNavBar,
90
+ noticeBar: zhCNNoticeBar,
91
+ picker: zhCNPicker,
92
+ searchBar: zhCNSearchBar,
93
+ textarea: zhCNTextarea,
94
+ toast: zhCNToast
95
+ }
96
+
97
+ /**
98
+ * 英语模块映射
99
+ */
100
+ const enUSModules: ModularLocaleMessages = {
101
+ actionSheet: enUSActionSheet,
102
+ common: enUSCommon,
103
+ dialog: enUSDialog,
104
+ empty: enUSEmpty,
105
+ errorState: enUSErrorState,
106
+ examples: enUSExamples,
107
+ examplePages: enUSExamplePages,
108
+ form: enUSForm,
109
+ input: enUSInput,
110
+ list: enUSList,
111
+ loading: enUSLoading,
112
+ navBar: enUSNavBar,
113
+ noticeBar: enUSNoticeBar,
114
+ picker: enUSPicker,
115
+ searchBar: enUSSearchBar,
116
+ textarea: enUSTextarea,
117
+ toast: enUSToast
118
+ }
119
+
120
+ /**
121
+ * 繁体中文模块映射
122
+ */
123
+ const zhTWModules: ModularLocaleMessages = {
124
+ actionSheet: zhTWActionSheet,
125
+ common: zhTWCommon,
126
+ dialog: zhTWDialog,
127
+ empty: zhTWEmpty,
128
+ errorState: zhTWErrorState,
129
+ examples: zhTWExamples,
130
+ examplePages: zhTWExamplePages,
131
+ form: zhTWForm,
132
+ input: zhTWInput,
133
+ list: zhTWList,
134
+ loading: zhTWLoading,
135
+ navBar: zhTWNavBar,
136
+ noticeBar: zhTWNoticeBar,
137
+ picker: zhTWPicker,
138
+ searchBar: zhTWSearchBar,
139
+ textarea: zhTWTextarea,
140
+ toast: zhTWToast
141
+ }
142
+
143
+ // ============================================
144
+ // LocaleLoader 类
145
+ // ============================================
146
+
147
+ /**
148
+ * LocaleLoader 类
149
+ * 提供语言包加载功能(同步方式,跨平台兼容)
150
+ */
151
+ export class LocaleLoader {
152
+ /**
153
+ * 模块列表(显式维护)
154
+ */
155
+ private static readonly MODULES = [
156
+ 'actionSheet',
157
+ 'common',
158
+ 'dialog',
159
+ 'empty',
160
+ 'errorState',
161
+ 'examples',
162
+ 'examplePages',
163
+ 'form',
164
+ 'input',
165
+ 'list',
166
+ 'loading',
167
+ 'navBar',
168
+ 'noticeBar',
169
+ 'picker',
170
+ 'searchBar',
171
+ 'textarea',
172
+ 'toast'
173
+ ]
174
+
175
+ /**
176
+ * 加载指定语言的所有模块(同步方法)
177
+ * 使用静态导入映射表,确保编译时可解析
178
+ * @param locale 语言代码
179
+ * @returns 模块化语言包
180
+ */
181
+ static loadLocale(locale: string): ModularLocaleMessages {
182
+ const modules: ModularLocaleMessages = {}
183
+
184
+ // 使用静态导入映射表
185
+ const localeImports = this.getLocaleImports(locale)
186
+
187
+ if (!localeImports) {
188
+ console.warn(`[Tang UI I18n] Locale "${locale}" not found`)
189
+ return modules
190
+ }
191
+
192
+ for (const moduleName of this.MODULES) {
193
+ try {
194
+ const content = localeImports[moduleName]
195
+ if (content) {
196
+ modules[moduleName] = content
197
+ } else {
198
+ console.warn(`[Tang UI I18n] Module ${moduleName} not found for locale ${locale}`)
199
+ modules[moduleName] = {}
200
+ }
201
+ } catch (error) {
202
+ console.warn(`[Tang UI I18n] Failed to load module ${moduleName} for locale ${locale}`, error)
203
+ modules[moduleName] = {}
204
+ }
205
+ }
206
+
207
+ return modules
208
+ }
209
+
210
+ /**
211
+ * 获取语言的静态导入映射
212
+ * 所有导入都是静态的,确保编译时可解析
213
+ * @param locale 语言代码
214
+ * @returns 模块名到内容的映射
215
+ */
216
+ private static getLocaleImports(locale: string): ModularLocaleMessages | null {
217
+ // 根据语言代码返回对应的静态导入
218
+ // 这些导入在文件顶部已经完成
219
+ switch (locale) {
220
+ case 'zh-CN':
221
+ return zhCNModules
222
+ case 'en-US':
223
+ return enUSModules
224
+ case 'zh-TW':
225
+ return zhTWModules
226
+ default:
227
+ return null
228
+ }
229
+ }
230
+
231
+ /**
232
+ * 预加载内置语言包(同步方法)
233
+ * 同步加载所有内置语言,确保平台兼容性
234
+ * @returns 内置语言包的 Map
235
+ */
236
+ static preloadBuiltinLocales(): Map<string, ModularLocaleMessages> {
237
+ const builtinLocales = ['zh-CN', 'en-US', 'zh-TW']
238
+ const localesMap = new Map<string, ModularLocaleMessages>()
239
+
240
+ for (const locale of builtinLocales) {
241
+ try {
242
+ const messages = this.loadLocale(locale)
243
+ localesMap.set(locale, messages)
244
+ } catch (error) {
245
+ console.error(`[Tang UI I18n] Failed to preload locale ${locale}`, error)
246
+ }
247
+ }
248
+
249
+ return localesMap
250
+ }
251
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 验证脚本运行器
3
+ * 用于在不同平台上运行跨平台兼容性验证
4
+ */
5
+
6
+ import { runCrossPlatformVerification } from './cross-platform-verification.uts'
7
+
8
+ // 运行验证
9
+ console.log('开始运行跨平台兼容性验证...')
10
+ console.log('')
11
+
12
+ try {
13
+ runCrossPlatformVerification()
14
+ } catch (error) {
15
+ console.error('验证过程中发生错误:', error)
16
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "cancelText": "取消"
3
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "confirm": "确定",
3
+ "cancel": "取消",
4
+ "ok": "好的",
5
+ "close": "关闭",
6
+ "loading": "加载中...",
7
+ "noData": "暂无数据",
8
+ "language": "语言",
9
+ "languageSwitch": "切换语言"
10
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "title": "提示",
3
+ "confirmText": "确定",
4
+ "cancelText": "取消"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "title": "暂无数据",
3
+ "description": "当前没有相关内容",
4
+ "actionText": "刷新试试"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "title": "出错了",
3
+ "description": "页面加载失败,请稍后重试",
4
+ "retryText": "重新加载"
5
+ }