@zfqh/uview-x 0.0.3 → 0.0.5

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 (43) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +83 -127
  3. package/components/uv-badge/uv-badge.vue +5 -3
  4. package/components/uv-button/uv-button.vue +4 -2
  5. package/components/uv-checkbox/uv-checkbox.vue +1 -3
  6. package/components/uv-checkbox-group/uv-checkbox-group.vue +0 -3
  7. package/components/uv-dialog/uv-dialog.vue +3 -3
  8. package/components/uv-form/uv-form.vue +0 -2
  9. package/components/uv-form-item/uv-form-item.vue +4 -2
  10. package/components/uv-icon/uv-icon.vue +6 -6
  11. package/components/uv-input/uv-input.vue +2 -2
  12. package/components/uv-line-progress/uv-line-progress.vue +0 -2
  13. package/components/uv-loading-icon/uv-loading-icon.vue +1 -2
  14. package/components/uv-overlay/uv-overlay.vue +1 -2
  15. package/components/uv-popup/uv-popup.vue +5 -2
  16. package/components/uv-safe-bottom/uv-safe-bottom.vue +0 -2
  17. package/components/uv-status-bar/uv-status-bar.vue +0 -2
  18. package/components/uv-tabs/uv-tabs.vue +2 -2
  19. package/hooks/useI18n.ts +1 -1
  20. package/index.ts +10 -3
  21. package/locales/en.ts +4 -3
  22. package/locales/es.ts +79 -0
  23. package/locales/fr.ts +79 -0
  24. package/locales/index.ts +166 -169
  25. package/locales/ru.ts +79 -0
  26. package/locales/zh-Hans.ts +3 -2
  27. package/locales/zh-Hant.ts +79 -0
  28. package/package.json +2 -3
  29. package/styles/common.scss +148 -134
  30. package/styles/index.scss +4 -7
  31. package/styles/reset.scss +25 -0
  32. package/styles/theme.scss +40 -44
  33. package/styles/var.module.scss +1 -1
  34. package/types/index.d.ts +4 -4
  35. package/utils/config.ts +18 -13
  36. package/utils/function.ts +12 -11
  37. package/utils/index.ts +1 -0
  38. package/utils/locale.ts +14 -6
  39. package/utils/scrollbar.ts +181 -0
  40. package/styles/color.scss +0 -33
  41. package/styles/components.scss +0 -19
  42. package/styles/vue.scss +0 -39
  43. package/theme.scss +0 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.0.5](http://10.10.10.16/caoben/front-end-tools/compare/@zfqh/uview-x@0.0.4...@zfqh/uview-x@0.0.5) (2026-11-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * 国际化问题优化 ([b2dda3c](http://10.10.10.16/caoben/front-end-tools/commits/b2dda3c0b9ff45a42bf777db3bddf6f06c5d7e57))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.0.4](http://10.10.10.16/caoben/front-end-tools/compare/@zfqh/uview-x@0.0.3...@zfqh/uview-x@0.0.4) (2026-11-10)
18
+
19
+ **Note:** Version bump only for package @zfqh/uview-x
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.0.3](http://10.10.10.16/caoben/front-end-tools/compare/@zfqh/uview-x@0.0.2...@zfqh/uview-x@0.0.3) (2026-11-10)
7
26
 
8
27
 
package/README.md CHANGED
@@ -1,127 +1,83 @@
1
- # @zfqh/uview-x
2
-
3
- 面向 uni-app x 蒸汽模式(Vapor)与经典 uni-app Vue3 的 UV UI 组件库,由 `@gmcb/uv-ui` fork 并完成多端适配:App 支持 uni-app x 蒸汽模式与经典 nvue,H5 / 微信小程序支持 uni-app x VDOM 与经典 Vue3 VDOM。组件保持 `.vue`,沿用 uv-ui 的 `uv-*` 组件名与主要 API。
4
-
5
- ## 安装
6
-
7
- ```bash
8
- npm i @zfqh/uview-x
9
- ```
10
-
11
- ## 接入
12
-
13
- `main.ts` 注册插件,注册后脚本可用 `uni.$uv`、模板可用 `$uv`:
14
-
15
- ```ts
16
- import { createSSRApp } from 'vue';
17
- import App from './App.uvue';
18
- import uviewX from '@zfqh/uview-x';
19
-
20
- export function createApp() {
21
- const app = createSSRApp(App);
22
- app.use(uviewX as any);
23
- return { app };
24
- }
25
- ```
26
-
27
- `pages.json` 配置 easycom,组件按需自动引入:
28
-
29
- ```json
30
- {
31
- "easycom": {
32
- "autoscan": true,
33
- "custom": {
34
- "^uv-(.*)": "@zfqh/uview-x/components/uv-$1/uv-$1.vue"
35
- }
36
- }
37
- }
38
- ```
39
-
40
- `uni.scss` 引入主题变量,`App.uvue` 引入全局工具样式:
41
-
42
- ```scss
43
- @import '@zfqh/uview-x/theme.scss';
44
- ```
45
-
46
- ```vue
47
- <style lang="scss">
48
- @import '@zfqh/uview-x/styles/index.scss';
49
- </style>
50
- ```
51
-
52
- App x 需在 `manifest.json` 开启蒸汽模式:`"uni-app-x": { "vapor": true, "styleIsolationVersion": "2", "vapor-default-script-lang": "ts" }`,完整配置见 `examples/uview-vapor/manifest.json`。
53
-
54
- ## 组件示例
55
-
56
- ```vue
57
- <template>
58
- <uv-button type="primary" text="提交" @click="onSubmit" />
59
- <uv-icon name="search" :size="24" />
60
- <uv-line />
61
- </template>
62
- ```
63
-
64
- 已适配组件以 `components/uv-*` 为准。业务对话框 `uv-dialog`(基于 `uv-popup`,`open()` 返回 Promise)示例见 `examples/uview-vapor/pages/feedback/dialog/` 与 `examples/uview-nvue/pages/feedback/dialog/`,完整说明见 `AGENTS.md`。
65
-
66
- ## 工具与 hooks
67
-
68
- 入口同时导出 `hooks`、`utils`、`libs` 的公共 API(`libs` 仅汇总第三方库公共入口),例如:
69
-
70
- ```ts
71
- import { $uv, config, useDebounce, useThrottle, Request, dayjs } from '@zfqh/uview-x';
72
-
73
- config.color.primary;
74
- uni.$uv.config.color.primary; // 同一个对象
75
-
76
- // 组件全局 props;需在组件加载前调用,后续修改不影响已加载组件
77
- uni.$uv.setConfig({
78
- props: {
79
- button: { type: { default: 'primary' } },
80
- input: { color: { default: '#303133' } },
81
- },
82
- });
83
- ```
84
-
85
- ## 国际化
86
-
87
- 组件内置文案(`uv-dialog` / `uv-code` / `uv-form` / `timeFrom`)随包提供 `zh-Hans`、`en` 两套语言包;`createI18n` 会自动合并,用户 `messages` 传同名 key 即可覆盖(键空间 `uv.*`)。
88
-
89
- ```ts
90
- // main.ts:创建 i18n(自动合并组件内置语言包),再安装到 Vue app
91
- import { createI18n } from '@zfqh/uview-x';
92
-
93
- const i18n = createI18n({
94
- legacy: false,
95
- locale: 'zh-Hans',
96
- fallbackLocale: 'zh-Hans',
97
- messages: {
98
- // 只覆盖想自定义的 key,未传的以内置文案兜底
99
- 'zh-Hans': { uv: { dialog: { title: '温馨提示' } } },
100
- en: { uv: { dialog: { title: 'Notice' } } },
101
- },
102
- });
103
-
104
- app.use(i18n);
105
- ```
106
-
107
- ```ts
108
- // 页面内
109
- import { useI18n, setLocale, getLocale } from '@zfqh/uview-x';
110
-
111
- const { t } = useI18n();
112
-
113
- t('uv.dialog.title'); // 未创建实例时也能取到内置文案(自动降级)
114
- setLocale('en'); // 更新实例 + 写入 storage 的 UNI_LOCALE + 调用 uni.setLocale
115
- getLocale(); // 读取当前语言(优先 storage UNI_LOCALE)
116
- ```
117
-
118
- - 公共 API:`createI18n` / `getLocale` / `getLocaleMessage` / `setLocale` + `useI18n`;`useI18n` 在未创建实例时降级读组件内置语言包,不会抛错。
119
- - 内置文案键空间:`uv.dialog.title/cancel/confirm`、`uv.code.start/change/end`、`uv.time.*`、`uv.form.*`(async-validator 校验文案,保留 `%s` 占位符)。
120
- - `uv-dialog` 的 `title` / `cancelText` / `confirmText` 默认 `''` 时取内置文案;隐藏按钮用 `showCancelButton` / `showConfirmButton`(文本只能是 String,不能传 `false`)。
121
- - 完整 API、平台差异与降级规则见 `AGENTS.md` §12.1。
122
-
123
- ## 文档
124
-
125
- - 开发约定、组件 API、平台差异与验证:[AGENTS.md](AGENTS.md)
126
- - 示例工程:`examples/uview-vapor`(蒸汽模式)、`examples/uview-nvue`(nvue)
127
- - 参考:[uni-app x 蒸汽模式](https://doc.dcloud.net.cn/uni-app-x/app-vapor.html) · [uv-ui 官方文档](https://www.uvui.cn)
1
+ # @zfqh/uview-x
2
+
3
+ 面向 uni-app x 蒸汽模式(Vapor)、uni-app x H5 / 微信小程序(VDOM)与经典 uni-app Vue3 / nvue 的 UV UI 组件库,沿用 `uv-*` 组件名与 uv-ui API;入口同时提供 `$uv`、`config`、hooks 与第三方库导出。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm i @zfqh/uview-x
9
+ ```
10
+
11
+ ## 快速开始
12
+
13
+ `main.ts` 注册插件(仅安装 `$uv` 能力,不注册组件):
14
+
15
+ ```ts
16
+ import { createSSRApp } from 'vue';
17
+ import App from './App.uvue';
18
+ import uviewX from '@zfqh/uview-x';
19
+
20
+ export function createApp() {
21
+ const app = createSSRApp(App);
22
+ app.use(uviewX);
23
+ return { app };
24
+ }
25
+ ```
26
+
27
+ 页面推荐显式 import 组件(uni-app x Vapor 构建必需):
28
+
29
+ ```vue
30
+ <script setup lang="ts">
31
+ import UvButton from '@zfqh/uview-x/components/uv-button/uv-button.vue';
32
+ </script>
33
+
34
+ <template>
35
+ <uv-button type="primary" text="提交" />
36
+ </template>
37
+ ```
38
+
39
+ dev 阶段也可使用 easycom(`pages.json`):
40
+
41
+ ```json
42
+ {
43
+ "easycom": {
44
+ "autoscan": true,
45
+ "custom": {
46
+ "^uv-(.*)": "@zfqh/uview-x/components/uv-$1/uv-$1.vue"
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ > uni-app x Vapor 下 easycom 仅在 dev 阶段可用,build 阶段不支持。
53
+
54
+ `uni.scss` 引入主题变量,`App.uvue` / `App.vue` 引入全局样式:
55
+
56
+ ```scss
57
+ @import '@zfqh/uview-x/styles/theme.scss';
58
+ ```
59
+
60
+ ```vue
61
+ <style lang="scss">
62
+ @import '@zfqh/uview-x/styles/index.scss';
63
+ </style>
64
+ ```
65
+
66
+ 全局配置(如 H5 滚动条,默认隐藏)需在 `app.use(uviewX)` 前通过 `uni.$uv.setConfig({ scrollbar: true })` 设置(安装时应用一次),详见 `AGENTS.md`。
67
+
68
+ ## 国际化
69
+
70
+ 默认简体中文;其他语言按需引入并合并(可选:`en`、`es`、`fr`、`ru`、`zh-Hant`):
71
+
72
+ ```ts
73
+ import en from '@zfqh/uview-x/locales/en';
74
+ // createI18n({ messages: { en: { ...en, ...自定义 } } })
75
+ // 其他语言将路径中的 en 换成对应 locale 即可
76
+ ```
77
+
78
+ ## 文档
79
+
80
+ - 开发约定、组件清单、完整 API、平台差异与验证:[AGENTS.md](AGENTS.md)
81
+ - 示例工程:`examples/uview-vapor`(蒸汽模式)、`examples/uview-nvue`(nvue)
82
+ - 变更记录:[CHANGELOG.md](CHANGELOG.md)
83
+ - 参考:[uni-app x 蒸汽模式](https://doc.dcloud.net.cn/uni-app-x/app-vapor.html) · [uv-ui 官方文档](https://www.uvui.cn)
@@ -100,8 +100,7 @@
100
100
  </script>
101
101
 
102
102
  <style lang="scss">
103
- @import '../../styles/components.scss';
104
- @import '../../styles/color.scss';
103
+ @import '../../styles/theme.scss';
105
104
 
106
105
  $uv-badge-primary: $uv-primary !default;
107
106
  $uv-badge-error: $uv-error !default;
@@ -120,7 +119,10 @@
120
119
  border-top-left-radius: $uv-badge-dot-radius;
121
120
  border-bottom-left-radius: $uv-badge-dot-radius;
122
121
  border-bottom-right-radius: $uv-badge-dot-radius;
123
- @include flex;
122
+ /* #ifndef APP-NVUE */
123
+ display: flex;
124
+ /* #endif */
125
+ flex-direction: row;
124
126
  line-height: $uv-badge-text-font-size;
125
127
  text-align: $uv-badge-text-align;
126
128
  font-size: $uv-badge-text-font-size;
@@ -114,6 +114,8 @@
114
114
  import { computed } from 'vue'
115
115
  import { $uv } from '../../utils'
116
116
  import props from './props'
117
+ import UvIcon from '../uv-icon/uv-icon.vue'
118
+ import UvLoadingIcon from '../uv-loading-icon/uv-loading-icon.vue'
117
119
  import { useThrottle } from '../../hooks'
118
120
  import { createBem } from '../../utils/compat'
119
121
 
@@ -207,7 +209,7 @@
207
209
  return p.type === 'info' ? '#000000' : '#ffffff'
208
210
  })
209
211
 
210
- // uv-ui 主题色(与 styles/color.scss 一致),用于 plain/light 态文字颜色
212
+ // uv-ui 主题色(与 styles/theme.scss 一致),用于 plain/light 态文字颜色
211
213
  const typeTextColors: Record<string, string> = {
212
214
  info: '#909399',
213
215
  primary: '#3c9cff',
@@ -351,7 +353,7 @@
351
353
  </script>
352
354
 
353
355
  <style lang="scss">
354
- @import '../../styles/color.scss';
356
+ @import '../../styles/theme.scss';
355
357
 
356
358
  .uv-button-wrapper {
357
359
  position: relative;
@@ -42,6 +42,7 @@
42
42
  import { computed, inject, nextTick, onUnmounted, ref, watch } from 'vue'
43
43
  import { $uv } from '../../utils'
44
44
  import props from './props'
45
+ import UvIcon from '../uv-icon/uv-icon.vue'
45
46
  import { preventEvent } from '../../utils/compat'
46
47
 
47
48
 
@@ -325,9 +326,6 @@
325
326
  </script>
326
327
 
327
328
  <style lang="scss">
328
- @import '../../styles/components.scss';
329
- @import '../../styles/color.scss';
330
-
331
329
  $uv-checkbox-label-wrap-padding-right: 6px !default;
332
330
  $uv-checkbox-icon-wrap-font-size: 6px !default;
333
331
  $uv-checkbox-icon-wrap-border-width: 1px !default;
@@ -143,9 +143,6 @@
143
143
  </script>
144
144
 
145
145
  <style lang="scss">
146
- @import '../../styles/components.scss';
147
- @import '../../styles/color.scss';
148
-
149
146
  .uv-checkbox-group {
150
147
  flex: 1;
151
148
  }
@@ -96,6 +96,8 @@
96
96
  import { computed, nextTick, onMounted, ref, watch } from 'vue'
97
97
  import { $uv } from '../../utils'
98
98
  import props from './props'
99
+ import UvPopup from '../uv-popup/uv-popup.vue'
100
+ import UvButton from '../uv-button/uv-button.vue'
99
101
  import { useI18n } from '../../hooks'
100
102
 
101
103
  defineOptions({
@@ -109,7 +111,7 @@
109
111
  /**
110
112
  * Dialog 业务对话框
111
113
  * @description 基于 uv-popup 的业务对话框:标题/内容/底部取消确认/关闭/确认回调,支持 ref.open() 返回 Promise;
112
- * 标题与按钮内置文案支持 i18n(内置 zh-Hans / en,可通过 createI18n messages 覆盖 uv.dialog.*)
114
+ * 标题与按钮内置文案支持 i18n(默认中文;其他语言需显式引入语言包并在 createI18n 中合并,可覆盖 uv.dialog.*)
113
115
  * @tutorial https://www.uvui.cn/components/popup.html
114
116
  * @property {Boolean} modelValue 是否显示(v-model)
115
117
  * @property {String} mode 弹出方式,默认 center
@@ -438,8 +440,6 @@
438
440
  </script>
439
441
 
440
442
  <style lang="scss">
441
- @import '../../styles/color.scss';
442
-
443
443
  .uv-dialog {
444
444
  /* #ifndef APP-NVUE */
445
445
  box-sizing: border-box;
@@ -247,8 +247,6 @@
247
247
  </script>
248
248
 
249
249
  <style lang="scss">
250
- @import '../../styles/components.scss';
251
-
252
250
  .uv-form {
253
251
  display: flex;
254
252
  flex-direction: column;
@@ -71,6 +71,9 @@
71
71
  import { computed, inject, onUnmounted, provide, reactive, ref, watch } from 'vue'
72
72
  import { $uv } from '../../utils'
73
73
  import props from './props'
74
+ import UvIcon from '../uv-icon/uv-icon.vue'
75
+ import UvTransition from '../uv-transition/uv-transition.vue'
76
+ import UvLine from '../uv-line/uv-line.vue'
74
77
 
75
78
 
76
79
  defineOptions({
@@ -227,8 +230,7 @@
227
230
  </script>
228
231
 
229
232
  <style lang="scss">
230
- @import '../../styles/components.scss';
231
- @import '../../styles/color.scss';
233
+ @import '../../styles/theme.scss';
232
234
 
233
235
  .uv-form-item {
234
236
  display: flex;
@@ -118,11 +118,11 @@ const iconStyle = computed(() => {
118
118
  };
119
119
  if (p.color && !colorType.includes(p.color)) {
120
120
  style.color = p.color;
121
- }
122
- if (p.customPrefix !== 'uvicon') {
123
- style.fontFamily = p.customPrefix;
124
- } else {
125
- style.fontFamily = 'uvicon-iconfont';
121
+ }
122
+ if (p.customPrefix !== 'uvicon') {
123
+ style.fontFamily = p.customPrefix;
124
+ } else {
125
+ style.fontFamily = 'uvicon-iconfont';
126
126
  }
127
127
  return style;
128
128
  });
@@ -141,7 +141,7 @@ const clickHandler = (e: any) => {
141
141
  </script>
142
142
 
143
143
  <style lang="scss">
144
- @import '../../styles/color.scss';
144
+ @import '../../styles/theme.scss';
145
145
 
146
146
  /* #ifndef APP-NVUE */
147
147
  @font-face {
@@ -70,6 +70,7 @@
70
70
  import { computed, inject, nextTick, ref, watch } from 'vue'
71
71
  import { $uv } from '../../utils'
72
72
  import props from './props'
73
+ import UvIcon from '../uv-icon/uv-icon.vue'
73
74
 
74
75
 
75
76
  defineOptions({
@@ -376,8 +377,7 @@
376
377
  </script>
377
378
 
378
379
  <style lang="scss">
379
- @import '../../styles/components.scss';
380
- @import '../../styles/color.scss';
380
+ @import '../../styles/theme.scss';
381
381
 
382
382
  .uv-input {
383
383
  /* #ifndef APP-NVUE */
@@ -108,8 +108,6 @@
108
108
  </script>
109
109
 
110
110
  <style lang="scss">
111
- @import '../../styles/components.scss';
112
-
113
111
  .uv-line-progress {
114
112
  /* #ifndef APP-NVUE */
115
113
  display: flex;
@@ -160,8 +160,7 @@
160
160
  </script>
161
161
 
162
162
  <style lang="scss">
163
- @import '../../styles/components.scss';
164
- @import '../../styles/color.scss';
163
+ @import '../../styles/theme.scss';
165
164
 
166
165
  .uv-loading-icon {
167
166
  display: flex;
@@ -16,6 +16,7 @@
16
16
  import { computed, onUnmounted, watch } from 'vue'
17
17
  import { $uv } from '../../utils'
18
18
  import props from './props'
19
+ import UvTransition from '../uv-transition/uv-transition.vue'
19
20
  import { preventEvent } from '../../utils/compat'
20
21
 
21
22
  defineOptions({
@@ -103,8 +104,6 @@
103
104
  </script>
104
105
 
105
106
  <style lang="scss">
106
- @import '../../styles/components.scss';
107
-
108
107
  $uv-overlay-top: 0 !default;
109
108
  $uv-overlay-left: 0 !default;
110
109
  $uv-overlay-background-color: rgba(0, 0, 0, 0.7) !default;
@@ -59,6 +59,11 @@
59
59
  import { computed, onMounted, onUnmounted, ref } from 'vue'
60
60
  import { $uv, platform } from '../../utils'
61
61
  import props from './props'
62
+ import UvIcon from '../uv-icon/uv-icon.vue'
63
+ import UvOverlay from '../uv-overlay/uv-overlay.vue'
64
+ import UvTransition from '../uv-transition/uv-transition.vue'
65
+ import UvSafeBottom from '../uv-safe-bottom/uv-safe-bottom.vue'
66
+ import UvStatusBar from '../uv-status-bar/uv-status-bar.vue'
62
67
  import { preventEvent } from '../../utils/compat'
63
68
 
64
69
  defineOptions({
@@ -320,8 +325,6 @@
320
325
  </script>
321
326
 
322
327
  <style lang="scss">
323
- @import '../../styles/components.scss';
324
-
325
328
  .uv-popup {
326
329
  position: fixed;
327
330
  /* #ifndef APP-NVUE */
@@ -96,8 +96,6 @@
96
96
  </script>
97
97
 
98
98
  <style lang="scss">
99
- @import '../../styles/components.scss';
100
-
101
99
  .uv-safe-bottom {
102
100
  /* #ifndef APP-NVUE */
103
101
  width: 100%;
@@ -102,8 +102,6 @@
102
102
  </script>
103
103
 
104
104
  <style lang="scss">
105
- @import '../../styles/components.scss';
106
-
107
105
  .uv-status-bar {
108
106
  /* #ifndef APP-NVUE */
109
107
  width: 100%;
@@ -80,6 +80,7 @@
80
80
  import { computed, getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue'
81
81
  import { $uv } from '../../utils'
82
82
  import props from './props'
83
+ import UvBadge from '../uv-badge/uv-badge.vue'
83
84
  import { getRect, getRectNvue } from '../../utils/compat'
84
85
 
85
86
  defineOptions({
@@ -358,8 +359,7 @@
358
359
  </script>
359
360
 
360
361
  <style lang="scss">
361
- @import '../../styles/components.scss';
362
- @import '../../styles/color.scss';
362
+ @import '../../styles/theme.scss';
363
363
 
364
364
  .uv-tabs {
365
365
  display: flex;
package/hooks/useI18n.ts CHANGED
@@ -46,7 +46,7 @@ function createLocaleComputed(): WritableComputedRef<string> {
46
46
  }
47
47
 
48
48
  /**
49
- * 降级实现:不依赖 vue-i18n 运行时,直接读 `uni.$i18n` 语言包 + 组件内置语言包。
49
+ * 降级实现:不依赖 vue-i18n 运行时,直接读 `uni.$i18n` 语言包 + 默认中文语言包。
50
50
  *
51
51
  * 小程序端 vue-i18n 为 runtime-only 构建(无消息编译器),App 端也不依赖 vue-i18n 注入;
52
52
  * H5 未创建 / 未安装 i18n 实例时同样走这里,保证 `useI18n()` 不抛错。
package/index.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import type { App } from 'vue';
2
2
  import { $uv } from './utils';
3
+ // #ifdef WEB || H5
4
+ import { applyScrollbar } from './utils/scrollbar';
5
+ // #endif
3
6
 
4
7
  export * from './utils';
5
8
  export * from './hooks';
@@ -14,10 +17,14 @@ uni.$uv = $uv;
14
17
  *
15
18
  * - 仅挂到 `app.config.globalProperties.$uv`,模板中可直接使用 `$uv`;
16
19
  * - `uni.$uv` 已在入口模块顶层赋值(脚本中使用);
17
- * - 不注册全局 mixin,也不提供 uv-ui 的 `mpShare` 等安装选项。
18
- */
20
+ * - H5 下按 `config.scrollbar` 注入全局滚动条样式(默认隐藏);
21
+ */
22
+
19
23
  function install(app: App): void {
20
- app.config.globalProperties.$uv = $uv;
24
+ app.config.globalProperties.$uv = $uv;
25
+ // #ifdef WEB || H5
26
+ applyScrollbar($uv.config.scrollbar);
27
+ // #endif
21
28
  }
22
29
 
23
30
  export default { install };
package/locales/en.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
- * uview-x 组件内置语言包:英文(en)。
2
+ * uview-x 可选组件语言包:英文(en)。
3
3
  *
4
- * 键空间固定为 `uv.*`,用户可通过 `createI18n({ messages })` 传同名 key 覆盖;
5
- * `uv.form.*` 与 async-validator 默认 messages 完全对齐,`%s` 占位符由校验器替换。
4
+ * 不参与内部聚合、不会被 `createI18n` 自动合并;需要英文时由使用方显式引入并合并:
5
+ * `import en from '@zfqh/uview-x/locales/en'`,再在 `createI18n({ messages: { en } })` 中使用。
6
+ * 键空间固定为 `uv.*`,`uv.form.*` 与 async-validator 默认 messages 完全对齐,`%s` 占位符由校验器替换。
6
7
  */
7
8
  const en = {
8
9
  uv: {
package/locales/es.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * uview-x 可选组件语言包:西班牙语(es)。
3
+ *
4
+ * 不参与内部聚合、不会被 `createI18n` 自动合并;需要西班牙语时由使用方显式引入并合并:
5
+ * `import es from '@zfqh/uview-x/locales/es'`,再在 `createI18n({ messages: { es } })` 中使用。
6
+ * 键空间固定为 `uv.*`,`uv.form.*` 与 async-validator 默认 messages 完全对齐,`%s` 占位符由校验器替换。
7
+ */
8
+ const es = {
9
+ uv: {
10
+ dialog: {
11
+ title: 'Consejo',
12
+ cancel: 'Cancelar',
13
+ confirm: 'Confirmar',
14
+ },
15
+ code: {
16
+ start: 'Obtener código',
17
+ // 组件会把 x / X 替换为剩余秒数
18
+ change: 'X segundos para reenviar',
19
+ end: 'Reenviar',
20
+ },
21
+ time: {
22
+ justNow: 'Ahora mismo',
23
+ minutesAgo: 'hace {n} minutos',
24
+ hoursAgo: 'hace {n} horas',
25
+ daysAgo: 'hace {n} días',
26
+ monthsAgo: 'hace {n} meses',
27
+ yearsAgo: 'hace {n} años',
28
+ },
29
+ form: {
30
+ default: 'Error de validación en el campo %s',
31
+ required: '%s es obligatorio',
32
+ enum: '%s debe ser uno de %s',
33
+ whitespace: '%s no puede estar vacío',
34
+ date: {
35
+ format: '%s la fecha %s no es válida para el formato %s',
36
+ parse: '%s no se pudo analizar la fecha, %s no es válido',
37
+ invalid: '%s la fecha %s no es válida',
38
+ },
39
+ types: {
40
+ string: '%s no es de tipo %s',
41
+ method: '%s no es de tipo %s (función)',
42
+ array: '%s no es de tipo %s',
43
+ object: '%s no es de tipo %s',
44
+ number: '%s no es de tipo %s',
45
+ date: '%s no es de tipo %s',
46
+ boolean: '%s no es de tipo %s',
47
+ integer: '%s no es de tipo %s',
48
+ float: '%s no es de tipo %s',
49
+ regexp: '%s no es un %s válido',
50
+ email: '%s no es un %s válido',
51
+ url: '%s no es un %s válido',
52
+ hex: '%s no es un %s válido',
53
+ },
54
+ string: {
55
+ len: '%s debe tener exactamente %s caracteres',
56
+ min: '%s debe tener al menos %s caracteres',
57
+ max: '%s no puede tener más de %s caracteres',
58
+ range: '%s debe tener entre %s y %s caracteres',
59
+ },
60
+ number: {
61
+ len: '%s debe ser igual a %s',
62
+ min: '%s no puede ser menor que %s',
63
+ max: '%s no puede ser mayor que %s',
64
+ range: '%s debe estar entre %s y %s',
65
+ },
66
+ array: {
67
+ len: '%s debe tener exactamente %s elementos',
68
+ min: '%s no puede tener menos de %s elementos',
69
+ max: '%s no puede tener más de %s elementos',
70
+ range: '%s debe tener entre %s y %s elementos',
71
+ },
72
+ pattern: {
73
+ mismatch: '%s el valor %s no coincide con el patrón %s',
74
+ },
75
+ },
76
+ },
77
+ };
78
+
79
+ export default es;