uview-pro 0.4.9 → 0.4.11
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.
- package/changelog.md +50 -16
- package/components/u-config-provider/u-config-provider.vue +4 -1
- package/components/u-popup/u-popup.vue +0 -1
- package/components/u-tabbar/types.ts +2 -0
- package/components/u-tabbar/u-tabbar.vue +48 -3
- package/components/u-top-tips/u-top-tips.vue +1 -1
- package/components/u-upload/u-upload.vue +10 -15
- package/libs/config/color.ts +9 -0
- package/libs/config/theme-tokens.ts +2 -2
- package/libs/function/color.ts +8 -59
- package/libs/index.ts +6 -26
- package/libs/util/config-provider.ts +37 -6
- package/package.json +3 -3
- package/types/global.d.ts +2 -0
package/changelog.md
CHANGED
|
@@ -1,27 +1,61 @@
|
|
|
1
|
-
## 0.4.
|
|
1
|
+
## 0.4.11(2025-12-30)
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### 📦 Build System | 打包构建
|
|
4
4
|
|
|
5
|
-
-
|
|
5
|
+
- 添加edgeone.json配置 ([ed7ba7d](https://github.com/anyup/uView-Pro/commit/ed7ba7d94dbfa791264a624a03938dc6ac58c0bb))
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **source:** 添加静态资源文件 ([346bce6](https://github.com/anyup/uView-Pro/commit/346bce63126c4cb2c9db1f1665568eb11e26be07))
|
|
12
|
-
- **pages:** 优化多个页面演示样式,统一布局和暗黑模式 ([da68f17](https://github.com/anyup/uView-Pro/commit/da68f17ddf3018f7f5d53a7eebfb3dc1bad550ab))
|
|
13
|
-
- **i18n:** 完善国际化支持文案 ([68accbd](https://github.com/anyup/uView-Pro/commit/68accbd1d864f190e510de380d4ed8d603f8676b))
|
|
14
|
-
- **pages:** 更新iconfont图标 ([bafd4af](https://github.com/anyup/uView-Pro/commit/bafd4af26f6d2ca4dbe6e818b31be84f57c787b0))
|
|
15
|
-
- **demo-page:** 调整演示页面样式并添加tabbar支持 ([f4c5cfc](https://github.com/anyup/uView-Pro/commit/f4c5cfc70920b50602f226220ded4690279cb331))
|
|
16
|
-
|
|
17
|
-
### 🚀 Chore | 构建/工程依赖/工具
|
|
18
|
-
|
|
19
|
-
- **harmony:** 添加调试配置并调整harmony兼容版本 ([bd18fd2](https://github.com/anyup/uView-Pro/commit/bd18fd234bf0aec9671663f5b26294b4622bae81))
|
|
9
|
+
- **theme:** 修复运行时设置 color 与 theme 主题色不同步问题 ([1dcf56a](https://github.com/anyup/uView-Pro/commit/1dcf56a232f5b046e0dce5eb58ec90fb46ce19d5))
|
|
10
|
+
- **u-top-tips:** 修复顶部提示组件zindex显示问题,避免影响其他组件的层级显示 ([91391a8](https://github.com/anyup/uView-Pro/commit/91391a8ca10d505936c0b45488af0a3145cab335))
|
|
20
11
|
|
|
21
12
|
### 👥 Contributors
|
|
22
13
|
|
|
23
14
|
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
|
|
24
15
|
|
|
16
|
+
## 0.4.10(2025-12-26)
|
|
17
|
+
|
|
18
|
+
### 🚀 Chore | 构建/工程依赖/工具
|
|
19
|
+
|
|
20
|
+
- **contributors:** 更新贡献者映射配置 ([d496b21](https://github.com/anyup/uView-Pro/commit/d496b21d85bede68fefc9ffd752e31ecde14735a))
|
|
21
|
+
|
|
22
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
23
|
+
|
|
24
|
+
- **u-popup:** 修复u-popup设置mode=center,点击遮罩层无法关闭的问题 ([3896019](https://github.com/anyup/uView-Pro/commit/389601965933d9e1dc74d32c370c4e858df86595))
|
|
25
|
+
- **u-upload:** 优化u-upload组件在多个平台的样式兼容性 ([bfb60b5](https://github.com/anyup/uView-Pro/commit/bfb60b5c2f431d14425eceed9c9e5c248e7cfa29))
|
|
26
|
+
|
|
27
|
+
### ✨ Features | 新功能
|
|
28
|
+
|
|
29
|
+
- **u-tabbar:** 增强u-tabbar组件能力,支持文字和图标显示隐藏配置功能 ([29f3394](https://github.com/anyup/uView-Pro/commit/29f3394d7e8a5e2a818e397ffe97420855970333))
|
|
30
|
+
|
|
31
|
+
### 👥 Contributors
|
|
32
|
+
|
|
33
|
+
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
|
|
34
|
+
|
|
35
|
+
## 0.4.9(2025-12-24)
|
|
36
|
+
|
|
37
|
+
### 📝 Documentation | 文档
|
|
38
|
+
|
|
39
|
+
- **readme:** 修复捐赠页面链接 ([93323ab](https://github.com/anyup/uView-Pro/commit/93323ab414ddc5a4542604928f221a050cbe55c5))
|
|
40
|
+
|
|
41
|
+
### ✨ Features | 新功能
|
|
42
|
+
|
|
43
|
+
- **request:** 增强http请求工具,添加请求超时配置和全局配置合并功能 ([54d4a44](https://github.com/anyup/uView-Pro/commit/54d4a448a82d76889524cc2ad0f8f08b758b73fb))
|
|
44
|
+
- **http:** 修改http请求实例和响应拦截器 ([d566496](https://github.com/anyup/uView-Pro/commit/d56649673103b519492033504aa387cd6d037721))
|
|
45
|
+
- **source:** 添加静态资源文件 ([346bce6](https://github.com/anyup/uView-Pro/commit/346bce63126c4cb2c9db1f1665568eb11e26be07))
|
|
46
|
+
- **pages:** 优化多个页面演示样式,统一布局和暗黑模式 ([da68f17](https://github.com/anyup/uView-Pro/commit/da68f17ddf3018f7f5d53a7eebfb3dc1bad550ab))
|
|
47
|
+
- **i18n:** 完善国际化支持文案 ([68accbd](https://github.com/anyup/uView-Pro/commit/68accbd1d864f190e510de380d4ed8d603f8676b))
|
|
48
|
+
- **pages:** 更新iconfont图标 ([bafd4af](https://github.com/anyup/uView-Pro/commit/bafd4af26f6d2ca4dbe6e818b31be84f57c787b0))
|
|
49
|
+
- **demo-page:** 调整演示页面样式并添加tabbar支持 ([f4c5cfc](https://github.com/anyup/uView-Pro/commit/f4c5cfc70920b50602f226220ded4690279cb331))
|
|
50
|
+
|
|
51
|
+
### 🚀 Chore | 构建/工程依赖/工具
|
|
52
|
+
|
|
53
|
+
- **harmony:** 添加调试配置并调整harmony兼容版本 ([bd18fd2](https://github.com/anyup/uView-Pro/commit/bd18fd234bf0aec9671663f5b26294b4622bae81))
|
|
54
|
+
|
|
55
|
+
### 👥 Contributors
|
|
56
|
+
|
|
57
|
+
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
|
|
58
|
+
|
|
25
59
|
## 0.4.8(2025-12-23)
|
|
26
60
|
|
|
27
61
|
### 🐛 Bug Fixes | Bug 修复
|
|
@@ -36,7 +70,7 @@
|
|
|
36
70
|
|
|
37
71
|
### 👥 Contributors
|
|
38
72
|
|
|
39
|
-
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a> <a href="https://github.com/
|
|
73
|
+
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a> <a href="https://github.com/limes-cloud"><img src="https://github.com/limes-cloud.png?size=40" width="40" height="40" alt="limes-cloud" title="limes-cloud"/></a>
|
|
40
74
|
|
|
41
75
|
## 0.4.7(2025-12-19)
|
|
42
76
|
|
|
@@ -87,7 +87,10 @@ onMounted(() => {
|
|
|
87
87
|
watch(
|
|
88
88
|
() => props.themes,
|
|
89
89
|
val => {
|
|
90
|
-
|
|
90
|
+
// 如果传入的 themes 来自于 configProvider 自身(常见于模板中使用 useTheme() 直接透传),
|
|
91
|
+
// 那么对其做深度监听会在我们内部更新主题对象时触发该回调,进而再次调用 init 导致循环更新。
|
|
92
|
+
// 为避免该情况,先做简单保护:当传入对象正是 configProvider.themesRef.value 时不重复初始化。
|
|
93
|
+
if (val && val.length && val !== configProvider.themesRef.value) {
|
|
91
94
|
configProvider.init(val, props.currentTheme as any);
|
|
92
95
|
}
|
|
93
96
|
},
|
|
@@ -20,6 +20,8 @@ export const TabbarProps = {
|
|
|
20
20
|
iconSize: { type: [String, Number] as PropType<string | number>, default: 40 },
|
|
21
21
|
/** 凸起图标的大小,单位任意,数值默认rpx */
|
|
22
22
|
midButtonSize: { type: [String, Number] as PropType<string | number>, default: 90 },
|
|
23
|
+
/** 文本大小,单位任意,数值默认rpx */
|
|
24
|
+
textSize: { type: [String, Number] as PropType<string | number>, default: 26 },
|
|
23
25
|
/** 激活时的颜色 */
|
|
24
26
|
activeColor: { type: String, default: 'var(--u-main-color)' },
|
|
25
27
|
/** 未激活时的颜色 */
|
|
@@ -20,14 +20,18 @@
|
|
|
20
20
|
:style="{ backgroundColor: props.bgColor }"
|
|
21
21
|
>
|
|
22
22
|
<view
|
|
23
|
+
v-if="item.iconPath || item.selectedIconPath"
|
|
23
24
|
:class="[
|
|
24
25
|
props.midButton && item.midButton
|
|
25
26
|
? 'u-tabbar__content__circle__button'
|
|
26
|
-
: 'u-tabbar__content__item__button'
|
|
27
|
+
: 'u-tabbar__content__item__button',
|
|
28
|
+
!item.text && (item.iconPath || item.selectedIconPath)
|
|
29
|
+
? 'u-tabbar__content__item__button--center'
|
|
30
|
+
: ''
|
|
27
31
|
]"
|
|
28
32
|
>
|
|
29
33
|
<u-icon
|
|
30
|
-
:size="
|
|
34
|
+
:size="getIconSize(index)"
|
|
31
35
|
:name="elIconPath(index)"
|
|
32
36
|
img-mode="scaleToFill"
|
|
33
37
|
:color="elColor(index)"
|
|
@@ -40,7 +44,14 @@
|
|
|
40
44
|
:offset="[-2, getOffsetRight(item.count, item.isDot)]"
|
|
41
45
|
></u-badge>
|
|
42
46
|
</view>
|
|
43
|
-
<view
|
|
47
|
+
<view
|
|
48
|
+
v-if="item.text"
|
|
49
|
+
class="u-tabbar__content__item__text"
|
|
50
|
+
:class="{
|
|
51
|
+
'u-tabbar__content__item__text--center': item.text && !(item.iconPath || item.selectedIconPath)
|
|
52
|
+
}"
|
|
53
|
+
:style="{ color: elColor(index), fontSize: $u.addUnit(getTextSize(index)) }"
|
|
54
|
+
>
|
|
44
55
|
<text class="u-line-1">{{ item.text }}</text>
|
|
45
56
|
</view>
|
|
46
57
|
</view>
|
|
@@ -240,6 +251,31 @@ function getOffsetRight(count: number, isDot: boolean): number {
|
|
|
240
251
|
}
|
|
241
252
|
}
|
|
242
253
|
|
|
254
|
+
/**
|
|
255
|
+
* 获取单项icon尺寸(单项优先级高于props)
|
|
256
|
+
*/
|
|
257
|
+
function getIconSize(index: number) {
|
|
258
|
+
const item = props.list[index] || {};
|
|
259
|
+
if (props.midButton && item.midButton) {
|
|
260
|
+
return props.midButtonSize;
|
|
261
|
+
}
|
|
262
|
+
if (item.iconSize !== undefined && item.iconSize !== null && item.iconSize !== '') {
|
|
263
|
+
return item.iconSize;
|
|
264
|
+
}
|
|
265
|
+
return props.iconSize;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 获取单项text尺寸(单项优先级高于props)
|
|
270
|
+
*/
|
|
271
|
+
function getTextSize(index: number) {
|
|
272
|
+
const item = props.list[index] || {};
|
|
273
|
+
if (item.textSize !== undefined && item.textSize !== null && item.textSize !== '') {
|
|
274
|
+
return item.textSize;
|
|
275
|
+
}
|
|
276
|
+
return props.textSize;
|
|
277
|
+
}
|
|
278
|
+
|
|
243
279
|
/**
|
|
244
280
|
* 获取凸起按钮外层元素的left值,让其水平居中
|
|
245
281
|
*/
|
|
@@ -302,6 +338,10 @@ function getMidButtonLeft() {
|
|
|
302
338
|
left: 50%;
|
|
303
339
|
transform: translateX(-50%);
|
|
304
340
|
}
|
|
341
|
+
&__button--center {
|
|
342
|
+
top: 50%;
|
|
343
|
+
transform: translate(-50%, -50%);
|
|
344
|
+
}
|
|
305
345
|
&__text {
|
|
306
346
|
color: $u-content-color;
|
|
307
347
|
font-size: 26rpx;
|
|
@@ -313,6 +353,11 @@ function getMidButtonLeft() {
|
|
|
313
353
|
width: 100%;
|
|
314
354
|
text-align: center;
|
|
315
355
|
}
|
|
356
|
+
&__text--center {
|
|
357
|
+
top: 50%;
|
|
358
|
+
bottom: auto;
|
|
359
|
+
transform: translate(-50%, -50%);
|
|
360
|
+
}
|
|
316
361
|
}
|
|
317
362
|
&__circle {
|
|
318
363
|
position: relative;
|
|
@@ -18,15 +18,16 @@
|
|
|
18
18
|
background: delBgColor
|
|
19
19
|
}"
|
|
20
20
|
>
|
|
21
|
-
<u-icon
|
|
21
|
+
<u-icon :name="delIcon" size="20" :color="delColor"></u-icon>
|
|
22
|
+
</view>
|
|
23
|
+
<view class="u-upload-progress">
|
|
24
|
+
<u-line-progress
|
|
25
|
+
v-if="showProgress && item.progress > 0 && item.progress != 100 && !item.error"
|
|
26
|
+
:show-percent="false"
|
|
27
|
+
height="16"
|
|
28
|
+
:percent="item.progress"
|
|
29
|
+
></u-line-progress>
|
|
22
30
|
</view>
|
|
23
|
-
<u-line-progress
|
|
24
|
-
v-if="showProgress && item.progress > 0 && item.progress != 100 && !item.error"
|
|
25
|
-
:show-percent="false"
|
|
26
|
-
height="16"
|
|
27
|
-
class="u-progress"
|
|
28
|
-
:percent="item.progress"
|
|
29
|
-
></u-line-progress>
|
|
30
31
|
<view @tap.stop="retry(index)" v-if="item.error" class="u-error-btn">点击重试</view>
|
|
31
32
|
<image
|
|
32
33
|
@tap.stop="doPreviewImage(item.url || item.path, index)"
|
|
@@ -539,13 +540,7 @@ defineExpose({ clear, reUpload, selectFile, upload, retry, remove, doPreviewImag
|
|
|
539
540
|
justify-content: center;
|
|
540
541
|
}
|
|
541
542
|
|
|
542
|
-
.u-
|
|
543
|
-
@include vue-flex;
|
|
544
|
-
align-items: center;
|
|
545
|
-
justify-content: center;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
.u-progress {
|
|
543
|
+
.u-upload-progress {
|
|
549
544
|
position: absolute;
|
|
550
545
|
bottom: 10rpx;
|
|
551
546
|
left: 8rpx;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { reactive } from 'vue';
|
|
2
|
+
import { lightPalette } from './theme-tokens';
|
|
3
|
+
import type { ThemeColor } from '../../types/global';
|
|
4
|
+
|
|
5
|
+
// 使用 reactive 包装颜色对象,使其在运行时可被响应式读取与更新
|
|
6
|
+
// 这个对象会被 configProvider 在主题切换时更新
|
|
7
|
+
export const color = reactive<ThemeColor>({ ...lightPalette });
|
|
8
|
+
|
|
9
|
+
export default color;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Theme, ThemeColor } from '../../types/global';
|
|
2
2
|
import config from './config';
|
|
3
3
|
|
|
4
|
-
const lightPalette: ThemeColor = {
|
|
4
|
+
export const lightPalette: ThemeColor = {
|
|
5
5
|
primary: '#2979ff',
|
|
6
6
|
primaryDark: '#2b85e4',
|
|
7
7
|
primaryDisabled: '#a0cfff',
|
|
@@ -39,7 +39,7 @@ const lightPalette: ThemeColor = {
|
|
|
39
39
|
bgBlack: '#000000'
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
const darkPalette: ThemeColor = {
|
|
42
|
+
export const darkPalette: ThemeColor = {
|
|
43
43
|
primary: '#8ab4ff',
|
|
44
44
|
primaryDark: '#5f8dff',
|
|
45
45
|
primaryDisabled: '#3d4f74',
|
package/libs/function/color.ts
CHANGED
|
@@ -1,48 +1,7 @@
|
|
|
1
|
-
import { reactive } from 'vue';
|
|
2
1
|
import type { ColorType, ThemeColor } from '../../types/global';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
primary: '#2979ff',
|
|
7
|
-
primaryDark: '#2b85e4',
|
|
8
|
-
primaryDisabled: '#a0cfff',
|
|
9
|
-
primaryLight: '#ecf5ff',
|
|
10
|
-
success: '#19be6b',
|
|
11
|
-
successDark: '#18b566',
|
|
12
|
-
successDisabled: '#71d5a1',
|
|
13
|
-
successLight: '#dbf1e1',
|
|
14
|
-
warning: '#ff9900',
|
|
15
|
-
warningDark: '#f29100',
|
|
16
|
-
warningDisabled: '#fcbd71',
|
|
17
|
-
warningLight: '#fdf6ec',
|
|
18
|
-
error: '#fa3534',
|
|
19
|
-
errorDark: '#dd6161',
|
|
20
|
-
errorDisabled: '#fab6b6',
|
|
21
|
-
errorLight: '#fef0f0',
|
|
22
|
-
info: '#909399',
|
|
23
|
-
infoDark: '#82848a',
|
|
24
|
-
infoDisabled: '#c8c9cc',
|
|
25
|
-
infoLight: '#f4f4f5',
|
|
26
|
-
whiteColor: '#ffffff',
|
|
27
|
-
blackColor: '#000000',
|
|
28
|
-
mainColor: '#303133',
|
|
29
|
-
contentColor: '#606266',
|
|
30
|
-
tipsColor: '#909399',
|
|
31
|
-
lightColor: '#c0c4cc',
|
|
32
|
-
borderColor: '#dcdfe6',
|
|
33
|
-
dividerColor: '#e4e7ed',
|
|
34
|
-
maskColor: 'rgba(0, 0, 0, 0.4)',
|
|
35
|
-
shadowColor: 'rgba(0, 0, 0, 0.1)',
|
|
36
|
-
bgColor: '#f3f4f6',
|
|
37
|
-
bgWhite: '#ffffff',
|
|
38
|
-
bgGrayLight: '#f5f7fa',
|
|
39
|
-
bgGrayDark: '#2f343c',
|
|
40
|
-
bgBlack: '#000000'
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// 使用 reactive 包装颜色对象,使其在运行时可被响应式读取与更新
|
|
44
|
-
// 这个对象会被 configProvider 在主题切换时更新
|
|
45
|
-
export const color = reactive<ThemeColor>({ ...defaultColor });
|
|
2
|
+
import { color } from '../config/color';
|
|
3
|
+
import { lightPalette } from '../config/theme-tokens';
|
|
4
|
+
import configProvider from '../util/config-provider';
|
|
46
5
|
|
|
47
6
|
/**
|
|
48
7
|
* 获取颜色值(响应式)
|
|
@@ -51,27 +10,17 @@ export const color = reactive<ThemeColor>({ ...defaultColor });
|
|
|
51
10
|
* @returns 颜色值
|
|
52
11
|
*/
|
|
53
12
|
export function getColor(name: ColorType): string {
|
|
54
|
-
// // 优先从 configProvider 获取当前主题颜色
|
|
55
|
-
// const currentTheme = configProvider.getCurrentTheme();
|
|
56
|
-
// if (currentTheme) {
|
|
57
|
-
// const isDark = configProvider.isInDarkMode();
|
|
58
|
-
// const palette =
|
|
59
|
-
// isDark && currentTheme.darkColor && Object.keys(currentTheme.darkColor).length
|
|
60
|
-
// ? currentTheme.darkColor
|
|
61
|
-
// : currentTheme.color || {};
|
|
62
|
-
|
|
63
|
-
// if (palette[name]) {
|
|
64
|
-
// return palette[name] as string;
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
67
|
-
|
|
68
13
|
// 从响应式 color 对象获取(会被 configProvider 更新)
|
|
69
14
|
if (color[name]) {
|
|
70
15
|
return color[name] as string;
|
|
71
16
|
}
|
|
72
17
|
|
|
73
18
|
// 兜底返回默认值
|
|
74
|
-
return
|
|
19
|
+
return lightPalette[name] || '';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setColor(theme: Partial<ThemeColor> | undefined) {
|
|
23
|
+
configProvider.setThemeColor(theme);
|
|
75
24
|
}
|
|
76
25
|
|
|
77
26
|
export default color;
|
package/libs/index.ts
CHANGED
|
@@ -11,9 +11,8 @@ import colorGradients from './function/colorGradient';
|
|
|
11
11
|
// 生成全局唯一guid字符串
|
|
12
12
|
import guid from './function/guid';
|
|
13
13
|
// 主题相关颜色,info|success|warning|primary|default|error,此颜色已在uview.scss中定义,但是为js中也能使用,故也定义一份
|
|
14
|
-
import color from './
|
|
15
|
-
import { getColor } from './function/color';
|
|
16
|
-
import type { ThemeColor } from '../types/global';
|
|
14
|
+
import { color } from './config/color';
|
|
15
|
+
import { getColor, setColor } from './function/color';
|
|
17
16
|
// 根据type获取图标名称
|
|
18
17
|
import type2icon from './function/type2icon';
|
|
19
18
|
// 打乱数组的顺序
|
|
@@ -244,25 +243,6 @@ export function kebabCase(word: string): string {
|
|
|
244
243
|
return newWord;
|
|
245
244
|
}
|
|
246
245
|
|
|
247
|
-
/**
|
|
248
|
-
* 运行时设置主题颜色(就地合并到 reactive 的 $u.color)
|
|
249
|
-
* @param theme Partial<ThemeColor>
|
|
250
|
-
*/
|
|
251
|
-
function setColor(theme: Partial<ThemeColor> | undefined) {
|
|
252
|
-
if (!theme) return;
|
|
253
|
-
try {
|
|
254
|
-
const merged = deepMerge($u.color, theme);
|
|
255
|
-
Object.keys(merged).forEach(k => {
|
|
256
|
-
$u.color[k] = (merged as any)[k];
|
|
257
|
-
});
|
|
258
|
-
} catch (e) {
|
|
259
|
-
// 兜底:直接 assign
|
|
260
|
-
Object.keys(theme).forEach(k => {
|
|
261
|
-
$u.color[k] = (theme as any)[k];
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
246
|
export {
|
|
267
247
|
queryParams,
|
|
268
248
|
route,
|
|
@@ -271,6 +251,7 @@ export {
|
|
|
271
251
|
guid,
|
|
272
252
|
color,
|
|
273
253
|
getColor,
|
|
254
|
+
setColor,
|
|
274
255
|
sys,
|
|
275
256
|
os,
|
|
276
257
|
type2icon,
|
|
@@ -290,8 +271,7 @@ export {
|
|
|
290
271
|
clipboard,
|
|
291
272
|
config,
|
|
292
273
|
zIndex,
|
|
293
|
-
mitt
|
|
294
|
-
setColor
|
|
274
|
+
mitt
|
|
295
275
|
};
|
|
296
276
|
|
|
297
277
|
export const $u = {
|
|
@@ -305,6 +285,7 @@ export const $u = {
|
|
|
305
285
|
guid,
|
|
306
286
|
color,
|
|
307
287
|
getColor,
|
|
288
|
+
setColor,
|
|
308
289
|
sys,
|
|
309
290
|
os,
|
|
310
291
|
type2icon,
|
|
@@ -333,8 +314,7 @@ export const $u = {
|
|
|
333
314
|
formatName,
|
|
334
315
|
addStyle,
|
|
335
316
|
toStyle,
|
|
336
|
-
kebabCase
|
|
337
|
-
setColor
|
|
317
|
+
kebabCase
|
|
338
318
|
};
|
|
339
319
|
|
|
340
320
|
// 颜色相关方法单独导出
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { ref } from 'vue';
|
|
6
6
|
import type { DarkMode, Theme, ThemeColor } from '../../types/global';
|
|
7
|
-
import
|
|
7
|
+
import config from '../config/config';
|
|
8
8
|
import { defaultThemes } from '../config/theme-tokens';
|
|
9
|
-
import { color as reactiveColor } from '../
|
|
9
|
+
import { color as reactiveColor } from '../config/color';
|
|
10
10
|
import { getSystemDarkMode as getNativeSystemDarkMode } from './system-theme';
|
|
11
11
|
|
|
12
12
|
declare const uni: any;
|
|
@@ -213,6 +213,39 @@ export class ConfigProvider {
|
|
|
213
213
|
if (this.debug) console.log('[ConfigProvider] setTheme ->', themeName);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* 运行时更新当前主题颜色并应用(不持久化)
|
|
218
|
+
* @param colors 主题颜色键值,支持部分更新
|
|
219
|
+
*/
|
|
220
|
+
public setThemeColor(colors: Partial<ThemeColor>) {
|
|
221
|
+
if (!colors || Object.keys(colors).length === 0) return;
|
|
222
|
+
if (!this.currentThemeRef.value) {
|
|
223
|
+
console.warn('[ConfigProvider] setThemeColor called but no current theme');
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const mode = this.getActiveMode();
|
|
228
|
+
|
|
229
|
+
if (mode === 'dark') {
|
|
230
|
+
const existing = this.currentThemeRef.value.darkColor || {};
|
|
231
|
+
this.currentThemeRef.value.darkColor = {
|
|
232
|
+
...existing,
|
|
233
|
+
...colors
|
|
234
|
+
};
|
|
235
|
+
} else {
|
|
236
|
+
const existing = this.currentThemeRef.value.color || {};
|
|
237
|
+
this.currentThemeRef.value.color = {
|
|
238
|
+
...existing,
|
|
239
|
+
...colors
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// 重新应用当前主题以同步运行时 color、CSS 变量等
|
|
244
|
+
this.applyTheme(this.currentThemeRef.value);
|
|
245
|
+
|
|
246
|
+
if (this.debug) console.log('[ConfigProvider] setThemeColor ->', colors);
|
|
247
|
+
}
|
|
248
|
+
|
|
216
249
|
/**
|
|
217
250
|
* 获取当前暗黑模式设置
|
|
218
251
|
*/
|
|
@@ -406,10 +439,8 @@ export class ConfigProvider {
|
|
|
406
439
|
});
|
|
407
440
|
|
|
408
441
|
// 同步到 uni.$u.color(如果存在)
|
|
409
|
-
if (typeof uni !== 'undefined' && uni?.$u?.
|
|
410
|
-
uni.$u.
|
|
411
|
-
} else {
|
|
412
|
-
setColor(mergedPalette);
|
|
442
|
+
if (typeof uni !== 'undefined' && uni?.$u?.color) {
|
|
443
|
+
uni.$u.color = reactiveColor;
|
|
413
444
|
}
|
|
414
445
|
} catch (e) {
|
|
415
446
|
if (this.debug) console.warn('[ConfigProvider] sync runtime theme failed', e);
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "uview-pro",
|
|
3
3
|
"name": "uview-pro",
|
|
4
|
-
"displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS
|
|
5
|
-
"version": "0.4.
|
|
6
|
-
"description": "uView Pro
|
|
4
|
+
"displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的高质量UI组件库,支持多主题、暗黑模式",
|
|
5
|
+
"version": "0.4.11",
|
|
6
|
+
"description": "uView Pro 是为 Vue 3 + TypeScript 的 uni-app 生态量身打造的多平台 UI 框架。提供 80+ 高质量组件、丰富主题与暗黑模式、实用开发工具与模板,显著提升 H5/APP/鸿蒙/小程序 的多端开发效率,目前已在华为鸿蒙应用商店上线,欢迎体验。",
|
|
7
7
|
"main": "index.ts",
|
|
8
8
|
"module": "index.ts",
|
|
9
9
|
"browser": "index.ts",
|