@lambo-design/shared 1.0.0-beta.241 → 1.0.0-beta.243

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 (170) hide show
  1. package/config/config.js +51 -51
  2. package/config/env.js +4 -4
  3. package/config/index.js +7 -7
  4. package/config/themes/atrovirens/atrovirens.less +667 -667
  5. package/config/themes/atrovirens/var.less +674 -674
  6. package/config/themes/blue/blue.less +669 -669
  7. package/config/themes/blue/var.less +677 -677
  8. package/config/themes/blue-white/blue-white.less +669 -669
  9. package/config/themes/blue-white/var.less +676 -676
  10. package/config/themes/blue-white-tight/blue-white-tight.less +672 -672
  11. package/config/themes/blue-white-tight/var.less +677 -677
  12. package/config/themes/danqing/danqing.less +668 -668
  13. package/config/themes/danqing/danqing.wxss +572 -572
  14. package/config/themes/danqing/var.less +679 -679
  15. package/config/themes/deep/deep.less +669 -669
  16. package/config/themes/deep/var.less +677 -677
  17. package/config/themes/default/default.less +671 -671
  18. package/config/themes/default/var.less +677 -677
  19. package/config/themes/eap/eap.less +671 -671
  20. package/config/themes/eap/var.less +677 -677
  21. package/config/themes/gold/gold.less +671 -671
  22. package/config/themes/gold/var.less +677 -677
  23. package/config/themes/index.js +28 -28
  24. package/config/themes/lime/lime.less +671 -671
  25. package/config/themes/lime/var.less +678 -678
  26. package/config/themes/orange/orange.less +671 -671
  27. package/config/themes/orange/var.less +678 -678
  28. package/config/themes/red/red.less +671 -671
  29. package/config/themes/red/var.less +677 -677
  30. package/config/themes/theme-atrovirens.js +558 -558
  31. package/config/themes/theme-blue.js +558 -558
  32. package/config/themes/theme-bw.js +558 -558
  33. package/config/themes/theme-bwt.js +559 -559
  34. package/config/themes/theme-danqing.js +558 -558
  35. package/config/themes/theme-deep.js +558 -558
  36. package/config/themes/theme-default.js +558 -558
  37. package/config/themes/theme-eap.js +558 -558
  38. package/config/themes/theme-gold.js +558 -558
  39. package/config/themes/theme-lime.js +558 -558
  40. package/config/themes/theme-orange.js +559 -559
  41. package/config/themes/theme-red.js +558 -558
  42. package/config/themes/theme-white.js +557 -557
  43. package/config/themes/white/var.less +675 -675
  44. package/config/themes/white/white.less +668 -668
  45. package/directives/index.js +23 -23
  46. package/directives/module/draggable.js +56 -56
  47. package/directives/module/permission.js +49 -49
  48. package/directives/module/print.js +1 -1
  49. package/directives/module/vue-print-nb/README.md +63 -63
  50. package/directives/module/vue-print-nb/print.js +94 -94
  51. package/directives/module/vue-print-nb/printarea.js +532 -532
  52. package/index.js +10 -10
  53. package/nstyles/common.less +197 -197
  54. package/nstyles/components/404.less +46 -46
  55. package/nstyles/components/button.less +34 -34
  56. package/nstyles/components/date-picker.less +37 -37
  57. package/nstyles/components/drawer.less +20 -20
  58. package/nstyles/components/dropdown.less +18 -18
  59. package/nstyles/components/excel-flow.less +72 -72
  60. package/nstyles/components/form.less +313 -313
  61. package/nstyles/components/index.less +23 -23
  62. package/nstyles/components/layout/collect.less +10 -10
  63. package/nstyles/components/layout/detail-view.less +107 -107
  64. package/nstyles/components/layout/full-screen.less +7 -7
  65. package/nstyles/components/layout/index.less +7 -7
  66. package/nstyles/components/layout/other-menu.less +142 -142
  67. package/nstyles/components/layout/page-view.less +101 -101
  68. package/nstyles/components/layout/sider-trigger.less +41 -41
  69. package/nstyles/components/layout/tags-nav.less +113 -113
  70. package/nstyles/components/modal.less +85 -85
  71. package/nstyles/components/n-button.less +131 -131
  72. package/nstyles/components/n-image-preview.less +131 -131
  73. package/nstyles/components/n-model/index.less +19 -19
  74. package/nstyles/components/n-model/report-index.less +43 -43
  75. package/nstyles/components/n-panel.less +40 -40
  76. package/nstyles/components/n-picker.less +37 -37
  77. package/nstyles/components/n-sign.less +17 -17
  78. package/nstyles/components/n-tooltip.less +10 -10
  79. package/nstyles/components/panel.less +31 -31
  80. package/nstyles/components/select.less +3 -3
  81. package/nstyles/components/sign.less +27 -27
  82. package/nstyles/components/table.less +315 -315
  83. package/nstyles/components/tree.less +158 -158
  84. package/nstyles/components/upload.less +164 -164
  85. package/nstyles/index.less +5 -5
  86. package/nstyles/reset.less +65 -65
  87. package/nstyles/third/ag.less +174 -174
  88. package/nstyles/third/index.less +11 -11
  89. package/nstyles/third/view-design.less +366 -366
  90. package/nstyles/variables/base.less +143 -143
  91. package/nstyles/variables/index.less +4 -4
  92. package/nstyles/variables/theme/default/button.less +7 -7
  93. package/nstyles/variables/theme/default/common.less +57 -57
  94. package/nstyles/variables/theme/default/index.less +7 -7
  95. package/nstyles/variables/theme/default/layout.less +40 -40
  96. package/nstyles/variables/theme/default/table.less +37 -37
  97. package/nstyles/variables/theme/default/tag.less +3 -3
  98. package/nstyles/variables/theme/default/upload.less +3 -3
  99. package/nstyles/variables/theme/index.less +13 -13
  100. package/nstyles/variables/theme/small/button.less +7 -7
  101. package/nstyles/variables/theme/small/common.less +39 -39
  102. package/nstyles/variables/theme/small/index.less +5 -5
  103. package/nstyles/variables/theme/small/layout.less +21 -21
  104. package/nstyles/variables/theme/small/table.less +17 -17
  105. package/nstyles/variables/theme/small/tag.less +3 -3
  106. package/package.json +1 -1
  107. package/plugin/index.js +12 -12
  108. package/plugin/module/date-format.js +30 -30
  109. package/plugin/module/loading.js +26 -26
  110. package/plugin/module/warn-handler.js +11 -11
  111. package/styles/variables.less +21 -21
  112. package/utils/ajax/cacheconf.js +19 -19
  113. package/utils/ajax/content-type.js +30 -30
  114. package/utils/ajax/index.js +12 -12
  115. package/utils/ajax/interceptors.js +97 -97
  116. package/utils/assist.js +147 -147
  117. package/utils/base64.js +126 -126
  118. package/utils/blob.js +47 -47
  119. package/utils/bus.js +3 -3
  120. package/utils/crypto/index.js +48 -48
  121. package/utils/crypto/md5.js +152 -152
  122. package/utils/crypto/sm3.js +235 -235
  123. package/utils/date.js +381 -381
  124. package/utils/dict/built-in-dict.js +20 -20
  125. package/utils/dict/index.js +167 -167
  126. package/utils/dom.js +38 -38
  127. package/utils/event.js +72 -72
  128. package/utils/excel.js +655 -655
  129. package/utils/file.js +19 -19
  130. package/utils/form/validate.js +29 -29
  131. package/utils/half-year.js +68 -68
  132. package/utils/index.js +41 -41
  133. package/utils/json.js +29 -29
  134. package/utils/lodop.js +165 -165
  135. package/utils/menu/before-close.js +17 -17
  136. package/utils/menu/index.js +395 -395
  137. package/utils/mime_type.js +67 -67
  138. package/utils/modelerUtil.js +227 -227
  139. package/utils/n/api.js +22 -22
  140. package/utils/n/date.js +57 -57
  141. package/utils/n/index.js +9 -9
  142. package/utils/n/is-type.js +176 -176
  143. package/utils/n/number.js +144 -144
  144. package/utils/n/permission-cache.js +11 -11
  145. package/utils/n/reuqest/axiosN.js +17 -17
  146. package/utils/n/reuqest/content-type.js +19 -19
  147. package/utils/n/reuqest/interceptors.js +95 -95
  148. package/utils/n/reuqest/url-params.js +12 -12
  149. package/utils/n/storage.js +51 -51
  150. package/utils/n/token.js +51 -51
  151. package/utils/n/user-cache.js +11 -11
  152. package/utils/n/user.js +34 -34
  153. package/utils/n/uuid.js +16 -16
  154. package/utils/n-generator-routers.js +208 -208
  155. package/utils/n-router.js +205 -205
  156. package/utils/n-theme.js +30 -30
  157. package/utils/number.js +180 -180
  158. package/utils/oss.js +57 -57
  159. package/utils/platform.js +1334 -1334
  160. package/utils/quarter.js +58 -58
  161. package/utils/storage.js +198 -198
  162. package/utils/style.js +24 -24
  163. package/utils/theme.js +138 -138
  164. package/utils/transfer-queue.js +7 -7
  165. package/utils/transform.js +204 -204
  166. package/utils/type.js +102 -102
  167. package/utils/util.js +795 -795
  168. package/utils/validator.js +181 -181
  169. package/utils/vxetable/index.js +25 -25
  170. package/utils/zoomScroll.js +9 -9
