@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
@@ -1,134 +1,148 @@
1
- // 全局工具类(x-safe)。
2
- //
3
- // App 蒸汽模式只支持 class / 分组 / 复合 class / page 选择器,
4
- // 因此这里不使用元素选择器、伪类、伪元素;Web/小程序专属规则放在条件块中。
5
-
6
- // 超出行数,自动显示行尾省略号,最多 5 行
7
- // App 蒸汽模式用 text 的 max-lines;nvue 用 weex 的 lines;Web/小程序用 CSS 截断。
8
- /* #ifdef APP-NVUE */
9
- @for $i from 1 through 5 {
10
- .uv-line-#{$i} {
11
- lines: $i;
12
- text-overflow: ellipsis;
13
- overflow: hidden;
14
- flex: 1;
15
- }
16
- }
17
- /* #endif */
18
-
19
- /* #ifdef WEB || H5 || MP */
20
- @for $i from 1 through 5 {
21
- .uv-line-#{$i} {
22
- @if $i == 1 {
23
- overflow: hidden;
24
- white-space: nowrap;
25
- text-overflow: ellipsis;
26
- } @else {
27
- display: -webkit-box !important;
28
- overflow: hidden;
29
- text-overflow: ellipsis;
30
- word-break: break-all;
31
- -webkit-line-clamp: $i;
32
- -webkit-box-orient: vertical !important;
33
- }
34
- }
35
- }
36
- /* #endif */
37
-
38
- $uv-bordercolor: #dadbde !default;
39
- @if variable-exists(uv-border-color) {
40
- $uv-bordercolor: $uv-border-color;
41
- }
42
-
43
- // 边框工具类:
44
- // - nvue 不支持 !important,基础声明供 App-NVUE 使用;
45
- // - Web/H5/MP 与 App 蒸汽模式保留 !important 覆盖组件内联边框(与上游行为一致)。
46
- .uv-border {
47
- border-style: solid;
48
- border-width: 0.5px;
49
- border-color: $uv-bordercolor;
50
- /* #ifndef APP-NVUE */
51
- border-width: 0.5px !important;
52
- border-color: $uv-bordercolor !important;
53
- /* #endif */
54
- }
55
-
56
- .uv-border-top {
57
- border-top-style: solid;
58
- border-top-width: 0.5px;
59
- border-color: $uv-bordercolor;
60
- /* #ifndef APP-NVUE */
61
- border-top-width: 0.5px !important;
62
- border-color: $uv-bordercolor !important;
63
- /* #endif */
64
- }
65
-
66
- .uv-border-left {
67
- border-left-style: solid;
68
- border-left-width: 0.5px;
69
- border-color: $uv-bordercolor;
70
- /* #ifndef APP-NVUE */
71
- border-left-width: 0.5px !important;
72
- border-color: $uv-bordercolor !important;
73
- /* #endif */
74
- }
75
-
76
- .uv-border-right {
77
- border-right-style: solid;
78
- border-right-width: 0.5px;
79
- border-color: $uv-bordercolor;
80
- /* #ifndef APP-NVUE */
81
- border-right-width: 0.5px !important;
82
- border-color: $uv-bordercolor !important;
83
- /* #endif */
84
- }
85
-
86
- .uv-border-bottom {
87
- border-bottom-style: solid;
88
- border-bottom-width: 0.5px;
89
- border-color: $uv-bordercolor;
90
- /* #ifndef APP-NVUE */
91
- border-bottom-width: 0.5px !important;
92
- border-color: $uv-bordercolor !important;
93
- /* #endif */
94
- }
95
-
96
- .uv-border-top-bottom {
97
- border-top-style: solid;
98
- border-bottom-style: solid;
99
- border-top-width: 0.5px;
100
- border-bottom-width: 0.5px;
101
- border-color: $uv-bordercolor;
102
- /* #ifndef APP-NVUE */
103
- border-top-width: 0.5px !important;
104
- border-bottom-width: 0.5px !important;
105
- border-color: $uv-bordercolor !important;
106
- /* #endif */
107
- }
108
-
109
- // 去除 button 默认样式,让其表现跟普通 view/text 一致
110
- // 注意:App 蒸汽模式不支持 font-size/line-height/color: inherit,这里给显式兜底值,
111
- // 组件内部会通过内联样式/局部 class 覆盖。
112
- .uv-reset-button {
113
- padding: 0;
114
- background-color: transparent;
115
- /* #ifndef APP-NVUE */
116
- border-width: 0;
117
- font-size: 16px;
118
- line-height: 20px;
119
- color: #303133;
120
- /* #endif */
121
- /* #ifdef APP-NVUE */
122
- border-width: 0;
123
- /* #endif */
124
- }
125
-
126
- /* #ifdef WEB || H5 || MP */
127
- .uv-reset-button::after {
128
- border: none;
129
- }
130
- /* #endif */
131
-
132
- .uv-hover-class {
133
- opacity: 0.7;
134
- }
1
+ // 全局工具类(x-safe):行数截断、边框、button 重置、hover 与安全区/H5 辅助规则。
2
+ //
3
+ // App 蒸汽模式只支持 class / 分组 / 复合 class / page 选择器,
4
+ // 因此这里不使用元素选择器、伪类、伪元素;Web/小程序专属规则放在条件块中。
5
+ //
6
+ // 主题变量由 theme.scss 提供(!default):单独引入本文件时也能取到 $uv-*;
7
+ // 项目通过 uni.scss 覆盖同名变量时不会被这里覆盖。
8
+
9
+ @import './theme.scss';
10
+
11
+ // 超出行数,自动显示行尾省略号,最多 5 行
12
+ // App 蒸汽模式用 text 的 max-lines;nvue 用 weex 的 lines;Web/小程序用 CSS 截断。
13
+ /* #ifdef APP-NVUE */
14
+ @for $i from 1 through 5 {
15
+ .uv-line-#{$i} {
16
+ lines: $i;
17
+ text-overflow: ellipsis;
18
+ overflow: hidden;
19
+ flex: 1;
20
+ }
21
+ }
22
+ /* #endif */
23
+
24
+ /* #ifdef WEB || H5 || MP */
25
+ @for $i from 1 through 5 {
26
+ .uv-line-#{$i} {
27
+ @if $i == 1 {
28
+ overflow: hidden;
29
+ white-space: nowrap;
30
+ text-overflow: ellipsis;
31
+ } @else {
32
+ display: -webkit-box !important;
33
+ overflow: hidden;
34
+ text-overflow: ellipsis;
35
+ word-break: break-all;
36
+ -webkit-line-clamp: $i;
37
+ -webkit-box-orient: vertical !important;
38
+ }
39
+ }
40
+ }
41
+ /* #endif */
42
+
43
+ // 边框工具类:
44
+ // - nvue 不支持 !important,基础声明供 App-NVUE 使用;
45
+ // - Web/H5/MP 与 App 蒸汽模式保留 !important 覆盖组件内联边框(与上游行为一致)。
46
+ .uv-border {
47
+ border-style: solid;
48
+ border-width: 0.5px;
49
+ border-color: $uv-border-color;
50
+ /* #ifndef APP-NVUE */
51
+ border-width: 0.5px !important;
52
+ border-color: $uv-border-color !important;
53
+ /* #endif */
54
+ }
55
+
56
+ .uv-border-top {
57
+ border-top-style: solid;
58
+ border-top-width: 0.5px;
59
+ border-color: $uv-border-color;
60
+ /* #ifndef APP-NVUE */
61
+ border-top-width: 0.5px !important;
62
+ border-color: $uv-border-color !important;
63
+ /* #endif */
64
+ }
65
+
66
+ .uv-border-left {
67
+ border-left-style: solid;
68
+ border-left-width: 0.5px;
69
+ border-color: $uv-border-color;
70
+ /* #ifndef APP-NVUE */
71
+ border-left-width: 0.5px !important;
72
+ border-color: $uv-border-color !important;
73
+ /* #endif */
74
+ }
75
+
76
+ .uv-border-right {
77
+ border-right-style: solid;
78
+ border-right-width: 0.5px;
79
+ border-color: $uv-border-color;
80
+ /* #ifndef APP-NVUE */
81
+ border-right-width: 0.5px !important;
82
+ border-color: $uv-border-color !important;
83
+ /* #endif */
84
+ }
85
+
86
+ .uv-border-bottom {
87
+ border-bottom-style: solid;
88
+ border-bottom-width: 0.5px;
89
+ border-color: $uv-border-color;
90
+ /* #ifndef APP-NVUE */
91
+ border-bottom-width: 0.5px !important;
92
+ border-color: $uv-border-color !important;
93
+ /* #endif */
94
+ }
95
+
96
+ .uv-border-top-bottom {
97
+ border-top-style: solid;
98
+ border-bottom-style: solid;
99
+ border-top-width: 0.5px;
100
+ border-bottom-width: 0.5px;
101
+ border-color: $uv-border-color;
102
+ /* #ifndef APP-NVUE */
103
+ border-top-width: 0.5px !important;
104
+ border-bottom-width: 0.5px !important;
105
+ border-color: $uv-border-color !important;
106
+ /* #endif */
107
+ }
108
+
109
+ // 去除 button 默认样式,让其表现跟普通 view/text 一致
110
+ // 注意:App 蒸汽模式不支持 font-size/line-height/color: inherit,这里给显式兜底值,
111
+ // 组件内部会通过内联样式/局部 class 覆盖。
112
+ .uv-reset-button {
113
+ padding: 0;
114
+ background-color: transparent;
115
+ border-width: 0;
116
+ /* #ifndef APP-NVUE */
117
+ font-size: 16px;
118
+ line-height: 20px;
119
+ color: #303133;
120
+ /* #endif */
121
+ }
122
+
123
+ /* #ifdef WEB || H5 || MP */
124
+ .uv-reset-button::after {
125
+ border: none;
126
+ }
127
+ /* #endif */
128
+
129
+ .uv-hover-class {
130
+ opacity: 0.7;
131
+ }
132
+
133
+ // 安全区辅助类(仅非 nvue):App 使用 uni 安全区变量,Web/小程序使用 env()
134
+ /* #ifndef APP-NVUE */
135
+ @each $d in top, right, bottom, left {
136
+ .uv-safe-area-inset-#{$d} {
137
+ padding-#{$d}: 0;
138
+ /* #ifdef APP */
139
+ padding-#{$d}: var(--uni-safe-area-inset-#{$d}, 0px);
140
+ /* #endif */
141
+ /* #ifdef WEB || H5 || MP */
142
+ padding-#{$d}: constant(safe-area-inset-#{$d});
143
+ padding-#{$d}: env(safe-area-inset-#{$d});
144
+ /* #endif */
145
+ }
146
+ }
147
+ /* #endif */
148
+
package/styles/index.scss CHANGED
@@ -1,7 +1,4 @@
1
- // 引入公共基础类
2
- @import "./common.scss";
3
-
4
- // 非nvue的样式
5
- /* #ifndef APP-NVUE */
6
- @import "./vue.scss";
7
- /* #endif */
1
+ // 全局样式入口:公共工具类、页面 reset、安全区与 H5 辅助规则。
2
+ // 主题变量由各文件引入的 theme.scss 提供(!default,可被项目覆盖)。
3
+ @import "./common.scss";
4
+ @import "./reset.scss";
@@ -0,0 +1,25 @@
1
+ // 页面基础 reset(由 @zfqh/uniapp-x 原 src/styles/reset.scss 迁移):
2
+ // 仅 H5 / 小程序 / 经典 App 生效;nvue 与 uni-app x App 不支持元素选择器。
3
+
4
+ /* #ifndef APP-NVUE */
5
+ /* #ifdef WEB || H5 || MP || APP-PLUS */
6
+ page,
7
+ view,
8
+ text,
9
+ scroll-view,
10
+ button,
11
+ image,
12
+ navigator,
13
+ swiper,
14
+ swiper-item {
15
+ box-sizing: border-box;
16
+ }
17
+ /* #endif */
18
+
19
+ /* #ifdef WEB || H5 */
20
+ // 提升 H5 端 uni.toast() 的层级,避免被弹层遮盖
21
+ uni-toast {
22
+ z-index: 10090;
23
+ }
24
+ /* #endif */
25
+ /* #endif */
package/styles/theme.scss CHANGED
@@ -1,44 +1,40 @@
1
- // 此文件为uvUI的主题变量,这些变量目前只能通过uni.scss引入才有效,另外由于
2
- // uni.scss中引入的样式会同时混入到全局样式文件和单独每一个页面的样式中,造成微信程序包太大,
3
- // 故uni.scss只建议放scss变量名相关样式,其他的样式可以通过main.js或者App.vue引入
4
-
5
- $uv-main-color: #303133;
6
- $uv-content-color: #606266;
7
- $uv-tips-color: #909193;
8
- $uv-light-color: #c0c4cc;
9
- $uv-border-color: #dadbde;
10
- $uv-bg-color: #f3f4f6;
11
- $uv-bg-light-color: #fffbf4;
12
- $uv-disabled-color: #c8c9cc;
13
-
14
- $uv-primary: #3c9cff;
15
- $uv-primary-dark: #398ade;
16
- $uv-primary-disabled: #9acafc;
17
- $uv-primary-light: #ecf5ff;
18
-
19
- $uv-warning: #f9ae3d;
20
- $uv-warning-dark: #f1a532;
21
- $uv-warning-disabled: #f9d39b;
22
- $uv-warning-light: #fdf6ec;
23
-
24
- $uv-success: #5ac725;
25
- $uv-success-dark: #53c21d;
26
- $uv-success-disabled: #a9e08f;
27
- $uv-success-light: #f5fff0;
28
-
29
- $uv-error: #f56c6c;
30
- $uv-error-dark: #e45656;
31
- $uv-error-disabled: #f7b2b2;
32
- $uv-error-light: #fef0f0;
33
-
34
- $uv-info: #909399;
35
- $uv-info-dark: #767a82;
36
- $uv-info-disabled: #c4c6c9;
37
- $uv-info-light: #f4f4f5;
38
-
39
- @mixin flex($direction: row) {
40
- /* #ifndef APP-NVUE */
41
- display: flex;
42
- /* #endif */
43
- flex-direction: $direction;
44
- }
1
+ // 唯一主题色板:只放 SCSS 变量(无 CSS 输出)。
2
+ //
3
+ // - 项目在 uni.scss 中引入 @zfqh/uview-x/styles/theme.scss;
4
+ // - 变量统一使用 !default:项目先/后定义同名变量都能覆盖;
5
+ // - styles/common.scss、styles/reset.scss、styles/var.module.scss 与组件样式都会再次 @import 本文件,
6
+ // 因此这里不能用普通赋值,否则会覆盖项目主题;
7
+
8
+ $uv-main-color: #303133 !default;
9
+ $uv-content-color: #606266 !default;
10
+ $uv-tips-color: #909193 !default;
11
+ $uv-light-color: #c0c4cc !default;
12
+ $uv-border-color: #dadbde !default;
13
+ $uv-bg-color: #f3f4f6 !default;
14
+ $uv-bg-light-color: #fffbf4 !default;
15
+ $uv-disabled-color: #c8c9cc !default;
16
+
17
+ $uv-primary: #3c9cff !default;
18
+ $uv-primary-dark: #398ade !default;
19
+ $uv-primary-disabled: #9acafc !default;
20
+ $uv-primary-light: #ecf5ff !default;
21
+
22
+ $uv-warning: #f9ae3d !default;
23
+ $uv-warning-dark: #f1a532 !default;
24
+ $uv-warning-disabled: #f9d39b !default;
25
+ $uv-warning-light: #fdf6ec !default;
26
+
27
+ $uv-success: #5ac725 !default;
28
+ $uv-success-dark: #53c21d !default;
29
+ $uv-success-disabled: #a9e08f !default;
30
+ $uv-success-light: #f5fff0 !default;
31
+
32
+ $uv-error: #f56c6c !default;
33
+ $uv-error-dark: #e45656 !default;
34
+ $uv-error-disabled: #f7b2b2 !default;
35
+ $uv-error-light: #fef0f0 !default;
36
+
37
+ $uv-info: #909399 !default;
38
+ $uv-info-dark: #767a82 !default;
39
+ $uv-info-disabled: #c4c6c9 !default;
40
+ $uv-info-light: #f4f4f5 !default;
@@ -1,4 +1,4 @@
1
- @import './color.scss';
1
+ @import './theme.scss';
2
2
 
