uview-plus 3.4.3 → 3.4.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.
- package/changelog.md +13 -0
- package/components/u-modal/modal.js +3 -1
- package/components/u-modal/props.js +11 -0
- package/components/u-modal/u-modal.vue +16 -2
- package/components/u-tag/props.js +24 -3
- package/components/u-tag/tag.js +6 -1
- package/components/u-tag/u-tag.vue +21 -0
- package/components/u-toast/toast.js +1 -1
- package/libs/function/index.js +115 -28
- package/package.json +1 -1
- package/types/comps/toast.d.ts +5 -1
package/changelog.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## 3.4.5(2025-03-24)
|
|
2
|
+
feat: tag组件新增textSize/height/padding/borderRadius属性
|
|
3
|
+
|
|
4
|
+
feat: 新增genLightColor自动计算浅色方法及tag组件支持autoBgColor自动计算背景色
|
|
5
|
+
|
|
6
|
+
## 3.4.4(2025-03-13)
|
|
7
|
+
feat: modal增加异步操作进行中点击取消弹出提示特性防止操作被中断
|
|
8
|
+
|
|
9
|
+
fix: 修复toast组件show方法类型声明
|
|
10
|
+
|
|
11
|
+
## 3.4.3(2025-03-12)
|
|
12
|
+
fix: 修复textarea自动增高时在输入时高度异常
|
|
13
|
+
|
|
1
14
|
## 3.4.2(2025-03-11)
|
|
2
15
|
feat: step组件增加title插槽及增加辅助class便于自定义样式
|
|
3
16
|
|
|
@@ -87,5 +87,16 @@ export const props = defineMixin({
|
|
|
87
87
|
type: String,
|
|
88
88
|
default: () => defProps.modal.contentTextAlign
|
|
89
89
|
},
|
|
90
|
+
// 异步确定时如果点击了取消时候的提示文案
|
|
91
|
+
asyncCloseTip: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: () => defProps.modal.asyncCloseTip
|
|
94
|
+
},
|
|
95
|
+
// 是否异步关闭,只对取消按钮有效
|
|
96
|
+
asyncCancelClose: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: () => defProps.modal.asyncCancelClose
|
|
99
|
+
},
|
|
100
|
+
|
|
90
101
|
}
|
|
91
102
|
})
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
if (n && this.loading) this.loading = false
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
|
-
emits: ["confirm", "cancel", "close", "update:show"],
|
|
140
|
+
emits: ["confirm", "cancel", "close", "update:show", 'cancelOnAsync'],
|
|
141
141
|
methods: {
|
|
142
142
|
addUnit,
|
|
143
143
|
// 点击确定按钮
|
|
@@ -152,7 +152,21 @@
|
|
|
152
152
|
},
|
|
153
153
|
// 点击取消按钮
|
|
154
154
|
cancelHandler() {
|
|
155
|
-
|
|
155
|
+
// 如果点击了确定按钮,确定按钮正在请求接口执行异步操作,那么限制不能取消。
|
|
156
|
+
if (this.asyncClose && this.loading) {
|
|
157
|
+
if (this.asyncCloseTip) {
|
|
158
|
+
uni.showToast({
|
|
159
|
+
title: this.asyncCloseTip,
|
|
160
|
+
icon: 'none'
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
this.$emit('cancelOnAsync')
|
|
164
|
+
} else {
|
|
165
|
+
// 如果配置了取消时异步关闭
|
|
166
|
+
if (!this.asyncCancelClose) {
|
|
167
|
+
this.$emit('update:show', false)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
156
170
|
this.$emit('cancel')
|
|
157
171
|
},
|
|
158
172
|
// 点击遮罩
|
|
@@ -82,9 +82,30 @@ export const props = defineMixin({
|
|
|
82
82
|
type: String,
|
|
83
83
|
default: () => defProps.tag.icon,
|
|
84
84
|
},
|
|
85
|
-
|
|
85
|
+
// 自定义尺寸字体大小
|
|
86
|
+
textSize: {
|
|
86
87
|
type: String,
|
|
87
|
-
default: () => defProps.tag.
|
|
88
|
-
}
|
|
88
|
+
default: () => defProps.tag.textSize
|
|
89
|
+
},
|
|
90
|
+
// 自定义尺寸高度
|
|
91
|
+
height: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: () => defProps.tag.height
|
|
94
|
+
},
|
|
95
|
+
// 自定义尺寸padding
|
|
96
|
+
padding: {
|
|
97
|
+
type: String,
|
|
98
|
+
default: () => defProps.tag.padding
|
|
99
|
+
},
|
|
100
|
+
// 自定义尺寸
|
|
101
|
+
borderRadius: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: () => defProps.tag.borderRadius
|
|
104
|
+
},
|
|
105
|
+
// 自动计算背景色
|
|
106
|
+
autoBgColor: {
|
|
107
|
+
type: Number,
|
|
108
|
+
default: () => defProps.tag.autoBgColor
|
|
109
|
+
},
|
|
89
110
|
}
|
|
90
111
|
})
|
package/components/u-tag/tag.js
CHANGED
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
import { mpMixin } from '../../libs/mixin/mpMixin';
|
|
65
65
|
import { mixin } from '../../libs/mixin/mixin';
|
|
66
66
|
import test from '../../libs/function/test';
|
|
67
|
+
import { addUnit, genLightColor } from '../../libs/function/index';
|
|
67
68
|
/**
|
|
68
69
|
* Tag 标签
|
|
69
70
|
* @description tag组件一般用于标记和选择,我们提供了更加丰富的表现形式,能够较全面的涵盖您的使用场景
|
|
@@ -107,6 +108,19 @@
|
|
|
107
108
|
if(this.borderColor) {
|
|
108
109
|
style.borderColor = this.borderColor
|
|
109
110
|
}
|
|
111
|
+
if (this.height) {
|
|
112
|
+
style.height = addUnit(this.height)
|
|
113
|
+
style.lineHeight = addUnit(this.height)
|
|
114
|
+
}
|
|
115
|
+
if (this.padding) {
|
|
116
|
+
style.padding = this.padding
|
|
117
|
+
}
|
|
118
|
+
if (this.borderRadius) {
|
|
119
|
+
style.borderRadius = addUnit(this.borderRadius)
|
|
120
|
+
}
|
|
121
|
+
if (this.autoBgColor > 0 && this.color) {
|
|
122
|
+
style.backgroundColor = this.getBagColor(this.color)
|
|
123
|
+
}
|
|
110
124
|
return style
|
|
111
125
|
},
|
|
112
126
|
// nvue下,文本颜色无法继承父元素
|
|
@@ -115,6 +129,9 @@
|
|
|
115
129
|
if (this.color) {
|
|
116
130
|
style.color = this.color
|
|
117
131
|
}
|
|
132
|
+
if (this.textSize) {
|
|
133
|
+
style.textSize = addUnit(this.textSize)
|
|
134
|
+
}
|
|
118
135
|
return style
|
|
119
136
|
},
|
|
120
137
|
imgStyle() {
|
|
@@ -149,6 +166,10 @@
|
|
|
149
166
|
// 点击标签
|
|
150
167
|
clickHandler() {
|
|
151
168
|
this.$emit('click', this.name)
|
|
169
|
+
},
|
|
170
|
+
// 根据颜色计算浅色作为背景
|
|
171
|
+
getBagColor(darkColor) {
|
|
172
|
+
return genLightColor(darkColor, this.autoBgColor)
|
|
152
173
|
}
|
|
153
174
|
}
|
|
154
175
|
}
|
package/libs/function/index.js
CHANGED
|
@@ -49,12 +49,12 @@ export function sleep(value = 30) {
|
|
|
49
49
|
* @returns {string} 返回所在平台(小写)
|
|
50
50
|
* @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台
|
|
51
51
|
*/
|
|
52
|
-
export function os() {
|
|
53
|
-
// #ifdef APP || H5 || MP-WEIXIN
|
|
54
|
-
return uni.getDeviceInfo().platform.toLowerCase()
|
|
55
|
-
// #endif
|
|
56
|
-
// #ifndef APP || H5 || MP-WEIXIN
|
|
57
|
-
return uni.getSystemInfoSync().platform.toLowerCase()
|
|
52
|
+
export function os() {
|
|
53
|
+
// #ifdef APP || H5 || MP-WEIXIN
|
|
54
|
+
return uni.getDeviceInfo().platform.toLowerCase()
|
|
55
|
+
// #endif
|
|
56
|
+
// #ifndef APP || H5 || MP-WEIXIN
|
|
57
|
+
return uni.getSystemInfoSync().platform.toLowerCase()
|
|
58
58
|
// #endif
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
@@ -63,26 +63,26 @@ export function os() {
|
|
|
63
63
|
*/
|
|
64
64
|
export function sys() {
|
|
65
65
|
return uni.getSystemInfoSync()
|
|
66
|
-
}
|
|
67
|
-
export function getWindowInfo() {
|
|
68
|
-
let ret = {}
|
|
69
|
-
// #ifdef APP || H5 || MP-WEIXIN
|
|
70
|
-
ret = uni.getWindowInfo()
|
|
71
|
-
// #endif
|
|
72
|
-
// #ifndef APP || H5 || MP-WEIXIN
|
|
73
|
-
ret = sys()
|
|
74
|
-
// #endif
|
|
75
|
-
return ret
|
|
76
|
-
}
|
|
77
|
-
export function getDeviceInfo() {
|
|
78
|
-
let ret = {}
|
|
79
|
-
// #ifdef APP || H5 || MP-WEIXIN
|
|
80
|
-
ret = uni.getDeviceInfo()
|
|
81
|
-
// #endif
|
|
82
|
-
// #ifndef APP || H5 || MP-WEIXIN
|
|
83
|
-
ret = sys()
|
|
84
|
-
// #endif
|
|
85
|
-
return ret
|
|
66
|
+
}
|
|
67
|
+
export function getWindowInfo() {
|
|
68
|
+
let ret = {}
|
|
69
|
+
// #ifdef APP || H5 || MP-WEIXIN
|
|
70
|
+
ret = uni.getWindowInfo()
|
|
71
|
+
// #endif
|
|
72
|
+
// #ifndef APP || H5 || MP-WEIXIN
|
|
73
|
+
ret = sys()
|
|
74
|
+
// #endif
|
|
75
|
+
return ret
|
|
76
|
+
}
|
|
77
|
+
export function getDeviceInfo() {
|
|
78
|
+
let ret = {}
|
|
79
|
+
// #ifdef APP || H5 || MP-WEIXIN
|
|
80
|
+
ret = uni.getDeviceInfo()
|
|
81
|
+
// #endif
|
|
82
|
+
// #ifndef APP || H5 || MP-WEIXIN
|
|
83
|
+
ret = sys()
|
|
84
|
+
// #endif
|
|
85
|
+
return ret
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
@@ -730,12 +730,99 @@ export function getValueByPath(obj, path) {
|
|
|
730
730
|
}, obj);
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
+
/**
|
|
734
|
+
* 生成同色系浅色背景色
|
|
735
|
+
* @param {string} textColor - 支持 #RGB、#RRGGBB、rgb()、rgba() 格式
|
|
736
|
+
* @param {number} [lightness=85] - 目标亮度百分比(默认85%)
|
|
737
|
+
* @returns {string} 十六进制颜色值
|
|
738
|
+
*/
|
|
739
|
+
export function genLightColor(textColor, lightness = 95) {
|
|
740
|
+
// 手动解析颜色值(避免使用document)
|
|
741
|
+
const rgb = parseColorWithoutDOM(textColor);
|
|
742
|
+
|
|
743
|
+
// RGB转HSL色域
|
|
744
|
+
const hsl = rgbToHsl(rgb.r, rgb.g, rgb.b);
|
|
745
|
+
|
|
746
|
+
// 生成浅色背景
|
|
747
|
+
const bgHsl = {
|
|
748
|
+
h: hsl.h,
|
|
749
|
+
s: hsl.s,
|
|
750
|
+
l: Math.min(lightness, 95)
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
return hslToHex(bgHsl.h, bgHsl.s, bgHsl.l);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/* 手动解析颜色字符串(兼容uni-app环境) */
|
|
757
|
+
function parseColorWithoutDOM(colorStr) {
|
|
758
|
+
// 统一转小写处理
|
|
759
|
+
const str = colorStr.toLowerCase().trim();
|
|
760
|
+
|
|
761
|
+
// 处理十六进制格式
|
|
762
|
+
if (str.startsWith('#')) {
|
|
763
|
+
const hex = str.replace('#', '');
|
|
764
|
+
const fullHex = hex.length === 3 ?
|
|
765
|
+
hex.split('').map(c => c + c).join('') : hex;
|
|
766
|
+
|
|
767
|
+
return {
|
|
768
|
+
r: parseInt(fullHex.substring(0,2), 16),
|
|
769
|
+
g: parseInt(fullHex.substring(2,4), 16),
|
|
770
|
+
b: parseInt(fullHex.substring(4,6), 16)
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// 处理rgb/rgba格式
|
|
775
|
+
const rgbMatch = str.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
776
|
+
if (rgbMatch) {
|
|
777
|
+
return {
|
|
778
|
+
r: +rgbMatch[1],
|
|
779
|
+
g: +rgbMatch[2],
|
|
780
|
+
b: +rgbMatch[3]
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
throw new Error('Invalid color format');
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// 辅助函数:RGB 转 HSL(色相、饱和度、亮度)
|
|
788
|
+
function rgbToHsl(r, g, b) {
|
|
789
|
+
r /= 255, g /= 255, b /= 255;
|
|
790
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
791
|
+
let h, s, l = (max + min) / 2;
|
|
792
|
+
|
|
793
|
+
if (max === min) {
|
|
794
|
+
h = s = 0; // achromatic
|
|
795
|
+
} else {
|
|
796
|
+
const d = max - min;
|
|
797
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
798
|
+
switch (max) {
|
|
799
|
+
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
|
800
|
+
case g: h = (b - r) / d + 2; break;
|
|
801
|
+
case b: h = (r - g) / d + 4; break;
|
|
802
|
+
}
|
|
803
|
+
h = (h * 60).toFixed(1);
|
|
804
|
+
}
|
|
805
|
+
return { h: +h, s: +(s * 100).toFixed(1), l: +(l * 100).toFixed(1) };
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// 辅助函数:HSL 转十六进制
|
|
809
|
+
function hslToHex(h, s, l) {
|
|
810
|
+
l /= 100;
|
|
811
|
+
const a = s * Math.min(l, 1 - l) / 100;
|
|
812
|
+
const f = n => {
|
|
813
|
+
const k = (n + h / 30) % 12;
|
|
814
|
+
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
815
|
+
return Math.round(255 * color).toString(16).padStart(2, '0');
|
|
816
|
+
};
|
|
817
|
+
return `#${f(0)}${f(8)}${f(4)}`;
|
|
818
|
+
}
|
|
819
|
+
|
|
733
820
|
export default {
|
|
734
821
|
range,
|
|
735
822
|
getPx,
|
|
736
823
|
sleep,
|
|
737
824
|
os,
|
|
738
|
-
sys,
|
|
825
|
+
sys,
|
|
739
826
|
getWindowInfo,
|
|
740
827
|
random,
|
|
741
828
|
guid,
|
|
@@ -762,5 +849,5 @@ export default {
|
|
|
762
849
|
page,
|
|
763
850
|
pages,
|
|
764
851
|
getValueByPath,
|
|
765
|
-
|
|
852
|
+
genLightColor
|
|
766
853
|
}
|
package/package.json
CHANGED
package/types/comps/toast.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { AllowedComponentProps, VNodeProps } from './_common'
|
|
2
2
|
|
|
3
3
|
declare interface ToastProps {
|
|
4
|
+
/**
|
|
5
|
+
* 层级
|
|
6
|
+
*/
|
|
7
|
+
zIndex?: string | number
|
|
4
8
|
/**
|
|
5
9
|
* 是否加载中
|
|
6
10
|
* @default false
|
|
@@ -43,7 +47,7 @@ declare interface _ToastRef {
|
|
|
43
47
|
/**
|
|
44
48
|
* 显示toast,如需一进入页面就显示toast,请在onReady生命周期调用
|
|
45
49
|
*/
|
|
46
|
-
show: () => void
|
|
50
|
+
show: (options: ToastProps) => void
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
declare interface _Toast {
|