uview-pro 0.0.1

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 (149) hide show
  1. package/changelog.md +6 -0
  2. package/components/u-action-sheet/u-action-sheet.vue +205 -0
  3. package/components/u-alert-tips/u-alert-tips.vue +241 -0
  4. package/components/u-avatar/u-avatar.vue +220 -0
  5. package/components/u-avatar-cropper/u-avatar-cropper.vue +329 -0
  6. package/components/u-avatar-cropper/weCropper.d.ts +54 -0
  7. package/components/u-avatar-cropper/weCropper.js +1267 -0
  8. package/components/u-avatar-cropper/weCropper.ts +1254 -0
  9. package/components/u-back-top/u-back-top.vue +156 -0
  10. package/components/u-badge/u-badge.vue +189 -0
  11. package/components/u-button/u-button.vue +562 -0
  12. package/components/u-calendar/u-calendar.vue +725 -0
  13. package/components/u-car-keyboard/u-car-keyboard.vue +236 -0
  14. package/components/u-card/u-card.vue +240 -0
  15. package/components/u-cell-group/u-cell-group.vue +56 -0
  16. package/components/u-cell-item/u-cell-item.vue +245 -0
  17. package/components/u-checkbox/u-checkbox.vue +310 -0
  18. package/components/u-checkbox-group/u-checkbox-group.vue +134 -0
  19. package/components/u-circle-progress/u-circle-progress.vue +210 -0
  20. package/components/u-col/u-col.vue +135 -0
  21. package/components/u-collapse/u-collapse.vue +82 -0
  22. package/components/u-collapse-item/u-collapse-item.vue +190 -0
  23. package/components/u-column-notice/u-column-notice.vue +264 -0
  24. package/components/u-count-down/u-count-down.vue +333 -0
  25. package/components/u-count-to/u-count-to.vue +297 -0
  26. package/components/u-divider/u-divider.vue +141 -0
  27. package/components/u-dropdown/u-dropdown.vue +311 -0
  28. package/components/u-dropdown-item/u-dropdown-item.vue +135 -0
  29. package/components/u-empty/u-empty.vue +111 -0
  30. package/components/u-field/u-field.vue +469 -0
  31. package/components/u-form/u-form.vue +162 -0
  32. package/components/u-form-item/u-form-item.vue +476 -0
  33. package/components/u-full-screen/u-full-screen.vue +80 -0
  34. package/components/u-gap/u-gap.vue +48 -0
  35. package/components/u-grid/u-grid.vue +101 -0
  36. package/components/u-grid-item/u-grid-item.vue +136 -0
  37. package/components/u-icon/u-icon.vue +389 -0
  38. package/components/u-image/types.ts +48 -0
  39. package/components/u-image/u-image.vue +218 -0
  40. package/components/u-index-anchor/u-index-anchor.vue +101 -0
  41. package/components/u-index-list/u-index-list.vue +376 -0
  42. package/components/u-input/u-input.vue +462 -0
  43. package/components/u-keyboard/u-keyboard.vue +188 -0
  44. package/components/u-lazy-load/u-lazy-load.vue +288 -0
  45. package/components/u-line/u-line.vue +71 -0
  46. package/components/u-line-progress/u-line-progress.vue +128 -0
  47. package/components/u-link/u-link.vue +87 -0
  48. package/components/u-loading/u-loading.vue +111 -0
  49. package/components/u-loadmore/u-loadmore.vue +205 -0
  50. package/components/u-mask/u-mask.vue +137 -0
  51. package/components/u-message-input/u-message-input.vue +315 -0
  52. package/components/u-modal/u-modal.vue +284 -0
  53. package/components/u-navbar/u-navbar.vue +314 -0
  54. package/components/u-no-network/image.ts +2 -0
  55. package/components/u-no-network/u-no-network.vue +311 -0
  56. package/components/u-notice-bar/u-notice-bar.vue +274 -0
  57. package/components/u-number-box/u-number-box.vue +344 -0
  58. package/components/u-number-keyboard/u-number-keyboard.vue +170 -0
  59. package/components/u-parse/libs/CssHandler.js +100 -0
  60. package/components/u-parse/libs/MpHtmlParser.js +580 -0
  61. package/components/u-parse/libs/config.js +80 -0
  62. package/components/u-parse/libs/handler.wxs +22 -0
  63. package/components/u-parse/libs/trees.vue +505 -0
  64. package/components/u-parse/u-parse.vue +645 -0
  65. package/components/u-picker/u-picker.vue +808 -0
  66. package/components/u-popup/u-popup.vue +404 -0
  67. package/components/u-radio/u-radio.vue +272 -0
  68. package/components/u-radio-group/u-radio-group.vue +116 -0
  69. package/components/u-rate/u-rate.vue +349 -0
  70. package/components/u-read-more/u-read-more.vue +199 -0
  71. package/components/u-row/u-row.vue +95 -0
  72. package/components/u-row-notice/u-row-notice.vue +273 -0
  73. package/components/u-search/u-search.vue +298 -0
  74. package/components/u-section/u-section.vue +175 -0
  75. package/components/u-select/u-select.vue +387 -0
  76. package/components/u-skeleton/u-skeleton.vue +230 -0
  77. package/components/u-slider/u-slider.vue +293 -0
  78. package/components/u-steps/u-steps.vue +200 -0
  79. package/components/u-sticky/u-sticky.vue +189 -0
  80. package/components/u-subsection/u-subsection.vue +388 -0
  81. package/components/u-swipe-action/u-swipe-action.vue +289 -0
  82. package/components/u-swiper/u-swiper.vue +305 -0
  83. package/components/u-switch/u-switch.vue +146 -0
  84. package/components/u-tabbar/u-tabbar.vue +347 -0
  85. package/components/u-table/u-table.vue +104 -0
  86. package/components/u-tabs/u-tabs.vue +322 -0
  87. package/components/u-tabs-swiper/u-tabs-swiper.vue +426 -0
  88. package/components/u-tag/u-tag.vue +270 -0
  89. package/components/u-td/u-td.vue +76 -0
  90. package/components/u-th/u-th.vue +70 -0
  91. package/components/u-time-line/u-time-line.vue +39 -0
  92. package/components/u-time-line-item/u-time-line-item.vue +88 -0
  93. package/components/u-toast/types.ts +4 -0
  94. package/components/u-toast/u-toast.vue +238 -0
  95. package/components/u-top-tips/u-top-tips.vue +118 -0
  96. package/components/u-tr/u-tr.vue +24 -0
  97. package/components/u-upload/u-upload.vue +600 -0
  98. package/components/u-verification-code/u-verification-code.vue +194 -0
  99. package/components/u-waterfall/u-waterfall.vue +186 -0
  100. package/iconfont.css +910 -0
  101. package/index.scss +23 -0
  102. package/index.ts +166 -0
  103. package/libs/config/config.ts +26 -0
  104. package/libs/config/zIndex.ts +37 -0
  105. package/libs/css/color.scss +155 -0
  106. package/libs/css/common.scss +176 -0
  107. package/libs/css/style.components.scss +7 -0
  108. package/libs/css/style.h5.scss +8 -0
  109. package/libs/css/style.mp.scss +72 -0
  110. package/libs/css/style.nvue.scss +3 -0
  111. package/libs/css/style.vue.scss +175 -0
  112. package/libs/function/$parent.ts +22 -0
  113. package/libs/function/addUnit.ts +13 -0
  114. package/libs/function/color.ts +37 -0
  115. package/libs/function/colorGradient.ts +123 -0
  116. package/libs/function/debounce.ts +28 -0
  117. package/libs/function/deepClone.ts +39 -0
  118. package/libs/function/deepMerge.ts +34 -0
  119. package/libs/function/getParent.ts +59 -0
  120. package/libs/function/getRect.ts +26 -0
  121. package/libs/function/guid.ts +42 -0
  122. package/libs/function/md5.ts +397 -0
  123. package/libs/function/parent.ts +21 -0
  124. package/libs/function/queryParams.ts +60 -0
  125. package/libs/function/random.ts +16 -0
  126. package/libs/function/randomArray.ts +11 -0
  127. package/libs/function/route.ts +118 -0
  128. package/libs/function/sys.ts +15 -0
  129. package/libs/function/test.ts +229 -0
  130. package/libs/function/throttle.ts +31 -0
  131. package/libs/function/timeFormat.ts +54 -0
  132. package/libs/function/timeFrom.ts +48 -0
  133. package/libs/function/toast.ts +14 -0
  134. package/libs/function/trim.ts +21 -0
  135. package/libs/function/type2icon.ts +36 -0
  136. package/libs/hooks/useEmitter.ts +77 -0
  137. package/libs/hooks/useParent.ts +29 -0
  138. package/libs/request/index.ts +237 -0
  139. package/libs/store/index.ts +88 -0
  140. package/libs/util/area.ts +1 -0
  141. package/libs/util/async-validator.js +1356 -0
  142. package/libs/util/city.ts +1 -0
  143. package/libs/util/emitter.ts +112 -0
  144. package/libs/util/mitt.ts +118 -0
  145. package/libs/util/parent.ts +20 -0
  146. package/libs/util/province.ts +1 -0
  147. package/package.json +98 -0
  148. package/readme.md +165 -0
  149. package/theme.scss +38 -0
