ztxkutils 2.10.17 → 2.10.19
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/dist/authority-e6bde99f.js +423 -0
- package/dist/authority.js +1 -1
- package/dist/fileOperation.js +1 -1
- package/dist/hooks.js +1 -1
- package/dist/index.js +2 -2
- package/dist/print.d.ts +13 -0
- package/dist/print.js +98 -31
- package/dist/request-8e0e6316.js +2774 -0
- package/dist/request.js +2 -2
- package/dist/stompClient.js +1 -1
- package/dist/useFileIdToBase64.js +1 -1
- package/dist/useHistory.js +1 -1
- package/package.json +1 -1
@@ -0,0 +1,423 @@
|
|
1
|
+
/**
|
2
|
+
* base64.ts
|
3
|
+
*
|
4
|
+
* Licensed under the BSD 3-Clause License.
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
6
|
+
*
|
7
|
+
* References:
|
8
|
+
* http://en.wikipedia.org/wiki/Base64
|
9
|
+
*
|
10
|
+
* @author Dan Kogai (https://github.com/dankogai)
|
11
|
+
*/
|
12
|
+
const _hasatob = typeof atob === 'function';
|
13
|
+
const _hasbtoa = typeof btoa === 'function';
|
14
|
+
const _hasBuffer = typeof Buffer === 'function';
|
15
|
+
const _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
|
16
|
+
const _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
|
17
|
+
const b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
18
|
+
const b64chs = [...b64ch];
|
19
|
+
const b64tab = ((a) => {
|
20
|
+
let tab = {};
|
21
|
+
a.forEach((c, i) => tab[c] = i);
|
22
|
+
return tab;
|
23
|
+
})(b64chs);
|
24
|
+
const b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
25
|
+
const _fromCC = String.fromCharCode.bind(String);
|
26
|
+
const _U8Afrom = typeof Uint8Array.from === 'function'
|
27
|
+
? Uint8Array.from.bind(Uint8Array)
|
28
|
+
: (it, fn = (x) => x) => new Uint8Array(Array.prototype.slice.call(it, 0).map(fn));
|
29
|
+
const _mkUriSafe = (src) => src
|
30
|
+
.replace(/[+\/]/g, (m0) => m0 == '+' ? '-' : '_')
|
31
|
+
.replace(/=+$/m, '');
|
32
|
+
const _tidyB64 = (s) => s.replace(/[^A-Za-z0-9\+\/]/g, '');
|
33
|
+
/**
|
34
|
+
* polyfill version of `btoa`
|
35
|
+
*/
|
36
|
+
const btoaPolyfill = (bin) => {
|
37
|
+
// console.log('polyfilled');
|
38
|
+
let u32, c0, c1, c2, asc = '';
|
39
|
+
const pad = bin.length % 3;
|
40
|
+
for (let i = 0; i < bin.length;) {
|
41
|
+
if ((c0 = bin.charCodeAt(i++)) > 255 ||
|
42
|
+
(c1 = bin.charCodeAt(i++)) > 255 ||
|
43
|
+
(c2 = bin.charCodeAt(i++)) > 255)
|
44
|
+
throw new TypeError('invalid character found');
|
45
|
+
u32 = (c0 << 16) | (c1 << 8) | c2;
|
46
|
+
asc += b64chs[u32 >> 18 & 63]
|
47
|
+
+ b64chs[u32 >> 12 & 63]
|
48
|
+
+ b64chs[u32 >> 6 & 63]
|
49
|
+
+ b64chs[u32 & 63];
|
50
|
+
}
|
51
|
+
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
|
52
|
+
};
|
53
|
+
/**
|
54
|
+
* does what `window.btoa` of web browsers do.
|
55
|
+
* @param {String} bin binary string
|
56
|
+
* @returns {string} Base64-encoded string
|
57
|
+
*/
|
58
|
+
const _btoa = _hasbtoa ? (bin) => btoa(bin)
|
59
|
+
: _hasBuffer ? (bin) => Buffer.from(bin, 'binary').toString('base64')
|
60
|
+
: btoaPolyfill;
|
61
|
+
const _fromUint8Array = _hasBuffer
|
62
|
+
? (u8a) => Buffer.from(u8a).toString('base64')
|
63
|
+
: (u8a) => {
|
64
|
+
// cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
|
65
|
+
const maxargs = 0x1000;
|
66
|
+
let strs = [];
|
67
|
+
for (let i = 0, l = u8a.length; i < l; i += maxargs) {
|
68
|
+
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
|
69
|
+
}
|
70
|
+
return _btoa(strs.join(''));
|
71
|
+
};
|
72
|
+
// This trick is found broken https://github.com/dankogai/js-base64/issues/130
|
73
|
+
// const utob = (src: string) => unescape(encodeURIComponent(src));
|
74
|
+
// reverting good old fationed regexp
|
75
|
+
const cb_utob = (c) => {
|
76
|
+
if (c.length < 2) {
|
77
|
+
var cc = c.charCodeAt(0);
|
78
|
+
return cc < 0x80 ? c
|
79
|
+
: cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6))
|
80
|
+
+ _fromCC(0x80 | (cc & 0x3f)))
|
81
|
+
: (_fromCC(0xe0 | ((cc >>> 12) & 0x0f))
|
82
|
+
+ _fromCC(0x80 | ((cc >>> 6) & 0x3f))
|
83
|
+
+ _fromCC(0x80 | (cc & 0x3f)));
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
var cc = 0x10000
|
87
|
+
+ (c.charCodeAt(0) - 0xD800) * 0x400
|
88
|
+
+ (c.charCodeAt(1) - 0xDC00);
|
89
|
+
return (_fromCC(0xf0 | ((cc >>> 18) & 0x07))
|
90
|
+
+ _fromCC(0x80 | ((cc >>> 12) & 0x3f))
|
91
|
+
+ _fromCC(0x80 | ((cc >>> 6) & 0x3f))
|
92
|
+
+ _fromCC(0x80 | (cc & 0x3f)));
|
93
|
+
}
|
94
|
+
};
|
95
|
+
const re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
96
|
+
/**
|
97
|
+
* @deprecated should have been internal use only.
|
98
|
+
* @param {string} src UTF-8 string
|
99
|
+
* @returns {string} UTF-16 string
|
100
|
+
*/
|
101
|
+
const utob = (u) => u.replace(re_utob, cb_utob);
|
102
|
+
//
|
103
|
+
const _encode = _hasBuffer
|
104
|
+
? (s) => Buffer.from(s, 'utf8').toString('base64')
|
105
|
+
: _TE
|
106
|
+
? (s) => _fromUint8Array(_TE.encode(s))
|
107
|
+
: (s) => _btoa(utob(s));
|
108
|
+
/**
|
109
|
+
* converts a UTF-8-encoded string to a Base64 string.
|
110
|
+
* @param {boolean} [urlsafe] if `true` make the result URL-safe
|
111
|
+
* @returns {string} Base64 string
|
112
|
+
*/
|
113
|
+
const encode = (src, urlsafe = false) => urlsafe
|
114
|
+
? _mkUriSafe(_encode(src))
|
115
|
+
: _encode(src);
|
116
|
+
// This trick is found broken https://github.com/dankogai/js-base64/issues/130
|
117
|
+
// const btou = (src: string) => decodeURIComponent(escape(src));
|
118
|
+
// reverting good old fationed regexp
|
119
|
+
const re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
120
|
+
const cb_btou = (cccc) => {
|
121
|
+
switch (cccc.length) {
|
122
|
+
case 4:
|
123
|
+
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
|
124
|
+
| ((0x3f & cccc.charCodeAt(1)) << 12)
|
125
|
+
| ((0x3f & cccc.charCodeAt(2)) << 6)
|
126
|
+
| (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000;
|
127
|
+
return (_fromCC((offset >>> 10) + 0xD800)
|
128
|
+
+ _fromCC((offset & 0x3FF) + 0xDC00));
|
129
|
+
case 3:
|
130
|
+
return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12)
|
131
|
+
| ((0x3f & cccc.charCodeAt(1)) << 6)
|
132
|
+
| (0x3f & cccc.charCodeAt(2)));
|
133
|
+
default:
|
134
|
+
return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6)
|
135
|
+
| (0x3f & cccc.charCodeAt(1)));
|
136
|
+
}
|
137
|
+
};
|
138
|
+
/**
|
139
|
+
* @deprecated should have been internal use only.
|
140
|
+
* @param {string} src UTF-16 string
|
141
|
+
* @returns {string} UTF-8 string
|
142
|
+
*/
|
143
|
+
const btou = (b) => b.replace(re_btou, cb_btou);
|
144
|
+
/**
|
145
|
+
* polyfill version of `atob`
|
146
|
+
*/
|
147
|
+
const atobPolyfill = (asc) => {
|
148
|
+
// console.log('polyfilled');
|
149
|
+
asc = asc.replace(/\s+/g, '');
|
150
|
+
if (!b64re.test(asc))
|
151
|
+
throw new TypeError('malformed base64.');
|
152
|
+
asc += '=='.slice(2 - (asc.length & 3));
|
153
|
+
let u24, bin = '', r1, r2;
|
154
|
+
for (let i = 0; i < asc.length;) {
|
155
|
+
u24 = b64tab[asc.charAt(i++)] << 18
|
156
|
+
| b64tab[asc.charAt(i++)] << 12
|
157
|
+
| (r1 = b64tab[asc.charAt(i++)]) << 6
|
158
|
+
| (r2 = b64tab[asc.charAt(i++)]);
|
159
|
+
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255)
|
160
|
+
: r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255)
|
161
|
+
: _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
|
162
|
+
}
|
163
|
+
return bin;
|
164
|
+
};
|
165
|
+
/**
|
166
|
+
* does what `window.atob` of web browsers do.
|
167
|
+
* @param {String} asc Base64-encoded string
|
168
|
+
* @returns {string} binary string
|
169
|
+
*/
|
170
|
+
const _atob = _hasatob ? (asc) => atob(_tidyB64(asc))
|
171
|
+
: _hasBuffer ? (asc) => Buffer.from(asc, 'base64').toString('binary')
|
172
|
+
: atobPolyfill;
|
173
|
+
//
|
174
|
+
const _toUint8Array = _hasBuffer
|
175
|
+
? (a) => _U8Afrom(Buffer.from(a, 'base64'))
|
176
|
+
: (a) => _U8Afrom(_atob(a), c => c.charCodeAt(0));
|
177
|
+
//
|
178
|
+
const _decode = _hasBuffer
|
179
|
+
? (a) => Buffer.from(a, 'base64').toString('utf8')
|
180
|
+
: _TD
|
181
|
+
? (a) => _TD.decode(_toUint8Array(a))
|
182
|
+
: (a) => btou(_atob(a));
|
183
|
+
const _unURI = (a) => _tidyB64(a.replace(/[-_]/g, (m0) => m0 == '-' ? '+' : '/'));
|
184
|
+
/**
|
185
|
+
* converts a Base64 string to a UTF-8 string.
|
186
|
+
* @param {String} src Base64 string. Both normal and URL-safe are supported
|
187
|
+
* @returns {string} UTF-8 string
|
188
|
+
*/
|
189
|
+
const decode = (src) => _decode(_unURI(src));
|
190
|
+
|
191
|
+
function e(e){this.message=e;}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,a=0,i=0,c="";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw "Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t})))}(t)}catch(e){return r(t)}}function n(e){this.message=e;}function o(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";
|
192
|
+
|
193
|
+
/**
|
194
|
+
* @description 权限相关操作
|
195
|
+
*/
|
196
|
+
// 获取token
|
197
|
+
var getToken = function () {
|
198
|
+
try {
|
199
|
+
if (window.localStorage.getItem('system-token')) {
|
200
|
+
return window.localStorage.getItem('system-token');
|
201
|
+
}
|
202
|
+
else {
|
203
|
+
return false;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
catch (err) {
|
207
|
+
return false;
|
208
|
+
}
|
209
|
+
};
|
210
|
+
// 获取refreshToken
|
211
|
+
var getRefreshToken = function () {
|
212
|
+
try {
|
213
|
+
if (window.localStorage.getItem('system-refresh-token')) {
|
214
|
+
return window.localStorage.getItem('system-refresh-token');
|
215
|
+
}
|
216
|
+
else {
|
217
|
+
return false;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
catch (err) {
|
221
|
+
return false;
|
222
|
+
}
|
223
|
+
};
|
224
|
+
// 获取是否第三方登录
|
225
|
+
var getOAuth2 = function () {
|
226
|
+
try {
|
227
|
+
if (window.localStorage.getItem('system-oauth2')) {
|
228
|
+
return window.localStorage.getItem('system-oauth2');
|
229
|
+
}
|
230
|
+
else {
|
231
|
+
return false;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
catch (err) {
|
235
|
+
return false;
|
236
|
+
}
|
237
|
+
};
|
238
|
+
// 设置token
|
239
|
+
var setToken = function (token) {
|
240
|
+
try {
|
241
|
+
window.localStorage.setItem('system-token', token);
|
242
|
+
}
|
243
|
+
catch (err) {
|
244
|
+
return false;
|
245
|
+
}
|
246
|
+
};
|
247
|
+
var removeToken = function () {
|
248
|
+
try {
|
249
|
+
window.localStorage.removeItem('system-token');
|
250
|
+
}
|
251
|
+
catch (err) {
|
252
|
+
return false;
|
253
|
+
}
|
254
|
+
};
|
255
|
+
// 设置refreshToken
|
256
|
+
var setRefreshToken = function (token) {
|
257
|
+
try {
|
258
|
+
window.localStorage.setItem('system-refresh-token', token);
|
259
|
+
}
|
260
|
+
catch (err) {
|
261
|
+
return false;
|
262
|
+
}
|
263
|
+
};
|
264
|
+
var removeRefreshToken = function () {
|
265
|
+
try {
|
266
|
+
window.localStorage.removeItem('system-refresh-token');
|
267
|
+
}
|
268
|
+
catch (err) {
|
269
|
+
return false;
|
270
|
+
}
|
271
|
+
};
|
272
|
+
// 设置第三方登录
|
273
|
+
var setOAuth2 = function () {
|
274
|
+
try {
|
275
|
+
window.localStorage.setItem('system-oauth2', '1');
|
276
|
+
}
|
277
|
+
catch (err) {
|
278
|
+
return false;
|
279
|
+
}
|
280
|
+
};
|
281
|
+
var removeOAuth2 = function () {
|
282
|
+
try {
|
283
|
+
window.localStorage.removeItem('system-oauth2');
|
284
|
+
}
|
285
|
+
catch (err) {
|
286
|
+
return false;
|
287
|
+
}
|
288
|
+
};
|
289
|
+
// 对用户名密码进行加密/解密处理
|
290
|
+
var aesEncrypt = function (str) {
|
291
|
+
return encode(str);
|
292
|
+
};
|
293
|
+
var aesDecrypt = function (str) {
|
294
|
+
if (str) {
|
295
|
+
return decode(str);
|
296
|
+
}
|
297
|
+
else {
|
298
|
+
return str;
|
299
|
+
}
|
300
|
+
};
|
301
|
+
/**按钮权限级别 */
|
302
|
+
var BTN_AUTHS = {
|
303
|
+
add: 'add',
|
304
|
+
update: 'update',
|
305
|
+
check: 'check',
|
306
|
+
detail: 'detail',
|
307
|
+
unfreeze: 'unfreeze',
|
308
|
+
frozen: 'frozen',
|
309
|
+
cancelLation: 'cancelLation',
|
310
|
+
cancelSubmit: 'cancelSubmit',
|
311
|
+
submitApprove: 'submitApprove', // 提交审核
|
312
|
+
};
|
313
|
+
/**判断是否有当前按钮的权限 */
|
314
|
+
var isBtnAuth = function (userBtns, code) {
|
315
|
+
if (typeof code === 'boolean') {
|
316
|
+
return code;
|
317
|
+
}
|
318
|
+
if (!Array.isArray(userBtns)) {
|
319
|
+
return false;
|
320
|
+
}
|
321
|
+
return userBtns.some(function (userBtn) { return (userBtn === null || userBtn === void 0 ? void 0 : userBtn.code) === code; });
|
322
|
+
};
|
323
|
+
/**设置最后一次访问的路由 */
|
324
|
+
var setLastUrlPath = function (pathname) {
|
325
|
+
try {
|
326
|
+
window.localStorage.setItem('last-url-path', pathname);
|
327
|
+
}
|
328
|
+
catch (err) {
|
329
|
+
return false;
|
330
|
+
}
|
331
|
+
};
|
332
|
+
var getLastUrlPath = function () {
|
333
|
+
try {
|
334
|
+
if (window.localStorage.getItem('last-url-path')) {
|
335
|
+
return window.localStorage.getItem('last-url-path');
|
336
|
+
}
|
337
|
+
else {
|
338
|
+
return false;
|
339
|
+
}
|
340
|
+
}
|
341
|
+
catch (err) {
|
342
|
+
return false;
|
343
|
+
}
|
344
|
+
};
|
345
|
+
/**返回是否在乾坤下启动 */
|
346
|
+
var isQiankun = function () { return window.__POWERED_BY_QIANKUN__; };
|
347
|
+
/** jwt解析 */
|
348
|
+
var jwtDecode = function (str) {
|
349
|
+
try {
|
350
|
+
return o(str);
|
351
|
+
}
|
352
|
+
catch (err) {
|
353
|
+
//
|
354
|
+
}
|
355
|
+
};
|
356
|
+
/**
|
357
|
+
* 设置菜单id
|
358
|
+
* menuId: 菜单id
|
359
|
+
* menuPath:菜单对应的路由
|
360
|
+
*/
|
361
|
+
var setMenuId = function (menuId, menuPath) {
|
362
|
+
try {
|
363
|
+
window.sessionStorage.setItem('CURRENT_MENU_ID', menuId);
|
364
|
+
window.sessionStorage.setItem('CURRENT_MENU_PATH', menuPath);
|
365
|
+
}
|
366
|
+
catch (err) {
|
367
|
+
//
|
368
|
+
}
|
369
|
+
};
|
370
|
+
var getMenuIdInfo = function () {
|
371
|
+
var _a, _b, _c;
|
372
|
+
var obj = {};
|
373
|
+
try {
|
374
|
+
var pathname = window.location.pathname;
|
375
|
+
obj.CURRENT_MENU_ID = window.sessionStorage.getItem('CURRENT_MENU_ID');
|
376
|
+
obj.CURRENT_MENU_PATH = window.sessionStorage.getItem('CURRENT_MENU_PATH');
|
377
|
+
if (pathname === obj.CURRENT_MENU_PATH) {
|
378
|
+
obj.IS_CURRENT_MENU = true;
|
379
|
+
}
|
380
|
+
else {
|
381
|
+
var firstIndex = (_b = (_a = obj.CURRENT_MENU_PATH) === null || _a === void 0 ? void 0 : _a.indexOf) === null || _b === void 0 ? void 0 : _b.call(_a, ':');
|
382
|
+
var resultPathname = obj.CURRENT_MENU_PATH;
|
383
|
+
if (firstIndex !== -1) {
|
384
|
+
resultPathname = (_c = obj.CURRENT_MENU_PATH) === null || _c === void 0 ? void 0 : _c.substr(0, firstIndex);
|
385
|
+
}
|
386
|
+
if (pathname.indexOf(resultPathname) !== -1) {
|
387
|
+
obj.IS_CURRENT_MENU = true;
|
388
|
+
}
|
389
|
+
else {
|
390
|
+
obj.IS_CURRENT_MENU = false;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
}
|
394
|
+
catch (err) {
|
395
|
+
//
|
396
|
+
}
|
397
|
+
return obj;
|
398
|
+
};
|
399
|
+
|
400
|
+
var authority = /*#__PURE__*/Object.freeze({
|
401
|
+
__proto__: null,
|
402
|
+
getToken: getToken,
|
403
|
+
getRefreshToken: getRefreshToken,
|
404
|
+
getOAuth2: getOAuth2,
|
405
|
+
setToken: setToken,
|
406
|
+
removeToken: removeToken,
|
407
|
+
setRefreshToken: setRefreshToken,
|
408
|
+
removeRefreshToken: removeRefreshToken,
|
409
|
+
setOAuth2: setOAuth2,
|
410
|
+
removeOAuth2: removeOAuth2,
|
411
|
+
aesEncrypt: aesEncrypt,
|
412
|
+
aesDecrypt: aesDecrypt,
|
413
|
+
BTN_AUTHS: BTN_AUTHS,
|
414
|
+
isBtnAuth: isBtnAuth,
|
415
|
+
setLastUrlPath: setLastUrlPath,
|
416
|
+
getLastUrlPath: getLastUrlPath,
|
417
|
+
isQiankun: isQiankun,
|
418
|
+
jwtDecode: jwtDecode,
|
419
|
+
setMenuId: setMenuId,
|
420
|
+
getMenuIdInfo: getMenuIdInfo
|
421
|
+
});
|
422
|
+
|
423
|
+
export { BTN_AUTHS as B, getRefreshToken as a, setRefreshToken as b, authority as c, getOAuth2 as d, removeRefreshToken as e, setOAuth2 as f, getToken as g, removeOAuth2 as h, isQiankun as i, aesEncrypt as j, aesDecrypt as k, isBtnAuth as l, setLastUrlPath as m, getLastUrlPath as n, jwtDecode as o, setMenuId as p, getMenuIdInfo as q, removeToken as r, setToken as s };
|
package/dist/authority.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { B as BTN_AUTHS,
|
1
|
+
export { B as BTN_AUTHS, k as aesDecrypt, j as aesEncrypt, n as getLastUrlPath, q as getMenuIdInfo, d as getOAuth2, a as getRefreshToken, g as getToken, l as isBtnAuth, i as isQiankun, o as jwtDecode, h as removeOAuth2, e as removeRefreshToken, r as removeToken, m as setLastUrlPath, p as setMenuId, f as setOAuth2, b as setRefreshToken, s as setToken } from './authority-e6bde99f.js';
|
package/dist/fileOperation.js
CHANGED
package/dist/hooks.js
CHANGED
@@ -2,7 +2,7 @@ import { _ as __assign, c as __awaiter, d as __generator } from './tslib.es6-f94
|
|
2
2
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
3
3
|
export { default as useFileIdToBase64 } from './useFileIdToBase64.js';
|
4
4
|
import './fileOperation.js';
|
5
|
-
import './authority-
|
5
|
+
import './authority-e6bde99f.js';
|
6
6
|
import './tools-5541a681.js';
|
7
7
|
import 'dayjs';
|
8
8
|
import 'number-precision';
|
package/dist/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
export { c as authority } from './authority-
|
1
|
+
export { c as authority } from './authority-e6bde99f.js';
|
2
2
|
export { d as dataModel } from './dataModel-1fbaff40.js';
|
3
3
|
export { t as tools } from './tools-5541a681.js';
|
4
4
|
export { v as validate } from './validate-6e735536.js';
|
5
|
-
export { r as request } from './request-
|
5
|
+
export { r as request } from './request-8e0e6316.js';
|
6
6
|
export { r as reqUrl } from './reqUrl-787dd9e5.js';
|
7
7
|
import './tslib.es6-f9459658.js';
|
8
8
|
import 'dayjs';
|
package/dist/print.d.ts
CHANGED
@@ -30,6 +30,19 @@ export declare function htmlToPdf({ pageClassName, dom, pdfName, isShowPage, noW
|
|
30
30
|
pdfOptions?: any;
|
31
31
|
imgPositionX?: number;
|
32
32
|
}): Promise<jsPDF>;
|
33
|
+
export declare function htmlToPdfUseCanvas({ pageClassName, dom, pdfName, isShowPage, noWater, pdfOptions, imgPositionX, isDownload, }: {
|
34
|
+
pageClassName?: string;
|
35
|
+
dom: HTMLElement;
|
36
|
+
pdfName: string;
|
37
|
+
isShowPage?: boolean;
|
38
|
+
noWater?: boolean;
|
39
|
+
pdfOptions?: any;
|
40
|
+
imgPositionX?: number;
|
41
|
+
isDownload?: boolean;
|
42
|
+
}): Promise<{
|
43
|
+
pdfs: any;
|
44
|
+
pdfBase64: any;
|
45
|
+
}>;
|
33
46
|
export interface IPdfOption {
|
34
47
|
/** 是否压缩 */
|
35
48
|
compress?: boolean;
|
package/dist/print.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { a as __spreadArray, _ as __assign, c as __awaiter, d as __generator } from './tslib.es6-f9459658.js';
|
2
2
|
import { jsPDF } from 'jspdf';
|
3
3
|
import html2canvas from 'html2canvas';
|
4
|
-
import { g as getToken, j as jwtDecode } from './authority-312048ab.js';
|
5
4
|
|
6
5
|
/**
|
7
6
|
* 添加水印
|
@@ -65,17 +64,17 @@ function printCurrentDom(_a) {
|
|
65
64
|
* @returns canvas png
|
66
65
|
*/
|
67
66
|
function createWaterHandle(obj) {
|
68
|
-
|
69
|
-
|
70
|
-
if (token) {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
67
|
+
// const token = getToken();
|
68
|
+
// let defaultWaterText = '内部资料,严禁外泄!';
|
69
|
+
// if (token) {
|
70
|
+
// try {
|
71
|
+
// const tokenObj: any = jwtDecode(token);
|
72
|
+
// defaultWaterText = `浙商中拓 ${tokenObj?.real_name || ''}`;
|
73
|
+
// } catch (err) {
|
74
|
+
// console.log(err);
|
75
|
+
// }
|
76
|
+
// }
|
77
|
+
var defaultWaterText = '浙商中拓';
|
79
78
|
var _a = obj || {}, waterText = _a.waterText, opacity = _a.opacity, fontSize = _a.fontSize, cavansWidth = _a.cavansWidth, cavansHeight = _a.cavansHeight;
|
80
79
|
var canvas = document.createElement('canvas');
|
81
80
|
canvas.width = cavansWidth || 240;
|
@@ -208,11 +207,79 @@ function htmlToPdf(_a) {
|
|
208
207
|
});
|
209
208
|
}
|
210
209
|
}
|
210
|
+
function htmlToPdfUseCanvas(_a) {
|
211
|
+
var pageClassName = _a.pageClassName, dom = _a.dom, pdfName = _a.pdfName, isShowPage = _a.isShowPage, noWater = _a.noWater, pdfOptions = _a.pdfOptions, imgPositionX = _a.imgPositionX, isDownload = _a.isDownload;
|
212
|
+
var allDom = document.querySelectorAll(pageClassName ? pageClassName : '.html2canvas-container-page');
|
213
|
+
var format = (pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.format) || [632.28, 841.89];
|
214
|
+
var _pdfOptions = __assign({ unit: 'pt', format: format }, (pdfOptions || {}));
|
215
|
+
if (allDom.length > 0 && isShowPage) {
|
216
|
+
var allDomArray = Array.prototype.slice.call(allDom);
|
217
|
+
var pdfBase64_1 = [];
|
218
|
+
var pdfs_1 = [];
|
219
|
+
var promiseAllDomArray_3 = allDomArray.map(function (dom) {
|
220
|
+
return html2canvas(dom, {
|
221
|
+
scale: 2,
|
222
|
+
});
|
223
|
+
});
|
224
|
+
return (function () {
|
225
|
+
return __awaiter(this, void 0, void 0, function () {
|
226
|
+
var _i, promiseAllDomArray_4, item, pdf, canvas;
|
227
|
+
return __generator(this, function (_a) {
|
228
|
+
switch (_a.label) {
|
229
|
+
case 0:
|
230
|
+
_i = 0, promiseAllDomArray_4 = promiseAllDomArray_3;
|
231
|
+
_a.label = 1;
|
232
|
+
case 1:
|
233
|
+
if (!(_i < promiseAllDomArray_4.length)) return [3 /*break*/, 4];
|
234
|
+
item = promiseAllDomArray_4[_i];
|
235
|
+
pdf = new jsPDF(_pdfOptions);
|
236
|
+
return [4 /*yield*/, item];
|
237
|
+
case 2:
|
238
|
+
canvas = _a.sent();
|
239
|
+
createPdf(canvas, pdf, noWater, imgPositionX, {
|
240
|
+
width: format === null || format === void 0 ? void 0 : format[0],
|
241
|
+
height: format === null || format === void 0 ? void 0 : format[1],
|
242
|
+
});
|
243
|
+
if (isDownload) {
|
244
|
+
pdf.save(pdfName + ".pdf");
|
245
|
+
}
|
246
|
+
pdfBase64_1.push(pdf.output('dataurlstring'));
|
247
|
+
pdfs_1.push(pdf);
|
248
|
+
_a.label = 3;
|
249
|
+
case 3:
|
250
|
+
_i++;
|
251
|
+
return [3 /*break*/, 1];
|
252
|
+
case 4: return [2 /*return*/, Promise.resolve({
|
253
|
+
pdfs: pdfs_1,
|
254
|
+
pdfBase64: pdfBase64_1,
|
255
|
+
})];
|
256
|
+
}
|
257
|
+
});
|
258
|
+
});
|
259
|
+
})();
|
260
|
+
}
|
261
|
+
else {
|
262
|
+
var pdf_1 = new jsPDF(_pdfOptions);
|
263
|
+
return html2canvas(dom, { scale: 2 }).then(function (canvas) {
|
264
|
+
createPdf(canvas, pdf_1, noWater, imgPositionX, {
|
265
|
+
width: format === null || format === void 0 ? void 0 : format[0],
|
266
|
+
height: format === null || format === void 0 ? void 0 : format[1],
|
267
|
+
});
|
268
|
+
if (isDownload) {
|
269
|
+
pdf_1.save(pdfName + ".pdf");
|
270
|
+
}
|
271
|
+
return {
|
272
|
+
pdfs: [pdf_1],
|
273
|
+
pdfBase64: [pdf_1.output('dataurlstring')],
|
274
|
+
};
|
275
|
+
});
|
276
|
+
}
|
277
|
+
}
|
211
278
|
function htmlToPdfNoCanvas(_a) {
|
212
279
|
var _b, _c;
|
213
280
|
var pageClassName = _a.pageClassName, dom = _a.dom, isShowPage = _a.isShowPage, fileBinary = _a.fileBinary, pdfName = _a.pdfName, isDownload = _a.isDownload, pdfOption = _a.pdfOption, isAddWater = _a.isAddWater, waterBase64 = _a.waterBase64, imgWidth = _a.imgWidth, imgHeight = _a.imgHeight, isCompress = _a.isCompress;
|
214
281
|
return __awaiter(this, void 0, void 0, function () {
|
215
|
-
var allDom, pageFormat, pageOrient, pageMarginX, pageMarginY, pdfOptions, allDomArray_1,
|
282
|
+
var allDom, pageFormat, pageOrient, pageMarginX, pageMarginY, pdfOptions, allDomArray_1, pdfBase64_2, pdfs_2, pdf_2, pageWidth_1;
|
216
283
|
return __generator(this, function (_d) {
|
217
284
|
allDom = dom.querySelectorAll(pageClassName ? pageClassName : '.html2canvas-container-page');
|
218
285
|
pageFormat = (pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageFormat) ? pdfOption.pageFormat : 'a4';
|
@@ -234,8 +301,8 @@ function htmlToPdfNoCanvas(_a) {
|
|
234
301
|
// 如果需要分页
|
235
302
|
if (allDom.length > 0 && isShowPage) {
|
236
303
|
allDomArray_1 = Array.prototype.slice.call(allDom);
|
237
|
-
|
238
|
-
|
304
|
+
pdfBase64_2 = [];
|
305
|
+
pdfs_2 = [];
|
239
306
|
return [2 /*return*/, (function () {
|
240
307
|
return __awaiter(this, void 0, void 0, function () {
|
241
308
|
var i, _loop_1, _i, allDomArray_2, item;
|
@@ -281,8 +348,8 @@ function htmlToPdfNoCanvas(_a) {
|
|
281
348
|
if (isDownload) {
|
282
349
|
pdf.save(pdfName + "_" + i + ".pdf");
|
283
350
|
}
|
284
|
-
|
285
|
-
|
351
|
+
pdfBase64_2.push(pdf.output('dataurlstring'));
|
352
|
+
pdfs_2.push(pdf);
|
286
353
|
resolve({});
|
287
354
|
},
|
288
355
|
});
|
@@ -308,8 +375,8 @@ function htmlToPdfNoCanvas(_a) {
|
|
308
375
|
_i++;
|
309
376
|
return [3 /*break*/, 1];
|
310
377
|
case 4: return [2 /*return*/, Promise.resolve({
|
311
|
-
pdfs:
|
312
|
-
pdfBase64:
|
378
|
+
pdfs: pdfs_2,
|
379
|
+
pdfBase64: pdfBase64_2,
|
313
380
|
})];
|
314
381
|
}
|
315
382
|
});
|
@@ -317,10 +384,10 @@ function htmlToPdfNoCanvas(_a) {
|
|
317
384
|
})()];
|
318
385
|
}
|
319
386
|
else {
|
320
|
-
|
321
|
-
pageWidth_1 =
|
322
|
-
setPdfVersion(
|
323
|
-
supportJsPdfChinese(
|
387
|
+
pdf_2 = new jsPDF(pdfOptions);
|
388
|
+
pageWidth_1 = pdf_2.internal.pageSize.width - pageMarginX * 2;
|
389
|
+
setPdfVersion(pdf_2);
|
390
|
+
supportJsPdfChinese(pdf_2, fileBinary);
|
324
391
|
return [2 /*return*/, new Promise(function (resolve) {
|
325
392
|
new jsPDF(pdfOptions).html(dom, {
|
326
393
|
autoPaging: 'text',
|
@@ -330,28 +397,28 @@ function htmlToPdfNoCanvas(_a) {
|
|
330
397
|
callback: function (res) {
|
331
398
|
// 添加呈现的HTML所需的页面(从第2页开始)
|
332
399
|
for (var i = 2, j = res.internal.getNumberOfPages(); i <= j; i++) {
|
333
|
-
|
400
|
+
pdf_2.addPage(pageFormat, pageOrient);
|
334
401
|
}
|
335
402
|
// 正确呈现文档
|
336
|
-
|
403
|
+
pdf_2.html(dom, {
|
337
404
|
autoPaging: 'text',
|
338
405
|
margin: [pageMarginY, pageMarginX, pageMarginY, pageMarginX],
|
339
406
|
width: pageWidth_1,
|
340
407
|
windowWidth: pageWidth_1,
|
341
408
|
callback: function () {
|
342
409
|
for (var i = 1, j = res.internal.getNumberOfPages(); i <= j; i++) {
|
343
|
-
|
410
|
+
pdf_2.setPage(i);
|
344
411
|
// 添加水印
|
345
412
|
if (isAddWater) {
|
346
|
-
setPdfWater(
|
413
|
+
setPdfWater(pdf_2, waterBase64, imgWidth, imgHeight);
|
347
414
|
}
|
348
415
|
}
|
349
416
|
if (isDownload) {
|
350
|
-
|
417
|
+
pdf_2.save(pdfName + ".pdf");
|
351
418
|
}
|
352
419
|
resolve({
|
353
|
-
pdfs: [
|
354
|
-
pdfBase64: [
|
420
|
+
pdfs: [pdf_2],
|
421
|
+
pdfBase64: [pdf_2.output('dataurlstring')],
|
355
422
|
});
|
356
423
|
},
|
357
424
|
});
|
@@ -402,4 +469,4 @@ function setPdfWater(pdf, waterBase64, imgWidth, imgHeight) {
|
|
402
469
|
}
|
403
470
|
}
|
404
471
|
|
405
|
-
export { addWaterHandle, htmlToPdf, htmlToPdfNoCanvas, printCurrentDom, removeWaterHandle };
|
472
|
+
export { addWaterHandle, htmlToPdf, htmlToPdfNoCanvas, htmlToPdfUseCanvas, printCurrentDom, removeWaterHandle };
|