@@ -1,205 +1,205 @@
1
- /**
2
- * 将旧版本json 转换为新版 json
3
- *
4
- * 转换规则:
5
- * 1. 创建 widgetList:
6
- * - 创建一个 grid 类型的容器,包含 cols 数组。
7
- * - 每个 basicFormField 生成一个 grid-col,并填充到 cols 数组中。
8
- * - 每个 grid-col 的 span 值根据 gridColumns 计算,即 24 / gridColumns。
9
- * - 如果 basicFormField 的 type 是 ['textarea', 'imgUpload', 'imgListUpload', 'fileUpload', 'videoUpload'] 中的一个,则 span 设置为 24。
10
- * 2. 生成 formConfig:
11
- * - 将 sources 中除 gridColumns、workFlow 和 basicFormFields 外的所有属性复制到 formConfig 中。
12
- * 3. 生成 workFlow:
13
- * - 直接将 sources 中的 workFlow 复制到 target 的 workFlow 中。
14
- * 4. 对于每个 basicFormField:
15
- * - 生成唯一的 ID。
16
- * - 添加 formItemFlag 属性并设置为 true。
17
- * - 添加 options 对象,其中 name 字段值来自 basicFormField.formKey。
18
- * - options 对象还包括其他默认配置项。
19
- * @param {*} sources
20
- * @returns
21
- */
22
- export function transformToNew(sources) {
23
- // 创建一个新的target对象
24
- const target = {
25
- widgetList: [
26
- {
27
- id: "grid-id-1", // 默认值
28
- type: "grid",
29
- category: "container",
30
- icon: "grid",
31
- cols: [],
32
- options: {
33
- name: "grid-name-1", // 默认值
34
- hidden: false,
35
- gutter: 12
36
- }
37
- }
38
- ],
39
- formConfig: {},
40
- workFlow: {} // 新增workFlow属性
41
- };
42
-
43
- // 计算每列的span值
44
- const defaultSpan = 24 / sources.gridColumns;
45
- const specialTypes = ['textarea', 'imgUpload', 'imgListUpload', 'fileUpload', 'videoUpload'];
46
-
47
- // 动态生成cols
48
- sources.basicFormFields.forEach((field, index) => {
49
- const span = specialTypes.includes(field.type) ? 24 : defaultSpan;
50
-
51
- // 为每个field增加id和options
52
- const uniqueFieldId = `form-filed-${index}`;
53
- field.id = uniqueFieldId;
54
- field.formItemFlag = true;
55
- field.options = {
56
- name: field.formKey,
57
- customClass: "",
58
- hidden: false,
59
- defaultValue: null,
60
- validation: "",
61
- validationHint: "",
62
- onCreated: "",
63
- onMounted: "",
64
- onInput: "",
65
- onChange: "",
66
- onFocus: "",
67
- onBlur: "",
68
- onValidate: "",
69
- onAppendButtonClick: ""
70
- };
71
-
72
- target.widgetList[0].cols.push({
73
- id: `default-col-id-${index + 1}`, // 默认值
74
- type: "grid-col",
75
- category: "container",
76
- icon: "grid-col",
77
- internal: true,
78
- widgetList: [field],
79
- options: {
80
- name: `col-name-${index + 1}`, // 默认值
81
- hidden: false,
82
- span: span, // 根据规则2计算span值
83
- offset: 0,
84
- push: 0,
85
- pull: 0,
86
- md: span,
87
- sm: span,
88
- xs: span,
89
- responsive: false,
90
- customClass: ""
91
- }
92
- });
93
- });
94
-
95
- // 将sources中的属性(除了gridColumns和workFlow)复制到target的formConfig中
96
- for (let key in sources) {
97
- if (key !== 'gridColumns' && key !== 'workFlow' && key !== 'basicFormFields') {
98
- target.formConfig[key] = sources[key];
99
- }
100
- }
101
-
102
- // 将sources中的workFlow复制到target的workFlow中
103
- target.workFlow = sources.workFlow;
104
-
105
- return target;
106
- }
107
-
108
- // // 示例调用
109
- // const sources = {
110
- // validValue: "true",
111
- // formName: "测试",
112
- // gridColumns: 3,
113
- // labelWidth: 100,
114
- // labelPosition: "left",
115
- // saveWay: "0",
116
- // businessKey: [],
117
- // apiId: 74,
118
- // detailUrl: "/ibp-upms-server/manage/demoUser/get",
119
- // createUrl: "/ibp-upms-server/manage/demoUser/create",
120
- // updateUrl: "/ibp-upms-server/manage/demoUser/update",
121
- // customButton: false,
122
- // customMethod: "",
123
- // select: {
124
- // apiId: 74,
125
- // isGetFromApi: true
126
- // },
127
- // basicFormFields: [
128
- // {
129
- // formKey: "userId",
130
- // title: "用户编码",
131
- // required: false,
132
- // type: "input",
133
- // customComponentName: "",
134
- // customComponentMethod: "",
135
- // orders: 1,
136
- // enumType: "code",
137
- // enumKey: "",
138
- // enumList: [],
139
- // props: {
140
- // maxlength: 1024,
141
- // clearable: false,
142
- // limitFileNum: 5,
143
- // limitImgNum: 5
144
- // },
145
- // validate: {
146
- // way: "default",
147
- // type: "",
148
- // trigger: "",
149
- // validator: "",
150
- // customMethod: "",
151
- // customUrl: ""
152
- // },
153
- // condition: "",
154
- // onChange: "",
155
- // defaultValue: ""
156
- // },
157
- // {
158
- // formKey: "userName",
159
- // title: "用户名",
160
- // required: true,
161
- // type: "input",
162
- // customComponentName: "",
163
- // customComponentMethod: "",
164
- // orders: 2,
165
- // enumType: "code",
166
- // enumKey: "",
167
- // enumList: [],
168
- // props: {
169
- // maxlength: 1024,
170
- // clearable: true,
171
- // limitFileNum: 5,
172
- // limitImgNum: 5
173
- // },
174
- // validate: {
175
- // way: "default",
176
- // type: "string",
177
- // trigger: "blur",
178
- // validator: "",
179
- // customMethod: "",
180
- // customUrl: ""
181
- // },
182
- // condition: "",
183
- // onChange: "",
184
- // defaultValue: ""
185
- // }
186
- // ],
187
- // workFlow: {
188
- // procId: "",
189
- // applyId: "",
190
- // taskNode: "",
191
- // title: "流程办理",
192
- // smartFlowServerContext: "",
193
- // upmsServerContext: "",
194
- // width: 400,
195
- // executionCompleted: "",
196
- // businessFormSave: "",
197
- // required: false,
198
- // isUseWorkflow: false,
199
- // isProcessCallbacks: false,
200
- // callbackUrl: ""
201
- // }
202
- // };
203
- // console.log("old json:"+JSON.stringify(sources, null, 2));
204
- // const transformedTarget = transformToNew(sources);
1
+ /**
2
+ * 将旧版本json 转换为新版 json
3
+ *
4
+ * 转换规则:
5
+ * 1. 创建 widgetList:
6
+ * - 创建一个 grid 类型的容器,包含 cols 数组。
7
+ * - 每个 basicFormField 生成一个 grid-col,并填充到 cols 数组中。
8
+ * - 每个 grid-col 的 span 值根据 gridColumns 计算,即 24 / gridColumns。
9
+ * - 如果 basicFormField 的 type 是 ['textarea', 'imgUpload', 'imgListUpload', 'fileUpload', 'videoUpload'] 中的一个,则 span 设置为 24。
10
+ * 2. 生成 formConfig:
11
+ * - 将 sources 中除 gridColumns、workFlow 和 basicFormFields 外的所有属性复制到 formConfig 中。
12
+ * 3. 生成 workFlow:
13
+ * - 直接将 sources 中的 workFlow 复制到 target 的 workFlow 中。
14
+ * 4. 对于每个 basicFormField:
15
+ * - 生成唯一的 ID。
16
+ * - 添加 formItemFlag 属性并设置为 true。
17
+ * - 添加 options 对象,其中 name 字段值来自 basicFormField.formKey。
18
+ * - options 对象还包括其他默认配置项。
19
+ * @param {*} sources
20
+ * @returns
21
+ */
22
+ export function transformToNew(sources) {
23
+ // 创建一个新的target对象
24
+ const target = {
25
+ widgetList: [
26
+ {
27
+ id: "grid-id-1", // 默认值
28
+ type: "grid",
29
+ category: "container",
30
+ icon: "grid",
31
+ cols: [],
32
+ options: {
33
+ name: "grid-name-1", // 默认值
34
+ hidden: false,
35
+ gutter: 12
36
+ }
37
+ }
38
+ ],
39
+ formConfig: {},
40
+ workFlow: {} // 新增workFlow属性
41
+ };
42
+
43
+ // 计算每列的span值
44
+ const defaultSpan = 24 / sources.gridColumns;
45
+ const specialTypes = ['textarea', 'imgUpload', 'imgListUpload', 'fileUpload', 'videoUpload'];
46
+
47
+ // 动态生成cols
48
+ sources.basicFormFields.forEach((field, index) => {
49
+ const span = specialTypes.includes(field.type) ? 24 : defaultSpan;
50
+
51
+ // 为每个field增加id和options
52
+ const uniqueFieldId = `form-filed-${index}`;
53
+ field.id = uniqueFieldId;
54
+ field.formItemFlag = true;
55
+ field.options = {
56
+ name: field.formKey,
57
+ customClass: "",
58
+ hidden: false,
59
+ defaultValue: "",
60
+ validation: "",
61
+ validationHint: "",
62
+ onCreated: "",
63
+ onMounted: "",
64
+ onInput: "",
65
+ onChange: "",
66
+ onFocus: "",
67
+ onBlur: "",
68
+ onValidate: "",
69
+ onAppendButtonClick: ""
70
+ };
71
+
72
+ target.widgetList[0].cols.push({
73
+ id: `default-col-id-${index + 1}`, // 默认值
74
+ type: "grid-col",
75
+ category: "container",
76
+ icon: "grid-col",
77
+ internal: true,
78
+ widgetList: [field],
79
+ options: {
80
+ name: `col-name-${index + 1}`, // 默认值
81
+ hidden: false,
82
+ span: span, // 根据规则2计算span值
83
+ offset: 0,
84
+ push: 0,
85
+ pull: 0,
86
+ md: span,
87
+ sm: span,
88
+ xs: span,
89
+ responsive: false,
90
+ customClass: ""
91
+ }
92
+ });
93
+ });
94
+
95
+ // 将sources中的属性(除了gridColumns和workFlow)复制到target的formConfig中
96
+ for (let key in sources) {
97
+ if (key !== 'gridColumns' && key !== 'workFlow' && key !== 'basicFormFields') {
98
+ target.formConfig[key] = sources[key];
99
+ }
100
+ }
101
+
102
+ // 将sources中的workFlow复制到target的workFlow中
103
+ target.workFlow = sources.workFlow;
104
+
105
+ return target;
106
+ }
107
+
108
+ // // 示例调用
109
+ // const sources = {
110
+ // validValue: "true",
111
+ // formName: "测试",
112
+ // gridColumns: 3,
113
+ // labelWidth: 100,
114
+ // labelPosition: "left",
115
+ // saveWay: "0",
116
+ // businessKey: [],
117
+ // apiId: 74,
118
+ // detailUrl: "/ibp-upms-server/manage/demoUser/get",
119
+ // createUrl: "/ibp-upms-server/manage/demoUser/create",
120
+ // updateUrl: "/ibp-upms-server/manage/demoUser/update",
121
+ // customButton: false,
122
+ // customMethod: "",
123
+ // select: {
124
+ // apiId: 74,
125
+ // isGetFromApi: true
126
+ // },
127
+ // basicFormFields: [
128
+ // {
129
+ // formKey: "userId",
130
+ // title: "用户编码",
131
+ // required: false,
132
+ // type: "input",
133
+ // customComponentName: "",
134
+ // customComponentMethod: "",
135
+ // orders: 1,
136
+ // enumType: "code",
137
+ // enumKey: "",
138
+ // enumList: [],
139
+ // props: {
140
+ // maxlength: 1024,
141
+ // clearable: false,
142
+ // limitFileNum: 5,
143
+ // limitImgNum: 5
144
+ // },
145
+ // validate: {
146
+ // way: "default",
147
+ // type: "",
148
+ // trigger: "",
149
+ // validator: "",
150
+ // customMethod: "",
151
+ // customUrl: ""
152
+ // },
153
+ // condition: "",
154
+ // onChange: "",
155
+ // defaultValue: ""
156
+ // },
157
+ // {
158
+ // formKey: "userName",
159
+ // title: "用户名",
160
+ // required: true,
161
+ // type: "input",
162
+ // customComponentName: "",
163
+ // customComponentMethod: "",
164
+ // orders: 2,
165
+ // enumType: "code",
166
+ // enumKey: "",
167
+ // enumList: [],
168
+ // props: {
169
+ // maxlength: 1024,
170
+ // clearable: true,
171
+ // limitFileNum: 5,
172
+ // limitImgNum: 5
173
+ // },
174
+ // validate: {
175
+ // way: "default",
176
+ // type: "string",
177
+ // trigger: "blur",
178
+ // validator: "",
179
+ // customMethod: "",
180
+ // customUrl: ""
181
+ // },
182
+ // condition: "",
183
+ // onChange: "",
184
+ // defaultValue: ""
185
+ // }
186
+ // ],
187
+ // workFlow: {
188
+ // procId: "",
189
+ // applyId: "",
190
+ // taskNode: "",
191
+ // title: "流程办理",
192
+ // smartFlowServerContext: "",
193
+ // upmsServerContext: "",
194
+ // width: 400,
195
+ // executionCompleted: "",
196
+ // businessFormSave: "",
197
+ // required: false,
198
+ // isUseWorkflow: false,
199
+ // isProcessCallbacks: false,
200
+ // callbackUrl: ""
201
+ // }
202
+ // };
203
+ // console.log("old json:"+JSON.stringify(sources, null, 2));
204
+ // const transformedTarget = transformToNew(sources);
205
205
  // console.log("new json:"+JSON.stringify(transformedTarget, null, 2));
