fast-vue-multi-pages 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. package/dist/cjs/FastVueMultiTool.d.ts +5 -0
  2. package/dist/cjs/FastVueMultiTool.js +5 -0
  3. package/dist/cjs/http/FastVueMultiHttp.d.ts +5 -90
  4. package/dist/cjs/http/FastVueMultiHttp.js +6 -148
  5. package/dist/cjs/http/FastVueMultiSimpleJsonResponse.d.ts +67 -0
  6. package/dist/cjs/http/FastVueMultiSimpleJsonResponse.js +126 -0
  7. package/dist/cjs/http/FastVueMultiSimpleRequestConfig.d.ts +21 -0
  8. package/dist/cjs/http/FastVueMultiSimpleRequestConfig.js +25 -0
  9. package/dist/cjs/index.d.ts +3 -1
  10. package/dist/cjs/index.js +5 -1
  11. package/dist/cjs/other/FastVueMultiBase64.d.ts +12 -0
  12. package/dist/cjs/other/FastVueMultiBase64.js +22 -0
  13. package/dist/cjs/other/FastVueMultiFile.d.ts +11 -0
  14. package/dist/cjs/other/FastVueMultiFile.js +36 -2
  15. package/dist/esm/FastVueMultiTool.d.ts +5 -0
  16. package/dist/esm/FastVueMultiTool.js +5 -1
  17. package/dist/esm/http/FastVueMultiHttp.d.ts +5 -90
  18. package/dist/esm/http/FastVueMultiHttp.js +5 -152
  19. package/dist/esm/http/FastVueMultiSimpleJsonResponse.d.ts +67 -0
  20. package/dist/esm/http/FastVueMultiSimpleJsonResponse.js +127 -0
  21. package/dist/esm/http/FastVueMultiSimpleRequestConfig.d.ts +21 -0
  22. package/dist/esm/http/FastVueMultiSimpleRequestConfig.js +30 -0
  23. package/dist/esm/index.d.ts +3 -1
  24. package/dist/esm/index.js +4 -2
  25. package/dist/esm/other/FastVueMultiBase64.d.ts +12 -0
  26. package/dist/esm/other/FastVueMultiBase64.js +27 -0
  27. package/dist/esm/other/FastVueMultiFile.d.ts +11 -0
  28. package/dist/esm/other/FastVueMultiFile.js +68 -23
  29. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ export declare class FastVueMultiBase64 {
2
+ /**
3
+ * 转码base64
4
+ * @param content
5
+ */
6
+ static encode(content: any): string;
7
+ /**
8
+ * 解码base64
9
+ * @param content
10
+ */
11
+ static decode(content: string): string;
12
+ }
@@ -0,0 +1,27 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FastVueMultiBase64 = void 0;
5
+ var FastVueMultiBase64 = /** @class */ (function () {
6
+ function FastVueMultiBase64() {
7
+ }
8
+ /**
9
+ * 转码base64
10
+ * @param content
11
+ */
12
+ FastVueMultiBase64.encode = function (content) {
13
+ var Base64 = require("js-base64");
14
+ return Base64.encode(content);
15
+ };
16
+ /**
17
+ * 解码base64
18
+ * @param content
19
+ */
20
+ FastVueMultiBase64.decode = function (content) {
21
+ var Base64 = require("js-base64");
22
+ return Base64.decode(content);
23
+ };
24
+ return FastVueMultiBase64;
25
+ }());
26
+ exports.FastVueMultiBase64 = FastVueMultiBase64;
27
+ });
@@ -4,4 +4,15 @@ export declare class FastVueMultiFile {
4
4
  * @param multi
5
5
  */
6
6
  static showUploadImage(multi: boolean): Promise<any>;
7
+ /**
8
+ * 将base64转为file对象
9
+ * @param content base64内容
10
+ * @param fileName 文件名
11
+ */
12
+ static base64ToFile(content: string, fileName: string): File;
13
+ /**
14
+ * 将file对象转为base64
15
+ * @param file
16
+ */
17
+ static fileToBase64(file: File): Promise<unknown>;
7
18
  }
