uview-plus 3.3.31 → 3.3.33

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,7 +1,12 @@
1
+ ## 3.3.33(2024-09-18)
2
+ fix: 修复test.date('008')等验证结果不准确
3
+
4
+ ## 3.3.32(2024-09-09)
5
+ fix: u-keyboard名称冲突warning
6
+
1
7
  ## 3.3.31(2024-08-31)
2
8
  feat: qrcode初步支持nvue
3
9
 
4
-
5
10
  ## 3.3.30(2024-08-30)
6
11
  fix: slider兼容step为字符串类型
7
12
 
@@ -74,7 +74,7 @@
74
74
  import { randomArray, sleep } from '../../libs/function/index';
75
75
  /**
76
76
  * keyboard 键盘组件
77
- * @description 此为uView自定义的键盘面板,内含了数字键盘,车牌号键,身份证号键盘3种模式,都有可以打乱按键顺序的选项。
77
+ * @description 此为uview-plus自定义的键盘面板,内含了数字键盘,车牌号键,身份证号键盘3种模式,都有可以打乱按键顺序的选项。
78
78
  * @tutorial https://uview-plus.jiangruyi.com/components/keyboard.html
79
79
  * @property {Boolean} random 是否打乱键盘的顺序
80
80
  * @event {Function} change 点击键盘触发
@@ -82,7 +82,7 @@
82
82
  * @example <u-keyboard ref="uKeyboard" mode="car" v-model="show"></u-keyboard>
83
83
  */
84
84
  export default {
85
- name: "u-keyboard",
85
+ name: "u-car-keyboard",
86
86
  mixins: [mpMixin, mixin, props],
87
87
  data() {
88
88
  return {
@@ -55,6 +55,7 @@
55
55
  * @example
56
56
  */
57
57
  export default {
58
+ name: 'u-number-keyboard',
58
59
  mixins: [mpMixin, mixin, props],
59
60
  data() {
60
61
  return {
package/index.js CHANGED
@@ -111,7 +111,7 @@ function toCamelCase(str) {
111
111
  const install = (Vue) => {
112
112
  // #ifdef H5
113
113
  components.forEach(function(component) {
114
- Vue.component(component.name, component);
114
+ Vue.component(component.name, component);
115
115
  });
116
116
  // #endif
117
117
 
@@ -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.31",
5
+ "version": "3.3.33",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",