fast-vue-multi-pages 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/FastVueMultiTool.d.ts +5 -0
- package/dist/cjs/FastVueMultiTool.js +5 -0
- package/dist/cjs/other/FastVueMultiBase64.d.ts +12 -0
- package/dist/cjs/other/FastVueMultiBase64.js +22 -0
- package/dist/cjs/other/FastVueMultiFile.d.ts +11 -0
- package/dist/cjs/other/FastVueMultiFile.js +34 -2
- package/dist/esm/FastVueMultiTool.d.ts +5 -0
- package/dist/esm/FastVueMultiTool.js +5 -1
- package/dist/esm/other/FastVueMultiBase64.d.ts +12 -0
- package/dist/esm/other/FastVueMultiBase64.js +27 -0
- package/dist/esm/other/FastVueMultiFile.d.ts +11 -0
- package/dist/esm/other/FastVueMultiFile.js +66 -23
- package/package.json +1 -1
@@ -10,6 +10,7 @@ import { FastVueMultiFunction } from "./other/FastVueMultiFunction";
|
|
10
10
|
import { FastVueMultiElement } from "./other/FastVueMultiElement";
|
11
11
|
import { FastVueMultiWindow } from "./other/FastVueMultiWindow";
|
12
12
|
import { FastVueMultiFile } from "./other/FastVueMultiFile";
|
13
|
+
import { FastVueMultiBase64 } from "./other/FastVueMultiBase64";
|
13
14
|
/**
|
14
15
|
* FastBaseApp 手机APP功能工具类
|
15
16
|
*/
|
@@ -66,4 +67,8 @@ export declare class FastVueMultiTool {
|
|
66
67
|
* 文件选择器
|
67
68
|
*/
|
68
69
|
static File: typeof FastVueMultiFile;
|
70
|
+
/**
|
71
|
+
* base64相关操作
|
72
|
+
*/
|
73
|
+
static Base64: typeof FastVueMultiBase64;
|
69
74
|
}
|
@@ -14,6 +14,7 @@ const FastVueMultiFunction_1 = require("./other/FastVueMultiFunction");
|
|
14
14
|
const FastVueMultiElement_1 = require("./other/FastVueMultiElement");
|
15
15
|
const FastVueMultiWindow_1 = require("./other/FastVueMultiWindow");
|
16
16
|
const FastVueMultiFile_1 = require("./other/FastVueMultiFile");
|
17
|
+
const FastVueMultiBase64_1 = require("./other/FastVueMultiBase64");
|
17
18
|
/**
|
18
19
|
* FastBaseApp 手机APP功能工具类
|
19
20
|
*/
|
@@ -70,5 +71,9 @@ class FastVueMultiTool {
|
|
70
71
|
* 文件选择器
|
71
72
|
*/
|
72
73
|
static File = FastVueMultiFile_1.FastVueMultiFile;
|
74
|
+
/**
|
75
|
+
* base64相关操作
|
76
|
+
*/
|
77
|
+
static Base64 = FastVueMultiBase64_1.FastVueMultiBase64;
|
73
78
|
}
|
74
79
|
exports.FastVueMultiTool = FastVueMultiTool;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiBase64 = void 0;
|
4
|
+
class FastVueMultiBase64 {
|
5
|
+
/**
|
6
|
+
* 转码base64
|
7
|
+
* @param content
|
8
|
+
*/
|
9
|
+
static encode(content) {
|
10
|
+
const Base64 = require("js-base64");
|
11
|
+
return Base64.encode(content);
|
12
|
+
}
|
13
|
+
/**
|
14
|
+
* 解码base64
|
15
|
+
* @param content
|
16
|
+
*/
|
17
|
+
static decode(content) {
|
18
|
+
const Base64 = require("js-base64");
|
19
|
+
return Base64.decode(content);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
exports.FastVueMultiBase64 = FastVueMultiBase64;
|
@@ -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
|
}
|
@@ -6,7 +6,7 @@ class FastVueMultiFile {
|
|
6
6
|
* 弹出上传文件的选择框
|
7
7
|
* @param multi
|
8
8
|
*/
|
9
|
-
static showUploadImage(multi) {
|
9
|
+
static async showUploadImage(multi) {
|
10
10
|
return new Promise((resolve, reject) => {
|
11
11
|
let inputElement = document.createElement('input');
|
12
12
|
let event = new MouseEvent('click');
|
@@ -24,7 +24,10 @@ class FastVueMultiFile {
|
|
24
24
|
const fileReader = new FileReader();
|
25
25
|
fileReader.onload = (readEvent) => {
|
26
26
|
let base64 = readEvent.target.result;
|
27
|
-
base64Array.push(
|
27
|
+
base64Array.push({
|
28
|
+
file: file,
|
29
|
+
url: base64
|
30
|
+
});
|
28
31
|
if (base64Array.length === target.files.length) {
|
29
32
|
resolve(base64Array);
|
30
33
|
}
|
@@ -36,5 +39,34 @@ class FastVueMultiFile {
|
|
36
39
|
inputElement.dispatchEvent(event);
|
37
40
|
});
|
38
41
|
}
|
42
|
+
/**
|
43
|
+
* 将base64转为file对象
|
44
|
+
* @param content base64内容
|
45
|
+
* @param fileName 文件名
|
46
|
+
*/
|
47
|
+
static base64ToFile(content, fileName) {
|
48
|
+
let arr = content.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
49
|
+
while (n--) {
|
50
|
+
u8arr[n] = bstr.charCodeAt(n);
|
51
|
+
}
|
52
|
+
const blob = new Blob([u8arr], { type: mime });
|
53
|
+
blob.lastModifiedDate = new Date();
|
54
|
+
blob.name = fileName;
|
55
|
+
return blob;
|
56
|
+
}
|
57
|
+
/**
|
58
|
+
* 将file对象转为base64
|
59
|
+
* @param file
|
60
|
+
*/
|
61
|
+
static async fileToBase64(file) {
|
62
|
+
return new Promise(function (resolved, rejected) {
|
63
|
+
const fileReader = new FileReader();
|
64
|
+
fileReader.onload = function (readEvent) {
|
65
|
+
let base64 = readEvent.target.result;
|
66
|
+
resolved(base64);
|
67
|
+
};
|
68
|
+
fileReader.readAsDataURL(file);
|
69
|
+
});
|
70
|
+
}
|
39
71
|
}
|
40
72
|
exports.FastVueMultiFile = FastVueMultiFile;
|
@@ -10,6 +10,7 @@ import { FastVueMultiFunction } from "./other/FastVueMultiFunction";
|
|
10
10
|
import { FastVueMultiElement } from "./other/FastVueMultiElement";
|
11
11
|
import { FastVueMultiWindow } from "./other/FastVueMultiWindow";
|
12
12
|
import { FastVueMultiFile } from "./other/FastVueMultiFile";
|
13
|
+
import { FastVueMultiBase64 } from "./other/FastVueMultiBase64";
|
13
14
|
/**
|
14
15
|
* FastBaseApp 手机APP功能工具类
|
15
16
|
*/
|
@@ -66,4 +67,8 @@ export declare class FastVueMultiTool {
|
|
66
67
|
* 文件选择器
|
67
68
|
*/
|
68
69
|
static File: typeof FastVueMultiFile;
|
70
|
+
/**
|
71
|
+
* base64相关操作
|
72
|
+
*/
|
73
|
+
static Base64: typeof FastVueMultiBase64;
|
69
74
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./other/FastVueMultiStore", "./vue/FastVueMultiConfig", "./http/FastVueMultiCookie", "./other/FastVueMultiClipboard", "./other/FastVueMultiDate", "./other/FastVueMultiBoolean", "./other/FastVueMultiFunction", "./other/FastVueMultiElement", "./other/FastVueMultiWindow", "./other/FastVueMultiFile"], function (require, exports, tslib_1, lodash_1, FastVueMultiHttp_1, FastVueMultiStore_1, FastVueMultiConfig_1, FastVueMultiCookie_1, FastVueMultiClipboard_1, FastVueMultiDate_1, FastVueMultiBoolean_1, FastVueMultiFunction_1, FastVueMultiElement_1, FastVueMultiWindow_1, FastVueMultiFile_1) {
|
1
|
+
define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./other/FastVueMultiStore", "./vue/FastVueMultiConfig", "./http/FastVueMultiCookie", "./other/FastVueMultiClipboard", "./other/FastVueMultiDate", "./other/FastVueMultiBoolean", "./other/FastVueMultiFunction", "./other/FastVueMultiElement", "./other/FastVueMultiWindow", "./other/FastVueMultiFile", "./other/FastVueMultiBase64"], function (require, exports, tslib_1, lodash_1, FastVueMultiHttp_1, FastVueMultiStore_1, FastVueMultiConfig_1, FastVueMultiCookie_1, FastVueMultiClipboard_1, FastVueMultiDate_1, FastVueMultiBoolean_1, FastVueMultiFunction_1, FastVueMultiElement_1, FastVueMultiWindow_1, FastVueMultiFile_1, FastVueMultiBase64_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.FastVueMultiTool = void 0;
|
@@ -61,6 +61,10 @@ define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./o
|
|
61
61
|
* 文件选择器
|
62
62
|
*/
|
63
63
|
FastVueMultiTool.File = FastVueMultiFile_1.FastVueMultiFile;
|
64
|
+
/**
|
65
|
+
* base64相关操作
|
66
|
+
*/
|
67
|
+
FastVueMultiTool.Base64 = FastVueMultiBase64_1.FastVueMultiBase64;
|
64
68
|
return FastVueMultiTool;
|
65
69
|
}());
|
66
70
|
exports.FastVueMultiTool = FastVueMultiTool;
|
@@ -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,76 @@ define(["require", "exports"], function (require, exports) {
|
|
10
10
|
* @param multi
|
11
11
|
*/
|
12
12
|
FastVueMultiFile.showUploadImage = function (multi) {
|
13
|
-
return
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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.dispatchEvent(event);
|
48
|
+
})];
|
49
|
+
});
|
50
|
+
});
|
51
|
+
};
|
52
|
+
/**
|
53
|
+
* 将base64转为file对象
|
54
|
+
* @param content base64内容
|
55
|
+
* @param fileName 文件名
|
56
|
+
*/
|
57
|
+
FastVueMultiFile.base64ToFile = function (content, fileName) {
|
58
|
+
var arr = content.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
59
|
+
while (n--) {
|
60
|
+
u8arr[n] = bstr.charCodeAt(n);
|
61
|
+
}
|
62
|
+
var blob = new Blob([u8arr], { type: mime });
|
63
|
+
blob.lastModifiedDate = new Date();
|
64
|
+
blob.name = fileName;
|
65
|
+
return blob;
|
66
|
+
};
|
67
|
+
/**
|
68
|
+
* 将file对象转为base64
|
69
|
+
* @param file
|
70
|
+
*/
|
71
|
+
FastVueMultiFile.fileToBase64 = function (file) {
|
72
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
73
|
+
return tslib_1.__generator(this, function (_a) {
|
74
|
+
return [2 /*return*/, new Promise(function (resolved, rejected) {
|
27
75
|
var fileReader = new FileReader();
|
28
76
|
fileReader.onload = function (readEvent) {
|
29
77
|
var base64 = readEvent.target.result;
|
30
|
-
|
31
|
-
if (base64Array_1.length === target_1.files.length) {
|
32
|
-
resolve(base64Array_1);
|
33
|
-
}
|
78
|
+
resolved(base64);
|
34
79
|
};
|
35
80
|
fileReader.readAsDataURL(file);
|
36
|
-
}
|
37
|
-
|
38
|
-
};
|
39
|
-
inputElement.dispatchEvent(event);
|
81
|
+
})];
|
82
|
+
});
|
40
83
|
});
|
41
84
|
};
|
42
85
|
return FastVueMultiFile;
|