package/utils/type.js CHANGED
@@ -1,102 +1,102 @@
1
- /*
2
- * Copyright 2019 WeBank
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- const objectToString = Object.prototype.toString;
19
- const OBJECT_STRING = '[object Object]';
20
-
21
- /**
22
- * 是否是普通对象
23
- * @param {any} obj
24
- * @return {Boolean}
25
- */
26
- export function isPlainObject(obj) {
27
- return objectToString.call(obj) === OBJECT_STRING;
28
- }
29
-
30
- /**
31
- * 是否是数字
32
- * @param {any} value
33
- * @return {Boolean}
34
- */
35
- export function isNumber(value) {
36
- return typeof value === 'number';
37
- }
38
-
39
- /**
40
- * 是否是日期
41
- * @param {any} value
42
- * @return {Boolean}
43
- */
44
- export function isDate(value) {
45
- return objectToString.call(value) === '[object Date]';
46
- }
47
-
48
- /**
49
- * 是否是函数
50
- * @param {any} value
51
- * @return {Boolean}
52
- */
53
- export function isFunction(value) {
54
- return typeof value === 'function';
55
- }
56
-
57
- /**
58
- * 是否是函数
59
- * @param {any} value
60
- * @return {Boolean}
61
- */
62
- export function isObject(value) {
63
- let type = typeof value;
64
- return !!value && (type == 'object' || type == 'function');
65
- }
66
-
67
- /**
68
- * 是否是数组
69
- * @param {any} value
70
- * @return {Boolean}
71
- */
72
- export function isArray(value) {
73
- return Array.isArray(value);
74
- }
75
-
76
- /**
77
- * 是否像对象
78
- * @param {any} value
79
- * @return {Boolean}
80
- */
81
- export function isObjectLike(value) {
82
- return !!value && typeof value == 'object';
83
- }
84
-
85
- /**
86
- * 是否是字符串
87
- * @param {any} value
88
- * @return {Boolean}
89
- */
90
- export function isString(value) {
91
- return typeof value == 'string' ||
92
- (!isArray(value) && isObjectLike(value) && objectToString.call(value) == '[object String]');
93
- }
94
-
95
- /**
96
- * 是否是空的
97
- * @param {any} value
98
- * @return {Boolean}
99
- */
100
- export function isNull(value) {
101
- return value === undefined || value === null || value === '';
102
- }
1
+ /*
2
+ * Copyright 2019 WeBank
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ const objectToString = Object.prototype.toString;
19
+ const OBJECT_STRING = '[object Object]';
20
+
21
+ /**
22
+ * 是否是普通对象
23
+ * @param {any} obj
24
+ * @return {Boolean}
25
+ */
26
+ export function isPlainObject(obj) {
27
+ return objectToString.call(obj) === OBJECT_STRING;
28
+ }
29
+
30
+ /**
31
+ * 是否是数字
32
+ * @param {any} value
33
+ * @return {Boolean}
34
+ */
35
+ export function isNumber(value) {
36
+ return typeof value === 'number';
37
+ }
38
+
39
+ /**
40
+ * 是否是日期
41
+ * @param {any} value
42
+ * @return {Boolean}
43
+ */
44
+ export function isDate(value) {
45
+ return objectToString.call(value) === '[object Date]';
46
+ }
47
+
48
+ /**
49
+ * 是否是函数
50
+ * @param {any} value
51
+ * @return {Boolean}
52
+ */
53
+ export function isFunction(value) {
54
+ return typeof value === 'function';
55
+ }
56
+
57
+ /**
58
+ * 是否是函数
59
+ * @param {any} value
60
+ * @return {Boolean}
61
+ */
62
+ export function isObject(value) {
63
+ let type = typeof value;
64
+ return !!value && (type == 'object' || type == 'function');
65
+ }
66
+
67
+ /**
68
+ * 是否是数组
69
+ * @param {any} value
70
+ * @return {Boolean}
71
+ */
72
+ export function isArray(value) {
73
+ return Array.isArray(value);
74
+ }
75
+
76
+ /**
77
+ * 是否像对象
78
+ * @param {any} value
79
+ * @return {Boolean}
80
+ */
81
+ export function isObjectLike(value) {
82
+ return !!value && typeof value == 'object';
83
+ }
84
+
85
+ /**
86
+ * 是否是字符串
87
+ * @param {any} value
88
+ * @return {Boolean}
89
+ */
90
+ export function isString(value) {
91
+ return typeof value == 'string' ||
92
+ (!isArray(value) && isObjectLike(value) && objectToString.call(value) == '[object String]');
93
+ }
94
+
95
+ /**
96
+ * 是否是空的
97
+ * @param {any} value
98
+ * @return {Boolean}
99
+ */
100
+ export function isNull(value) {
101
+ return value === undefined || value === null || value === '';
102
+ }