fast-vue-multi-pages 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,13 +6,13 @@ export declare class FastVueMultiFile {
|
|
6
6
|
static showUploadImage(multi: boolean): Promise<any>;
|
7
7
|
/**
|
8
8
|
* 将base64转为file对象
|
9
|
-
* @param
|
9
|
+
* @param base64Content base64内容
|
10
10
|
* @param fileName 文件名
|
11
11
|
*/
|
12
|
-
static base64ToFile(
|
12
|
+
static base64ToFile(base64Content: string, fileName: string): Promise<File>;
|
13
13
|
/**
|
14
14
|
* 将file对象转为base64
|
15
15
|
* @param file
|
16
16
|
*/
|
17
|
-
static fileToBase64(file: File): Promise<
|
17
|
+
static fileToBase64(file: File): Promise<string>;
|
18
18
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.FastVueMultiFile = void 0;
|
4
|
+
const file64_1 = require("file64");
|
4
5
|
class FastVueMultiFile {
|
5
6
|
/**
|
6
7
|
* 弹出上传文件的选择框
|
@@ -43,32 +44,18 @@ class FastVueMultiFile {
|
|
43
44
|
}
|
44
45
|
/**
|
45
46
|
* 将base64转为file对象
|
46
|
-
* @param
|
47
|
+
* @param base64Content base64内容
|
47
48
|
* @param fileName 文件名
|
48
49
|
*/
|
49
|
-
static base64ToFile(
|
50
|
-
|
51
|
-
while (n--) {
|
52
|
-
u8arr[n] = bstr.charCodeAt(n);
|
53
|
-
}
|
54
|
-
const blob = new Blob([u8arr], { type: mime });
|
55
|
-
blob.lastModifiedDate = new Date();
|
56
|
-
blob.name = fileName;
|
57
|
-
return blob;
|
50
|
+
static async base64ToFile(base64Content, fileName) {
|
51
|
+
return await (0, file64_1.base64ToFile)(base64Content, fileName);
|
58
52
|
}
|
59
53
|
/**
|
60
54
|
* 将file对象转为base64
|
61
55
|
* @param file
|
62
56
|
*/
|
63
57
|
static async fileToBase64(file) {
|
64
|
-
return
|
65
|
-
const fileReader = new FileReader();
|
66
|
-
fileReader.onload = function (readEvent) {
|
67
|
-
let base64 = readEvent.target.result;
|
68
|
-
resolved(base64);
|
69
|
-
};
|
70
|
-
fileReader.readAsDataURL(file);
|
71
|
-
});
|
58
|
+
return await (0, file64_1.fileToBase64)(file);
|
72
59
|
}
|
73
60
|
}
|
74
61
|
exports.FastVueMultiFile = FastVueMultiFile;
|
@@ -6,13 +6,13 @@ export declare class FastVueMultiFile {
|
|
6
6
|
static showUploadImage(multi: boolean): Promise<any>;
|
7
7
|
/**
|
8
8
|
* 将base64转为file对象
|
9
|
-
* @param
|
9
|
+
* @param base64Content base64内容
|
10
10
|
* @param fileName 文件名
|
11
11
|
*/
|
12
|
-
static base64ToFile(
|
12
|
+
static base64ToFile(base64Content: string, fileName: string): Promise<File>;
|
13
13
|
/**
|
14
14
|
* 将file对象转为base64
|
15
15
|
* @param file
|
16
16
|
*/
|
17
|
-
static fileToBase64(file: File): Promise<
|
17
|
+
static fileToBase64(file: File): Promise<string>;
|
18
18
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
1
|
+
define(["require", "exports", "tslib", "file64"], function (require, exports, tslib_1, file64_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.FastVueMultiFile = void 0;
|
@@ -53,18 +53,18 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
|
53
53
|
};
|
54
54
|
/**
|
55
55
|
* 将base64转为file对象
|
56
|
-
* @param
|
56
|
+
* @param base64Content base64内容
|
57
57
|
* @param fileName 文件名
|
58
58
|
*/
|
59
|
-
FastVueMultiFile.base64ToFile = function (
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
59
|
+
FastVueMultiFile.base64ToFile = function (base64Content, fileName) {
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
61
|
+
return tslib_1.__generator(this, function (_a) {
|
62
|
+
switch (_a.label) {
|
63
|
+
case 0: return [4 /*yield*/, (0, file64_1.base64ToFile)(base64Content, fileName)];
|
64
|
+
case 1: return [2 /*return*/, _a.sent()];
|
65
|
+
}
|
66
|
+
});
|
67
|
+
});
|
68
68
|
};
|
69
69
|
/**
|
70
70
|
* 将file对象转为base64
|
@@ -73,14 +73,10 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
|
73
73
|
FastVueMultiFile.fileToBase64 = function (file) {
|
74
74
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
75
75
|
return tslib_1.__generator(this, function (_a) {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
resolved(base64);
|
81
|
-
};
|
82
|
-
fileReader.readAsDataURL(file);
|
83
|
-
})];
|
76
|
+
switch (_a.label) {
|
77
|
+
case 0: return [4 /*yield*/, (0, file64_1.fileToBase64)(file)];
|
78
|
+
case 1: return [2 /*return*/, _a.sent()];
|
79
|
+
}
|
84
80
|
});
|
85
81
|
});
|
86
82
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "fast-vue-multi-pages",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.10",
|
4
4
|
"author": "janesen",
|
5
5
|
"description": "快速搭建VUE项目工具类的基本库,主要用于每个功能页面独立生成html",
|
6
6
|
"main": "./dist/cjs/index.js",
|
@@ -31,7 +31,8 @@
|
|
31
31
|
"@types/js-cookie": "^3.0.6",
|
32
32
|
"@types/lodash": "^4.17.6",
|
33
33
|
"copy-to-clipboard": "^3.3.3",
|
34
|
-
"ip": "^2.0.1"
|
34
|
+
"ip": "^2.0.1",
|
35
|
+
"file64": "^1.0.3"
|
35
36
|
},
|
36
37
|
"devDependencies": {
|
37
38
|
"@typescript-eslint/eslint-plugin": "^7.16.0",
|