fast-vue-multi-pages 1.0.4 → 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 +10 -0
- package/dist/cjs/FastVueMultiTool.js +10 -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 +18 -0
- package/dist/cjs/other/FastVueMultiFile.js +72 -0
- package/dist/esm/FastVueMultiTool.d.ts +10 -0
- package/dist/esm/FastVueMultiTool.js +9 -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 +18 -0
- package/dist/esm/other/FastVueMultiFile.js +88 -0
- package/package.json +1 -1
@@ -9,6 +9,8 @@ import { FastVueMultiBoolean } from "./other/FastVueMultiBoolean";
|
|
9
9
|
import { FastVueMultiFunction } from "./other/FastVueMultiFunction";
|
10
10
|
import { FastVueMultiElement } from "./other/FastVueMultiElement";
|
11
11
|
import { FastVueMultiWindow } from "./other/FastVueMultiWindow";
|
12
|
+
import { FastVueMultiFile } from "./other/FastVueMultiFile";
|
13
|
+
import { FastVueMultiBase64 } from "./other/FastVueMultiBase64";
|
12
14
|
/**
|
13
15
|
* FastBaseApp 手机APP功能工具类
|
14
16
|
*/
|
@@ -61,4 +63,12 @@ export declare class FastVueMultiTool {
|
|
61
63
|
* window对象相关操作
|
62
64
|
*/
|
63
65
|
static Window: typeof FastVueMultiWindow;
|
66
|
+
/**
|
67
|
+
* 文件选择器
|
68
|
+
*/
|
69
|
+
static File: typeof FastVueMultiFile;
|
70
|
+
/**
|
71
|
+
* base64相关操作
|
72
|
+
*/
|
73
|
+
static Base64: typeof FastVueMultiBase64;
|
64
74
|
}
|
@@ -13,6 +13,8 @@ const FastVueMultiBoolean_1 = require("./other/FastVueMultiBoolean");
|
|
13
13
|
const FastVueMultiFunction_1 = require("./other/FastVueMultiFunction");
|
14
14
|
const FastVueMultiElement_1 = require("./other/FastVueMultiElement");
|
15
15
|
const FastVueMultiWindow_1 = require("./other/FastVueMultiWindow");
|
16
|
+
const FastVueMultiFile_1 = require("./other/FastVueMultiFile");
|
17
|
+
const FastVueMultiBase64_1 = require("./other/FastVueMultiBase64");
|
16
18
|
/**
|
17
19
|
* FastBaseApp 手机APP功能工具类
|
18
20
|
*/
|
@@ -65,5 +67,13 @@ class FastVueMultiTool {
|
|
65
67
|
* window对象相关操作
|
66
68
|
*/
|
67
69
|
static Window = FastVueMultiWindow_1.FastVueMultiWindow;
|
70
|
+
/**
|
71
|
+
* 文件选择器
|
72
|
+
*/
|
73
|
+
static File = FastVueMultiFile_1.FastVueMultiFile;
|
74
|
+
/**
|
75
|
+
* base64相关操作
|
76
|
+
*/
|
77
|
+
static Base64 = FastVueMultiBase64_1.FastVueMultiBase64;
|
68
78
|
}
|
69
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;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export declare class FastVueMultiFile {
|
2
|
+
/**
|
3
|
+
* 弹出上传文件的选择框
|
4
|
+
* @param multi
|
5
|
+
*/
|
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>;
|
18
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiFile = void 0;
|
4
|
+
class FastVueMultiFile {
|
5
|
+
/**
|
6
|
+
* 弹出上传文件的选择框
|
7
|
+
* @param multi
|
8
|
+
*/
|
9
|
+
static async showUploadImage(multi) {
|
10
|
+
return new Promise((resolve, reject) => {
|
11
|
+
let inputElement = document.createElement('input');
|
12
|
+
let event = new MouseEvent('click');
|
13
|
+
inputElement.type = "file";
|
14
|
+
inputElement.accept = "image/*";
|
15
|
+
if (multi) {
|
16
|
+
inputElement.multiple = true;
|
17
|
+
}
|
18
|
+
inputElement.onchange = function (selectEvent) {
|
19
|
+
if (selectEvent.target) {
|
20
|
+
let target = selectEvent.target;
|
21
|
+
let base64Array = [];
|
22
|
+
for (let i = 0; i < target.files.length; i++) {
|
23
|
+
const file = target.files.item(i);
|
24
|
+
const fileReader = new FileReader();
|
25
|
+
fileReader.onload = (readEvent) => {
|
26
|
+
let base64 = readEvent.target.result;
|
27
|
+
base64Array.push({
|
28
|
+
file: file,
|
29
|
+
url: base64
|
30
|
+
});
|
31
|
+
if (base64Array.length === target.files.length) {
|
32
|
+
resolve(base64Array);
|
33
|
+
}
|
34
|
+
};
|
35
|
+
fileReader.readAsDataURL(file);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
};
|
39
|
+
inputElement.dispatchEvent(event);
|
40
|
+
});
|
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
|
+
}
|
71
|
+
}
|
72
|
+
exports.FastVueMultiFile = FastVueMultiFile;
|
@@ -9,6 +9,8 @@ import { FastVueMultiBoolean } from "./other/FastVueMultiBoolean";
|
|
9
9
|
import { FastVueMultiFunction } from "./other/FastVueMultiFunction";
|
10
10
|
import { FastVueMultiElement } from "./other/FastVueMultiElement";
|
11
11
|
import { FastVueMultiWindow } from "./other/FastVueMultiWindow";
|
12
|
+
import { FastVueMultiFile } from "./other/FastVueMultiFile";
|
13
|
+
import { FastVueMultiBase64 } from "./other/FastVueMultiBase64";
|
12
14
|
/**
|
13
15
|
* FastBaseApp 手机APP功能工具类
|
14
16
|
*/
|
@@ -61,4 +63,12 @@ export declare class FastVueMultiTool {
|
|
61
63
|
* window对象相关操作
|
62
64
|
*/
|
63
65
|
static Window: typeof FastVueMultiWindow;
|
66
|
+
/**
|
67
|
+
* 文件选择器
|
68
|
+
*/
|
69
|
+
static File: typeof FastVueMultiFile;
|
70
|
+
/**
|
71
|
+
* base64相关操作
|
72
|
+
*/
|
73
|
+
static Base64: typeof FastVueMultiBase64;
|
64
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"], 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) {
|
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;
|
@@ -57,6 +57,14 @@ define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./o
|
|
57
57
|
* window对象相关操作
|
58
58
|
*/
|
59
59
|
FastVueMultiTool.Window = FastVueMultiWindow_1.FastVueMultiWindow;
|
60
|
+
/**
|
61
|
+
* 文件选择器
|
62
|
+
*/
|
63
|
+
FastVueMultiTool.File = FastVueMultiFile_1.FastVueMultiFile;
|
64
|
+
/**
|
65
|
+
* base64相关操作
|
66
|
+
*/
|
67
|
+
FastVueMultiTool.Base64 = FastVueMultiBase64_1.FastVueMultiBase64;
|
60
68
|
return FastVueMultiTool;
|
61
69
|
}());
|
62
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
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export declare class FastVueMultiFile {
|
2
|
+
/**
|
3
|
+
* 弹出上传文件的选择框
|
4
|
+
* @param multi
|
5
|
+
*/
|
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>;
|
18
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.FastVueMultiFile = void 0;
|
5
|
+
var FastVueMultiFile = /** @class */ (function () {
|
6
|
+
function FastVueMultiFile() {
|
7
|
+
}
|
8
|
+
/**
|
9
|
+
* 弹出上传文件的选择框
|
10
|
+
* @param multi
|
11
|
+
*/
|
12
|
+
FastVueMultiFile.showUploadImage = function (multi) {
|
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) {
|
75
|
+
var fileReader = new FileReader();
|
76
|
+
fileReader.onload = function (readEvent) {
|
77
|
+
var base64 = readEvent.target.result;
|
78
|
+
resolved(base64);
|
79
|
+
};
|
80
|
+
fileReader.readAsDataURL(file);
|
81
|
+
})];
|
82
|
+
});
|
83
|
+
});
|
84
|
+
};
|
85
|
+
return FastVueMultiFile;
|
86
|
+
}());
|
87
|
+
exports.FastVueMultiFile = FastVueMultiFile;
|
88
|
+
});
|