uview-plus 3.3.32 → 3.3.34

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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 3.3.34(2024-09-23)
2
+ feat: 支持toast设置duration值为-1时不自动关闭
3
+
4
+ ## 3.3.33(2024-09-18)
5
+ fix: 修复test.date('008')等验证结果不准确
6
+
1
7
  ## 3.3.32(2024-09-09)
2
8
  fix: u-keyboard名称冲突warning
3
9
 
@@ -165,12 +165,15 @@
165
165
  // 清除定时器
166
166
  this.clearTimer()
167
167
  this.isShow = true
168
- this.timer = setTimeout(() => {
169
- // 倒计时结束,清除定时器,隐藏toast组件
170
- this.clearTimer()
171
- // 判断是否存在callback方法,如果存在就执行
172
- typeof(this.tmpConfig.complete) === 'function' && this.tmpConfig.complete()
173
- }, this.tmpConfig.duration)
168
+ // -1时不自动关闭
169
+ if (this.duration !== -1) {
170
+ this.timer = setTimeout(() => {
171
+ // 倒计时结束,清除定时器,隐藏toast组件
172
+ this.clearTimer()
173
+ // 判断是否存在callback方法,如果存在就执行
174
+ typeof(this.tmpConfig.complete) === 'function' && this.tmpConfig.complete()
175
+ }, this.tmpConfig.duration)
176
+ }
174
177
  },
175
178
  // 隐藏toast组件,由父组件通过this.$refs.xxx.hide()形式调用
176
179
  hide() {
@@ -22,12 +22,44 @@ export function url(value) {
22
22
 
23
23
  /**
24
24
  * 验证日期格式
25
+ * @param {number | string} value yyyy-mm-dd hh:mm:ss 或 时间戳
25
26
  */
26
27
  export function date(value) {
27
- if (!value) return false
28
- // 判断是否数值或者字符串数值(意味着为时间戳),转为数值,否则new Date无法识别字符串时间戳
29
- if (number(value)) value = +value
30
- return !/Invalid|NaN/.test(new Date(value).toString())
28
+ if (!value) return false;
29
+ // number类型,判断是否是时间戳
30
+ if (typeof value === "number") {
31
+ // len === 10 秒级时间戳 len === 13 毫秒级时间戳
32
+ if (value.toString().length !== 10 && value.toString().length !== 13) {
33
+ return false;
34
+ }
35
+ return !isNaN(new Date(value).getTime());
36
+ }
37
+ if (typeof value === "string") {
38
+ // 是否为string类型时间戳
39
+ const numV = Number(value);
40
+ if (!isNaN(numV)) {
41
+ if (
42
+ numV.toString().length === 10 ||
43
+ numV.toString().length === 13
44
+ ) {
45
+ return !isNaN(new Date(numV).getTime());
46
+ }
47
+ }
48
+ // 非时间戳,且长度在yyyy-mm-dd 至 yyyy-mm-dd hh:mm:ss 之间
49
+ if (value.length < 10 || value.length > 19) {
50
+ return false;
51
+ }
52
+ const dateRegex =
53
+ /^\d{4}[-\/]\d{2}[-\/]\d{2}( \d{1,2}:\d{2}(:\d{2})?)?$/;
54
+ if (!dateRegex.test(value)) {
55
+ return false;
56
+ }
57
+ // 检查是否为有效日期
58
+ const dateValue = new Date(value);
59
+ return !isNaN(dateValue.getTime());
60
+ }
61
+ // 非number和string类型,不做校验
62
+ return false;
31
63
  }
32
64
 
33
65
  /**
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3移动组件库。",
5
- "version": "3.3.32",
5
+ "version": "3.3.34",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",