mali-applet-ui 1.1.32 → 1.1.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.
@@ -0,0 +1,126 @@
1
+
2
+ /* eslint-disable */
3
+ const Base64 = {
4
+
5
+ // private property
6
+ _keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
7
+
8
+ // public method for encoding
9
+ encode (input) {
10
+ let output = ''
11
+ let chr1, chr2, chr3, enc1, enc2, enc3, enc4
12
+ let i = 0
13
+
14
+ input = Base64._utf8_encode(input)
15
+
16
+ while (i < input.length) {
17
+ chr1 = input.charCodeAt(i++)
18
+ chr2 = input.charCodeAt(i++)
19
+ chr3 = input.charCodeAt(i++)
20
+
21
+ enc1 = chr1 >> 2
22
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4)
23
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6)
24
+ enc4 = chr3 & 63
25
+
26
+ if (isNaN(chr2)) {
27
+ enc3 = enc4 = 64
28
+ } else if (isNaN(chr3)) {
29
+ enc4 = 64
30
+ }
31
+
32
+ output = output +
33
+ this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
34
+ this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4)
35
+ }
36
+
37
+ return output
38
+ },
39
+
40
+ // public method for decoding
41
+ decode (input) {
42
+ let output = ''
43
+ let chr1, chr2, chr3
44
+ let enc1, enc2, enc3, enc4
45
+ let i = 0
46
+
47
+ input = input.replace(/[^A-Za-z0-9+/=]/g, '')
48
+
49
+ while (i < input.length) {
50
+ enc1 = this._keyStr.indexOf(input.charAt(i++))
51
+ enc2 = this._keyStr.indexOf(input.charAt(i++))
52
+ enc3 = this._keyStr.indexOf(input.charAt(i++))
53
+ enc4 = this._keyStr.indexOf(input.charAt(i++))
54
+
55
+ chr1 = (enc1 << 2) | (enc2 >> 4)
56
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2)
57
+ chr3 = ((enc3 & 3) << 6) | enc4
58
+
59
+ output = output + String.fromCharCode(chr1)
60
+
61
+ if (enc3 != 64) {
62
+ output = output + String.fromCharCode(chr2)
63
+ }
64
+ if (enc4 != 64) {
65
+ output = output + String.fromCharCode(chr3)
66
+ }
67
+ }
68
+
69
+ output = Base64._utf8_decode(output)
70
+
71
+ return output
72
+ },
73
+
74
+ // private method for UTF-8 encoding
75
+ _utf8_encode (string) {
76
+ string = string.replace(/\r\n/g, '\n')
77
+ let utftext = ''
78
+
79
+ for (let n = 0; n < string.length; n++) {
80
+ const c = string.charCodeAt(n)
81
+
82
+ if (c < 128) {
83
+ utftext += String.fromCharCode(c)
84
+ } else if ((c > 127) && (c < 2048)) {
85
+ utftext += String.fromCharCode((c >> 6) | 192)
86
+ utftext += String.fromCharCode((c & 63) | 128)
87
+ } else {
88
+ utftext += String.fromCharCode((c >> 12) | 224)
89
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128)
90
+ utftext += String.fromCharCode((c & 63) | 128)
91
+ }
92
+ }
93
+
94
+ return utftext
95
+ },
96
+
97
+ // private method for UTF-8 decoding
98
+ _utf8_decode (utftext) {
99
+ let c1, c2, c3
100
+ let string = ''
101
+ let i = 0
102
+ let c = c1 = c2 = 0
103
+
104
+ while (i < utftext.length) {
105
+ c = utftext.charCodeAt(i)
106
+
107
+ if (c < 128) {
108
+ string += String.fromCharCode(c)
109
+ i++
110
+ } else if ((c > 191) && (c < 224)) {
111
+ c2 = utftext.charCodeAt(i + 1)
112
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63))
113
+ i += 2
114
+ } else {
115
+ c2 = utftext.charCodeAt(i + 1)
116
+ c3 = utftext.charCodeAt(i + 2)
117
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63))
118
+ i += 3
119
+ }
120
+ }
121
+
122
+ return string
123
+ }
124
+ }
125
+
126
+ export default Base64
package/index.js CHANGED
@@ -6,6 +6,8 @@ import MaliStorage from './storage'
6
6
  import MaliI18n from './i18n/i18n'
7
7
  import MaliUtils from './utils'
8
8
 
9
+ import Base64 from './base64/base64'
10
+
9
11
  export function install (Vue) {
10
12
  Vue.prototype.$t = MaliI18n.t
11
13
  }
@@ -18,7 +20,8 @@ const MaliUI = {
18
20
  MaliModal,
19
21
  MaliLoading,
20
22
  MaliStorage,
21
- MaliI18n
23
+ MaliI18n,
24
+ Base64
22
25
  }
23
26
 
24
27
  export {
@@ -27,7 +30,8 @@ export {
27
30
  MaliModal,
28
31
  MaliLoading,
29
32
  MaliStorage,
30
- MaliI18n
33
+ MaliI18n,
34
+ Base64
31
35
  }
32
36
 
33
37
  export default MaliUI
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
4
4
  "description": "vue2 码里云小程序组件库",
5
5
  "files": [
6
6
  "lib",
@@ -12,6 +12,7 @@
12
12
  "modal",
13
13
  "store",
14
14
  "storage",
15
+ "base64",
15
16
  "index.js",
16
17
  "theme.scss"
17
18
  ],
@@ -0,0 +1,6 @@
1
+ export interface Base64Core {
2
+ encode(str: string): string
3
+ decode(str: string): string
4
+ }
5
+
6
+ export const Base64: Base64Core
package/types/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { MaliModal } from './modal'
6
6
  import { MaliToast } from './toast'
7
7
  import { MaliLoading } from './loading'
8
8
  import { MaliI18n, MlI18nCore } from './i18n'
9
+ import { Base64, Base64Core } from './base64'
9
10
 
10
11
  export const MaliUI: {
11
12
  version: string
@@ -17,6 +18,7 @@ export const MaliUI: {
17
18
  MaliLoading: typeof MaliLoading
18
19
  MaliI18n: MlI18nCore
19
20
  MaliStorage: MlStorageCore
21
+ Base64: Base64Core
20
22
  }
21
23
 
22
24
  export {
@@ -26,6 +28,7 @@ export {
26
28
  MaliLoading,
27
29
  MaliI18n,
28
30
  MaliStorage,
31
+ Base64
29
32
  }
30
33
 
31
34
  export default MaliUI