@@ -1,4 +1,4 @@
1
- define(["require", "exports"], function (require, exports) {
1
+ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.FastVueMultiFile = void 0;
@@ -10,33 +10,78 @@ define(["require", "exports"], function (require, exports) {
10
10
  * @param multi
11
11
  */
12
12
  FastVueMultiFile.showUploadImage = function (multi) {
13
- return new Promise(function (resolve, reject) {
14
- var inputElement = document.createElement('input');
15
- var event = new MouseEvent('click');
16
- inputElement.type = "file";
17
- inputElement.accept = "image/*";
18
- if (multi) {
19
- inputElement.multiple = true;
20
- }
21
- inputElement.onchange = function (selectEvent) {
22
- if (selectEvent.target) {
23
- var target_1 = selectEvent.target;
24
- var base64Array_1 = [];
25
- for (var i = 0; i < target_1.files.length; i++) {
26
- var file = target_1.files.item(i);
13
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
14
+ return tslib_1.__generator(this, function (_a) {
15
+ return [2 /*return*/, new Promise(function (resolve, reject) {
16
+ var inputElement = document.createElement('input');
17
+ var event = new MouseEvent('click');
18
+ inputElement.type = "file";
19
+ inputElement.accept = "image/*";
20
+ if (multi) {
21
+ inputElement.multiple = true;
22
+ }
23
+ inputElement.onchange = function (selectEvent) {
24
+ if (selectEvent.target) {
25
+ var target_1 = selectEvent.target;
26
+ var base64Array_1 = [];
27
+ var _loop_1 = function (i) {
28
+ var file = target_1.files.item(i);
29
+ var fileReader = new FileReader();
30
+ fileReader.onload = function (readEvent) {
31
+ var base64 = readEvent.target.result;
32
+ base64Array_1.push({
33
+ file: file,
34
+ url: base64
35
+ });
36
+ if (base64Array_1.length === target_1.files.length) {
37
+ resolve(base64Array_1);
38
+ }
39
+ };
40
+ fileReader.readAsDataURL(file);
41
+ };
42
+ for (var i = 0; i < target_1.files.length; i++) {
43
+ _loop_1(i);
44
+ }
45
+ }
46
+ };
47
+ inputElement.onerror = reject;
48
+ inputElement.onabort = reject;
49
+ inputElement.dispatchEvent(event);
50
+ })];
51
+ });
52
+ });
53
+ };
54
+ /**
55
+ * 将base64转为file对象
56
+ * @param content base64内容
57
+ * @param fileName 文件名
58
+ */
59
+ FastVueMultiFile.base64ToFile = function (content, fileName) {
60
+ var arr = content.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
61
+ while (n--) {
62
+ u8arr[n] = bstr.charCodeAt(n);
63
+ }
64
+ var blob = new Blob([u8arr], { type: mime });
65
+ blob.lastModifiedDate = new Date();
66
+ blob.name = fileName;
67
+ return blob;
68
+ };
69
+ /**
70
+ * 将file对象转为base64
71
+ * @param file
72
+ */
73
+ FastVueMultiFile.fileToBase64 = function (file) {
74
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
75
+ return tslib_1.__generator(this, function (_a) {
76
+ return [2 /*return*/, new Promise(function (resolved, rejected) {
27
77
  var fileReader = new FileReader();
28
78
  fileReader.onload = function (readEvent) {
29
79
  var base64 = readEvent.target.result;
30
- base64Array_1.push(base64);
31
- if (base64Array_1.length === target_1.files.length) {
32
- resolve(base64Array_1);
33
- }
80
+ resolved(base64);
34
81
  };
35
82
  fileReader.readAsDataURL(file);
36
- }
37
- }
38
- };
39
- inputElement.dispatchEvent(event);
83
+ })];
84
+ });
40
85
  });
41
86
  };
42
87
  return FastVueMultiFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-vue-multi-pages",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "author": "janesen",
5
5
  "description": "快速搭建VUE项目工具类的基本库,主要用于每个功能页面独立生成html",
6
6
  "main": "./dist/cjs/index.js",