@@ -0,0 +1,397 @@
1
+ /*
2
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
3
+ * Digest Algorithm, as defined in RFC 1321.
4
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
5
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6
+ * Distributed under the BSD License
7
+ * See http://pajhome.org.uk/crypt/md5 for more info.
8
+ */
9
+
10
+ /*
11
+ * Configurable variables. You may need to tweak these to be compatible with
12
+ * the server-side, but the defaults work in most cases.
13
+ */
14
+ let hexcase: number = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
15
+ let b64pad: string = ""; /* base-64 pad character. "=" for strict RFC compliance */
16
+
17
+ /**
18
+ * 这些是通常需要调用的函数
19
+ * @param s 输入字符串
20
+ * @returns 十六进制/BASE64/任意编码的MD5字符串
21
+ */
22
+ function hex_md5(s: string): string { return rstr2hex(rstr_md5(str2rstr_utf8(s))); }
23
+ function b64_md5(s: string): string { return rstr2b64(rstr_md5(str2rstr_utf8(s))); }
24
+ function any_md5(s: string, e: string): string { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); }
25
+ function hex_hmac_md5(k: string, d: string): string {
26
+ return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
27
+ }
28
+ function b64_hmac_md5(k: string, d: string): string {
29
+ return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)));
30
+ }
31
+ function any_hmac_md5(k: string, d: string, e: string): string {
32
+ return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e);
33
+ }
34
+
35
+ /**
36
+ * 执行简单自测,判断 VM 是否正常
37
+ * @returns 是否通过测试
38
+ */
39
+ function md5_vm_test(): boolean {
40
+ return hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
41
+ }
42
+
43
+ /**
44
+ * 计算原始字符串的 MD5
45
+ * @param s 原始字符串
46
+ * @returns MD5 结果字符串
47
+ */
48
+ function rstr_md5(s: string): string {
49
+ return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
50
+ }
51
+
52
+ /**
53
+ * 计算 HMAC-MD5
54
+ * @param key 密钥
55
+ * @param data 数据
56
+ * @returns HMAC-MD5 结果字符串
57
+ */
58
+ function rstr_hmac_md5(key: string, data: string): string {
59
+ let bkey: number[] = rstr2binl(key);
60
+ if(bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
61
+
62
+ const ipad: number[] = Array(16), opad: number[] = Array(16);
63
+ for(let i = 0; i < 16; i++) {
64
+ ipad[i] = bkey[i] ^ 0x36363636;
65
+ opad[i] = bkey[i] ^ 0x5C5C5C5C;
66
+ }
67
+
68
+ const hash: number[] = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
69
+ return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
70
+ }
71
+
72
+ /**
73
+ * 原始字符串转十六进制字符串
74
+ * @param input 输入字符串
75
+ * @returns 十六进制字符串
76
+ */
77
+ function rstr2hex(input: string): string {
78
+ try { hexcase } catch(e) { hexcase=0; }
79
+ const hex_tab: string = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
80
+ let output = "";
81
+ let x: number;
82
+ for(let i = 0; i < input.length; i++) {
83
+ x = input.charCodeAt(i);
84
+ output += hex_tab.charAt((x >>> 4) & 0x0F)
85
+ + hex_tab.charAt( x & 0x0F);
86
+ }
87
+ return output;
88
+ }
89
+
90
+ /**
91
+ * 原始字符串转 BASE64 字符串
92
+ * @param input 输入字符串
93
+ * @returns BASE64 字符串
94
+ */
95
+ function rstr2b64(input: string): string {
96
+ try { b64pad } catch(e) { b64pad=''; }
97
+ const tab: string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
98
+ let output = "";
99
+ const len: number = input.length;
100
+ for(let i = 0; i < len; i += 3) {
101
+ const triplet: number = (input.charCodeAt(i) << 16)
102
+ | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
103
+ | (i + 2 < len ? input.charCodeAt(i+2) : 0);
104
+ for(let j = 0; j < 4; j++) {
105
+ if(i * 8 + j * 6 > input.length * 8) output += b64pad;
106
+ else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
107
+ }
108
+ }
109
+ return output;
110
+ }
111
+
112
+ /**
113
+ * 原始字符串转任意编码字符串
114
+ * @param input 输入字符串
115
+ * @param encoding 编码表
116
+ * @returns 编码后的字符串
117
+ */
118
+ function rstr2any(input: string, encoding: string): string {
119
+ const divisor: number = encoding.length;
120
+ let i: number, j: number, q: number, x: number, quotient: number[];
121
+
122
+ /* Convert to an array of 16-bit big-endian values, forming the dividend */
123
+ let dividend: number[] = Array(Math.ceil(input.length / 2));
124
+ for(i = 0; i < dividend.length; i++) {
125
+ dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
126
+ }
127
+
128
+ /*
129
+ * Repeatedly perform a long division. The binary array forms the dividend,
130
+ * the length of the encoding is the divisor. Once computed, the quotient
131
+ * forms the dividend for the next step. All remainders are stored for later
132
+ * use.
133
+ */
134
+ const full_length: number = Math.ceil(input.length * 8 /
135
+ (Math.log(encoding.length) / Math.log(2)));
136
+ const remainders: number[] = Array(full_length);
137
+ for(j = 0; j < full_length; j++) {
138
+ quotient = [];
139
+ x = 0;
140
+ for(i = 0; i < dividend.length; i++) {
141
+ x = (x << 16) + dividend[i];
142
+ q = Math.floor(x / divisor);
143
+ x -= q * divisor;
144
+ if(quotient.length > 0 || q > 0)
145
+ quotient[quotient.length] = q;
146
+ }
147
+ remainders[j] = x;
148
+ dividend = quotient;
149
+ }
150
+
151
+ /* Convert the remainders to the output string */
152
+ let output = "";
153
+ for(i = remainders.length - 1; i >= 0; i--)
154
+ output += encoding.charAt(remainders[i]);
155
+
156
+ return output;
157
+ }
158
+
159
+ /**
160
+ * 字符串转 UTF-8 编码
161
+ * @param input 输入字符串
162
+ * @returns UTF-8 编码字符串
163
+ */
164
+ function str2rstr_utf8(input: string): string {
165
+ let output = "";
166
+ let i = -1;
167
+ let x: number, y: number;
168
+
169
+ while(++i < input.length) {
170
+ /* Decode utf-16 surrogate pairs */
171
+ x = input.charCodeAt(i);
172
+ y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
173
+ if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) {
174
+ x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
175
+ i++;
176
+ }
177
+
178
+ /* Encode output as utf-8 */
179
+ if(x <= 0x7F)
180
+ output += String.fromCharCode(x);
181
+ else if(x <= 0x7FF)
182
+ output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
183
+ 0x80 | ( x & 0x3F));
184
+ else if(x <= 0xFFFF)
185
+ output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
186
+ 0x80 | ((x >>> 6 ) & 0x3F),
187
+ 0x80 | ( x & 0x3F));
188
+ else if(x <= 0x1FFFFF)
189
+ output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
190
+ 0x80 | ((x >>> 12) & 0x3F),
191
+ 0x80 | ((x >>> 6 ) & 0x3F),
192
+ 0x80 | ( x & 0x3F));
193
+ }
194
+ return output;
195
+ }
196
+
197
+ /**
198
+ * 字符串转 UTF-16LE 编码
199
+ * @param input 输入字符串
200
+ * @returns UTF-16LE 编码字符串
201
+ */
202
+ function str2rstr_utf16le(input: string): string {
203
+ let output = "";
204
+ for(let i = 0; i < input.length; i++)
205
+ output += String.fromCharCode( input.charCodeAt(i) & 0xFF,
206
+ (input.charCodeAt(i) >>> 8) & 0xFF);
207
+ return output;
208
+ }
209
+
210
+ /**
211
+ * 字符串转 UTF-16BE 编码
212
+ * @param input 输入字符串
213
+ * @returns UTF-16BE 编码字符串
214
+ */
215
+ function str2rstr_utf16be(input: string): string {
216
+ let output = "";
217
+ for(let i = 0; i < input.length; i++)
218
+ output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
219
+ input.charCodeAt(i) & 0xFF);
220
+ return output;
221
+ }
222
+
223
+ /**
224
+ * 原始字符串转小端字数组
225
+ * @param input 输入字符串
226
+ * @returns 小端字数组
227
+ */
228
+ function rstr2binl(input: string): number[] {
229
+ const output: number[] = Array(input.length >> 2);
230
+ for(let i = 0; i < output.length; i++)
231
+ output[i] = 0;
232
+ for(let i = 0; i < input.length * 8; i += 8)
233
+ output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
234
+ return output;
235
+ }
236
+
237
+ /**
238
+ * 小端字数组转字符串
239
+ * @param input 小端字数组
240
+ * @returns 字符串
241
+ */
242
+ function binl2rstr(input: number[]): string {
243
+ let output = "";
244
+ for(let i = 0; i < input.length * 32; i += 8)
245
+ output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
246
+ return output;
247
+ }
248
+
249
+ /**
250
+ * 计算小端字数组的 MD5
251
+ * @param x 小端字数组
252
+ * @param len 位长度
253
+ * @returns MD5 结果数组
254
+ */
255
+ function binl_md5(x: number[], len: number): number[] {
256
+ /* append padding */
257
+ x[len >> 5] |= 0x80 << ((len) % 32);
258
+ x[(((len + 64) >>> 9) << 4) + 14] = len;
259
+
260
+ let a = 1732584193;
261
+ let b = -271733879;
262
+ let c = -1732584194;
263
+ let d = 271733878;
264
+
265
+ for(let i = 0; i < x.length; i += 16) {
266
+ const olda = a;
267
+ const oldb = b;
268
+ const oldc = c;
269
+ const oldd = d;
270
+
271
+ a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
272
+ d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
273
+ c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
274
+ b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
275
+ a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
276
+ d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
277
+ c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
278
+ b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
279
+ a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
280
+ d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
281
+ c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
282
+ b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
283
+ a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
284
+ d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
285
+ c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
286
+ b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
287
+
288
+ a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
289
+ d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
290
+ c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
291
+ b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
292
+ a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
293
+ d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
294
+ c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
295
+ b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
296
+ a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
297
+ d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
298
+ c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
299
+ b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
300
+ a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
301
+ d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
302
+ c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
303
+ b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
304
+
305
+ a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
306
+ d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
307
+ c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
308
+ b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
309
+ a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
310
+ d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
311
+ c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
312
+ b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
313
+ a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
314
+ d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
315
+ c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
316
+ b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
317
+ a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
318
+ d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
319
+ c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
320
+ b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
321
+
322
+ a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
323
+ d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
324
+ c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
325
+ b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
326
+ a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
327
+ d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
328
+ c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
329
+ b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
330
+ a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
331
+ d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
332
+ c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
333
+ b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
334
+ a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
335
+ d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
336
+ c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
337
+ b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
338
+
339
+ a = safe_add(a, olda);
340
+ b = safe_add(b, oldb);
341
+ c = safe_add(c, oldc);
342
+ d = safe_add(d, oldd);
343
+ }
344
+ return [a, b, c, d];
345
+ }
346
+
347
+ /**
348
+ * 四种基本操作
349
+ */
350
+ function md5_cmn(q: number, a: number, b: number, x: number, s: number, t: number): number {
351
+ return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
352
+ }
353
+ function md5_ff(a: number, b: number, c: number, d: number, x: number, s: number, t: number): number {
354
+ return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
355
+ }
356
+ function md5_gg(a: number, b: number, c: number, d: number, x: number, s: number, t: number): number {
357
+ return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
358
+ }
359
+ function md5_hh(a: number, b: number, c: number, d: number, x: number, s: number, t: number): number {
360
+ return md5_cmn(b ^ c ^ d, a, b, x, s, t);
361
+ }
362
+ function md5_ii(a: number, b: number, c: number, d: number, x: number, s: number, t: number): number {
363
+ return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
364
+ }
365
+
366
+ /**
367
+ * 安全整数加法,防止溢出
368
+ * @param x 整数
369
+ * @param y 整数
370
+ * @returns 加法结果
371
+ */
372
+ function safe_add(x: number, y: number): number {
373
+ const lsw: number = (x & 0xFFFF) + (y & 0xFFFF);
374
+ const msw: number = (x >> 16) + (y >> 16) + (lsw >> 16);
375
+ return (msw << 16) | (lsw & 0xFFFF);
376
+ }
377
+
378
+ /**
379
+ * 左移位操作
380
+ * @param num 数字
381
+ * @param cnt 位数
382
+ * @returns 结果
383
+ */
384
+ function bit_rol(num: number, cnt: number): number {
385
+ return (num << cnt) | (num >>> (32 - cnt));
386
+ }
387
+
388
+ /**
389
+ * 计算字符串的 MD5 值
390
+ * @param str 输入字符串
391
+ * @returns MD5 十六进制字符串
392
+ */
393
+ function md5(str: string): string {
394
+ return hex_md5(str);
395
+ }
396
+
397
+ export default md5;
@@ -0,0 +1,21 @@
1
+ import { type ComponentInternalInstance, getCurrentInstance } from 'vue';
2
+
3
+ export function parent(componentName?: string, _instance: ComponentInternalInstance | null | undefined = null) {
4
+ const instance = _instance || getCurrentInstance();
5
+
6
+ let parent = instance && (instance.parent as ComponentInternalInstance | null | undefined);
7
+
8
+ while (parent) {
9
+ const name = (parent.type as any)?.name as string | undefined;
10
+ if (name === componentName) {
11
+ return parent;
12
+ }
13
+ parent = parent.parent;
14
+ }
15
+ return null;
16
+ }
17
+ export function parentData(componentName?: string, _instance: ComponentInternalInstance | null | undefined = null) {
18
+ const instance = _instance || getCurrentInstance();
19
+ const findParent = parent(componentName, instance);
20
+ return findParent ? findParent.exposed : null;
21
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * 对象转url参数
3
+ * @param data 对象参数
4
+ * @param isPrefix 是否自动加上"?",默认true
5
+ * @param arrayFormat 数组参数格式,indices/brackets/repeat/comma,默认brackets
6
+ * @returns url参数字符串
7
+ */
8
+ function queryParams(data: Record<string, any> = {}, isPrefix: boolean = true, arrayFormat: 'indices' | 'brackets' | 'repeat' | 'comma' = 'brackets'): string {
9
+ const prefix = isPrefix ? '?' : '';
10
+ const _result: string[] = [];
11
+ if (!['indices', 'brackets', 'repeat', 'comma'].includes(arrayFormat)) arrayFormat = 'brackets';
12
+ for (const key in data) {
13
+ const value = data[key];
14
+ // 去掉为空的参数
15
+ if (['', undefined, null].includes(value)) {
16
+ continue;
17
+ }
18
+ // 如果值为数组,另行处理
19
+ if (Array.isArray(value)) {
20
+ // e.g. {ids: [1, 2, 3]}
21
+ switch (arrayFormat) {
22
+ case 'indices':
23
+ // 结果: ids[0]=1&ids[1]=2&ids[2]=3
24
+ for (let i = 0; i < value.length; i++) {
25
+ _result.push(`${key}[${i}]=${value[i]}`);
26
+ }
27
+ break;
28
+ case 'brackets':
29
+ // 结果: ids[]=1&ids[]=2&ids[]=3
30
+ value.forEach((_value: any) => {
31
+ _result.push(`${key}[]=${_value}`);
32
+ });
33
+ break;
34
+ case 'repeat':
35
+ // 结果: ids=1&ids=2&ids=3
36
+ value.forEach((_value: any) => {
37
+ _result.push(`${key}=${_value}`);
38
+ });
39
+ break;
40
+ case 'comma':
41
+ // 结果: ids=1,2,3
42
+ let commaStr = '';
43
+ value.forEach((_value: any) => {
44
+ commaStr += (commaStr ? ',' : '') + _value;
45
+ });
46
+ _result.push(`${key}=${commaStr}`);
47
+ break;
48
+ default:
49
+ value.forEach((_value: any) => {
50
+ _result.push(`${key}[]=${_value}`);
51
+ });
52
+ }
53
+ } else {
54
+ _result.push(`${key}=${value}`);
55
+ }
56
+ }
57
+ return _result.length ? prefix + _result.join('&') : '';
58
+ }
59
+
60
+ export default queryParams;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 生成指定范围的随机整数
3
+ * @param min 最小值(包含)
4
+ * @param max 最大值(包含)
5
+ * @returns 随机整数
6
+ */
7
+ function random(min: number, max: number): number {
8
+ if (min >= 0 && max > 0 && max >= min) {
9
+ const gab = max - min + 1;
10
+ return Math.floor(Math.random() * gab + min);
11
+ } else {
12
+ return 0;
13
+ }
14
+ }
15
+
16
+ export default random;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 打乱数组顺序
3
+ * @param array 需要打乱的数组
4
+ * @returns 打乱后的新数组
5
+ */
6
+ function randomArray<T>(array: T[] = []): T[] {
7
+ // 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.5大于或者小于0
8
+ return array.sort(() => Math.random() - 0.5);
9
+ }
10
+
11
+ export default randomArray;
@@ -0,0 +1,118 @@
1
+ /**
2
+ * 路由跳转方法,该方法相对于直接使用uni.xxx的好处是使用更加简单快捷
3
+ * 并且带有路由拦截功能
4
+ */
5
+
6
+ interface RouterConfig {
7
+ type?: string;
8
+ url?: string;
9
+ delta?: number;
10
+ params?: Record<string, any>;
11
+ animationType?: string;
12
+ animationDuration?: number;
13
+ intercept?: boolean;
14
+ }
15
+
16
+ declare const uni: any; // 声明uni对象,避免ts报错
17
+
18
+ class Router {
19
+ config: RouterConfig;
20
+ // route: (options?: string | RouterConfig, params?: Record<string, any>) => Promise<void>;
21
+
22
+ constructor() {
23
+ // 原始属性定义
24
+ this.config = {
25
+ type: 'navigateTo',
26
+ url: '',
27
+ delta: 1, // navigateBack页面后退时,回退的层数
28
+ params: {}, // 传递的参数
29
+ animationType: 'pop-in', // 窗口动画,只在APP有效
30
+ animationDuration: 300, // 窗口动画持续时间,单位毫秒,只在APP有效
31
+ intercept: false // 是否需要拦截
32
+ };
33
+ // 因为route方法是需要对外赋值给另外的对象使用,同时route内部有使用this,会导致route失去上下文
34
+ // 这里在构造函数中进行this绑定
35
+ this.route = this.route.bind(this);
36
+ }
37
+
38
+ // 判断url前面是否有"/",如果没有则加上,否则无法跳转
39
+ addRootPath(url: string): string {
40
+ return url[0] === '/' ? url : `/${url}`;
41
+ }
42
+
43
+ // 整合路由参数
44
+ mixinParam(url: string, params: Record<string, any>): string {
45
+ url = url && this.addRootPath(url);
46
+ // 使用正则匹配,主要依据是判断是否有"/","?","="等,如“/page/index/index?name=mary"
47
+ // 如果有url中有get参数,转换后无需带上"?"
48
+ let query = '';
49
+ if (/.*\/.*\?.*=.*/.test(url)) {
50
+ // object对象转为get类型的参数
51
+ query = uni.$u.queryParams(params, false);
52
+ // 因为已有get参数,所以后面拼接的参数需要带上"&"隔开
53
+ return url + '&' + query;
54
+ } else {
55
+ // 直接拼接参数,因为此处url中没有后面的query参数,也就没有"?/&"之类的符号
56
+ query = uni.$u.queryParams(params);
57
+ return url + query;
58
+ }
59
+ }
60
+
61
+ /**
62
+ * 路由跳转主方法
63
+ * @param options 跳转配置或url字符串
64
+ * @param params 跳转参数
65
+ */
66
+ async route(options: string | RouterConfig = {}, params: Record<string, any> = {}): Promise<void> {
67
+ let mergeConfig: RouterConfig = {};
68
+ if (typeof options === 'string') {
69
+ // 如果options为字符串,则为route(url, params)的形式
70
+ mergeConfig.url = this.mixinParam(options, params);
71
+ mergeConfig.type = 'navigateTo';
72
+ } else {
73
+ mergeConfig = uni.$u.deepMerge(this.config, options);
74
+ // 否则正常使用mergeConfig中的url和params进行拼接
75
+ mergeConfig.url = this.mixinParam(options.url || '', options.params || {});
76
+ }
77
+ if (params.intercept) {
78
+ this.config.intercept = params.intercept;
79
+ }
80
+ // params参数也带给拦截器
81
+ mergeConfig.params = params;
82
+ // 合并内外部参数
83
+ mergeConfig = uni.$u.deepMerge(this.config, mergeConfig);
84
+ // 判断用户是否定义了拦截器
85
+ if (uni.$u.routeIntercept && typeof uni.$u.routeIntercept === 'function') {
86
+ // 定一个promise,根据用户执行resolve(true)或者resolve(false)来决定是否进行路由跳转
87
+ const isNext = await new Promise<boolean>(resolve => {
88
+ uni.$u.routeIntercept(mergeConfig, resolve);
89
+ });
90
+ // 如果isNext为true,则执行路由跳转
91
+ isNext && this.openPage(mergeConfig);
92
+ } else {
93
+ this.openPage(mergeConfig);
94
+ }
95
+ }
96
+
97
+ // 执行路由跳转
98
+ openPage(config: RouterConfig): void {
99
+ const { url = '', type = '', delta = 1, animationDuration = 300 } = config;
100
+ if (type == 'navigateTo' || type == 'to') {
101
+ uni.navigateTo({ url, animationDuration });
102
+ }
103
+ if (type == 'redirectTo' || type == 'redirect') {
104
+ uni.redirectTo({ url });
105
+ }
106
+ if (type == 'switchTab' || type == 'tab') {
107
+ uni.switchTab({ url });
108
+ }
109
+ if (type == 'reLaunch' || type == 'launch') {
110
+ uni.reLaunch({ url });
111
+ }
112
+ if (type == 'navigateBack' || type == 'back') {
113
+ uni.navigateBack({ delta });
114
+ }
115
+ }
116
+ }
117
+
118
+ export default new Router().route;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 获取当前操作系统平台
3
+ * @returns 平台字符串,如 'ios'、'android'、'windows' 等
4
+ */
5
+ export function os(): string {
6
+ return uni.getSystemInfoSync().platform;
7
+ }
8
+
9
+ /**
10
+ * 获取系统信息
11
+ * @returns uniapp 系统信息对象
12
+ */
13
+ export function sys(): UniApp.GetSystemInfoResult {
14
+ return uni.getSystemInfoSync();
15
+ }