3
3
  :export {
4
4
  primary: $uv-primary;
package/types/index.d.ts CHANGED
@@ -48,17 +48,17 @@ declare module 'vue' {
48
48
  * 这里声明 `config` 与 4 个 i18n 公共函数 + `useI18n`;包内其余 helper、内部状态与 default/fallback 语言均不对外导出。
49
49
  */
50
50
  declare module '@zfqh/uview-x' {
51
- /** 运行时配置;颜色通过 `config.color` 访问(键为 camelCase,如 `primary`) */
51
+ /** 运行时配置;颜色通过 `config.color` 访问(键为 camelCase,如 `primary`);H5 滚动条通过 `config.scrollbar` 控制(默认隐藏) */
52
52
  export const config: (typeof import('../utils'))['config'];
53
- /** 创建 i18n 实例并挂到 `uni.$i18n`(自动合并 `locales/` 内置组件语言包,用户同名 key 覆盖) */
53
+ /** 创建 i18n 实例并挂到 `uni.$i18n`(仅注入并深合并默认中文 `zh-Hans`;其他语言需自行 import 语言包后合并) */
54
54
  export function createI18n(opts: I18nOptions): I18n;
55
55
  /** 获取当前语言(storage `UNI_LOCALE` → `uni.getLocale` → `getAppBaseInfo` → `zh-Hans`) */
56
56
  export function getLocale(): string;
57
- /** 按当前语言取词(优先全局语言包,其次组件内置语言包;支持 `a.b.c` 路径与 `{name}` 占位符) */
57
+ /** 按当前语言取词(优先全局语言包,其次默认中文语言包;支持 `a.b.c` 路径与 `{name}` 占位符) */
58
58
  export function getLocaleMessage(key: string, values?: Record<string, string | number>): string;
59
59
  /** 设置当前语言:更新内部 localeState 与 `uni.$i18n.global.locale`,写 storage `UNI_LOCALE`,最后调用 `uni.setLocale` */
60
60
  export function setLocale(locale: string): void;
61
- /** i18n hook:未创建 i18n 实例时降级读组件内置语言包,不会抛错 */
61
+ /** i18n hook:未创建 i18n 实例时降级读默认中文语言包,不会抛错 */
62
62
  export const useI18n: typeof import('vue-i18n').useI18n;
63
63
  }
64
64
 
package/utils/config.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // #ifndef APP-NVUE
2
2
  import vars from '../styles/var.module.scss';
3
3
  // #endif
4
+ import type { UviewXScrollbar } from './scrollbar';
4
5
 
5
6
  export interface UviewXColor {
6
7
  primary: string;
@@ -45,25 +46,28 @@ export interface UviewXConfig {
45
46
  props: UviewXProps;
46
47
  // 默认单位,可以通过配置为 rpx,那么在用于传入组件大小参数为数值时,就默认为 rpx
47
48
  unit: string;
49
+ // H5 全局滚动条:false 隐藏(默认);true 使用默认样式;对象在默认样式上自定义
50
+ scrollbar: UviewXScrollbar;
48
51
  }
49
52
 
50
53
  export type UviewXColorConfig = Partial<UviewXColor>;
51
54
 
52
- // 兜底色板与 styles/color.scss 保持一致;非 nvue 端会由 var.module.scss 覆盖为实际主题色
55
+ // 兜底色板与 styles/theme.scss 默认值保持一致(nvue 无法读取 SCSS,使用常量兜底);
56
+ // 非 nvue 端会由 var.module.scss 覆盖为实际主题色。
53
57
  const color: UviewXColor = {
54
- primary: '#00b4c3',
55
- primaryDark: '#157572',
56
- primaryDisabled: '#b4e3d9',
57
- primaryLight: '#dff3f9',
58
+ primary: '#3c9cff',
59
+ primaryDark: '#398ade',
60
+ primaryDisabled: '#9acafc',
61
+ primaryLight: '#ecf5ff',
58
62
  success: '#5ac725',
59
63
  successDark: '#53c21d',
60
64
  successDisabled: '#a9e08f',
61
65
  successLight: '#f5fff0',
62
- warning: '#ff9a05',
63
- warningDark: '#ed6c04',
66
+ warning: '#f9ae3d',
67
+ warningDark: '#f1a532',
64
68
  warningDisabled: '#f9d39b',
65
69
  warningLight: '#fdf6ec',
66
- error: '#ff4d4f',
70
+ error: '#f56c6c',
67
71
  errorDark: '#e45656',
68
72
  errorDisabled: '#f7b2b2',
69
73
  errorLight: '#fef0f0',
@@ -71,14 +75,14 @@ const color: UviewXColor = {
71
75
  infoDark: '#767a82',
72
76
  infoDisabled: '#c4c6c9',
73
77
  infoLight: '#f4f4f5',
74
- bgColor: '#f5f5f5',
78
+ bgColor: '#f3f4f6',
75
79
  bgLightColor: '#fffbf4',
76
- mainColor: '#333333',
77
- contentColor: '#7a7a7a',
78
- tipsColor: '#9a9a9a',
80
+ mainColor: '#303133',
81
+ contentColor: '#606266',
82
+ tipsColor: '#909193',
79
83
  lightColor: '#c0c4cc',
80
84
  disabledColor: '#c8c9cc',
81
- borderColor: '#eeeeee',
85
+ borderColor: '#dadbde',
82
86
  };
83
87
 
84
88
  // #ifndef APP-NVUE
@@ -90,6 +94,7 @@ const config: UviewXConfig = {
90
94
  color,
91
95
  props: {},
92
96
  unit: 'px',
97
+ scrollbar: false,
93
98
  };
94
99
 
95
100
  export default config;
package/utils/function.ts CHANGED
@@ -302,7 +302,9 @@ export function deepMerge<T extends object>(target: T = {} as T, source: Partial
302
302
  } else if (sourceValue instanceof Set) {
303
303
  merged[prop] = new Set(sourceValue);
304
304
  } else if (typeof sourceValue === 'object' && sourceValue !== null) {
305
- merged[prop] = deepMerge(targetValue, sourceValue);
305
+ // 目标是原始值 / null 时,用对象源替换;避免 `false`、`undefined` 等无法被深合并
306
+ const mergedTarget = typeof targetValue === 'object' && targetValue !== null ? targetValue : {};
307
+ merged[prop] = deepMerge(mergedTarget, sourceValue);
306
308
  } else {
307
309
  merged[prop] = sourceValue;
308
310
  }
@@ -754,18 +756,17 @@ export function getHistoryPage(back = 0): ReturnType<typeof getCurrentPages>[num
754
756
 
755
757
  /**
756
758
  * @description 修改 uview-x 运行时内置属性值
757
- * @param {object} config 修改内置 config 属性
758
- * @param {object} color 修改内置 color 属性
759
+ *
760
+ * 直接传 config 字段:
761
+ * `setConfig({ unit: 'rpx', type: [...], scrollbar: true, color: {...}, props: {...} })`
759
762
  */
760
- export interface SetConfigOptions {
761
- config?: Partial<UviewXConfig>;
763
+ export type SetConfigOptions = Omit<Partial<UviewXConfig>, 'color' | 'props'> & {
764
+ /** 修改内置 color 属性(与默认色板深合并) */
762
765
  color?: Partial<UviewXColor>;
766
+ /** 修改组件默认 props(与已有 props 深合并) */
763
767
  props?: UviewXProps;
764
- }
768
+ };
765
769
 
766
- export function setConfig({ config: configPatch = {}, color = {}, props = {} }: SetConfigOptions = {}): void {
767
- const merged = deepMerge(config, configPatch);
768
- Object.assign(config, merged);
769
- config.color = deepMerge(config.color, color);
770
- config.props = deepMerge(config.props, props);
770
+ export function setConfig(options: SetConfigOptions = {}): void {
771
+ Object.assign(config, deepMerge(config, options as Partial<UviewXConfig>));
771
772
  }
package/utils/index.ts CHANGED
@@ -52,6 +52,7 @@ export { range } from './function';
52
52
 
53
53
  // 对外类型:工具配置、路由、压缩与平台
54
54
  export type { UviewXConfig } from './config';
55
+ export type { UviewXScrollbar, UviewXScrollbarOptions, UviewXScrollbarStyle } from './scrollbar';
55
56
  export type { CompressOptions } from './compress';
56
57
  export type { RouteFunction, RouteOptions, RouteParams, RouteType } from './route';
57
58
  export type { UviewXPlatform } from './platform';
package/utils/locale.ts CHANGED
@@ -2,10 +2,13 @@ import { ref } from 'vue';
2
2
  import type { Ref } from 'vue';
3
3
  import { createI18n as _createI18n } from 'vue-i18n';
4
4
  import type { I18n, I18nOptions } from 'vue-i18n';
5
- import { getBuiltinMessage, mergeComponentMessages } from '../locales';
5
+ import { getBuiltinMessage, mergeDefaultMessages } from '../locales';
6
6
 
7
7
  /**
8
- * 国际化能力(组件内置语言包 + 4 个公共 API)。
8
+ * 国际化能力(默认中文 + 可选语言包 + 4 个公共 API)。
9
+ *
10
+ * 默认语言只有简体中文(`zh-Hans`),`createI18n` 只注入并深合并内置中文;
11
+ * 英文等其他语言为独立语言包(`locales/en.ts`),由使用方显式引入后合并进 `messages`。
9
12
  *
10
13
  * 公共 API(由 `utils/index.ts` 导出到包入口):
11
14
  * `createI18n`、`getLocale`、`getLocaleMessage`、`setLocale`。
@@ -187,7 +190,8 @@ function getMessage(messages: I18nMessages, locale: string, key: string): string
187
190
  * 翻译(App / 小程序 / 无 i18n 实例时的统一实现)。
188
191
  *
189
192
  * locale 优先级:storage `UNI_LOCALE` → `uni.$i18n.global.locale` → 内部 `localeState` → `zh-Hans`;
190
- * 消息优先级:全局语言包(当前语言 → 回退语言)→ 组件内置语言包(当前语言 → 回退语言)→ key。
193
+ * 消息优先级:全局语言包(当前语言 → 中文回退)→ 内置中文默认语言包 → key。
194
+ * 其他语言(如英文)由使用方在 `createI18n` 中显式合并,未合并时回退中文。
191
195
  * storage 优先用于 nvue 等页面上下文模块副本不同、实例未共享的场景(setLocale 已先落盘)。
192
196
  */
193
197
  export function appTranslate(key: string, values?: Record<string, string | number>): string {
@@ -206,14 +210,18 @@ export function appTranslate(key: string, values?: Record<string, string | numbe
206
210
  /**
207
211
  * 创建 i18n 实例并挂到 `uni.$i18n`。
208
212
  *
209
- * - 自动把组件内置语言包合并进 `opts.messages`(用户同名 key 优先);
213
+ * - 只注入内置默认中文:`mergeDefaultMessages(opts.messages)` 仅深合并 `zh-Hans`,
214
+ * 用户同名 key 优先;其他 locale(如显式引入的 `en`)原样透传,不做内置补全;
215
+ * - 未显式传 `fallbackLocale` 时默认 `zh-Hans`,未合并的语言回退中文;
210
216
  * - App 端不依赖 vue-i18n 注入,直接把 `global.t` 替换为包内 `appTranslate`;
211
217
  * - 用 `opts.locale` 初始化内部 `localeState`,无实例时也能保持语言一致。
212
218
  */
213
219
  export function createI18n(opts: I18nOptions): I18n {
214
- const mergedMessages: I18nMessages = mergeComponentMessages(opts.messages as I18nMessages | undefined);
220
+ const mergedMessages: I18nMessages = mergeDefaultMessages(opts.messages as I18nMessages | undefined);
215
221
  const mergedOptions: I18nOptions = {
216
222
  ...opts,
223
+ // 默认回退中文;显式传入的值(含 false)优先
224
+ fallbackLocale: opts.fallbackLocale ?? fallbackLocale,
217
225
  // #ifdef WEB || H5
218
226
  // vue-i18n 9.1.9 的 globalInjection 默认 false;H5 开启后 app.use(i18n) 会注入
219
227
  // `app.config.globalProperties.$i18n`,useI18n 才能检测到实例并走 vue-i18n 分支
@@ -288,7 +296,7 @@ export function setLocale(locale: string): void {
288
296
 
289
297
  /**
290
298
  * 按当前语言取词(公共 API)。
291
- * 统一走 `appTranslate`(优先读 `uni.$i18n` 语言包,其次组件内置语言包),
299
+ * 统一走 `appTranslate`(优先读 `uni.$i18n` 语言包,其次默认中文语言包),
292
300
  * 避免小程序端 vue-i18n runtime-only 构建缺少消息编译器导致翻译空白 / 占位符不插值。
293
301
  */
294
302
  export function getLocaleMessage(key: string, values?: Record<string, string | number>): string {