fast-vue-multi-pages 1.0.10 → 1.0.12
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/cjs/FastVueMultiTool.d.ts +5 -0
- package/dist/cjs/FastVueMultiTool.js +5 -0
- package/dist/cjs/other/FastVueMultiFile.d.ts +2 -2
- package/dist/cjs/other/FastVueMultiFile.js +27 -5
- package/dist/cjs/other/FastVueMultiWatcher.d.ts +22 -0
- package/dist/cjs/other/FastVueMultiWatcher.js +106 -0
- package/dist/esm/FastVueMultiTool.d.ts +5 -0
- package/dist/esm/FastVueMultiTool.js +5 -1
- package/dist/esm/other/FastVueMultiFile.d.ts +2 -2
- package/dist/esm/other/FastVueMultiFile.js +27 -14
- package/dist/esm/other/FastVueMultiWatcher.d.ts +22 -0
- package/dist/esm/other/FastVueMultiWatcher.js +113 -0
- package/package.json +1 -1
@@ -11,6 +11,7 @@ import { FastVueMultiElement } from "./other/FastVueMultiElement";
|
|
11
11
|
import { FastVueMultiWindow } from "./other/FastVueMultiWindow";
|
12
12
|
import { FastVueMultiFile } from "./other/FastVueMultiFile";
|
13
13
|
import { FastVueMultiBase64 } from "./other/FastVueMultiBase64";
|
14
|
+
import { FastVueMultiWatcher } from "./other/FastVueMultiWatcher";
|
14
15
|
/**
|
15
16
|
* FastBaseApp 手机APP功能工具类
|
16
17
|
*/
|
@@ -71,4 +72,8 @@ export declare class FastVueMultiTool {
|
|
71
72
|
* base64相关操作
|
72
73
|
*/
|
73
74
|
static Base64: typeof FastVueMultiBase64;
|
75
|
+
/**
|
76
|
+
* 监听者
|
77
|
+
*/
|
78
|
+
static Watcher: typeof FastVueMultiWatcher;
|
74
79
|
}
|
@@ -15,6 +15,7 @@ const FastVueMultiElement_1 = require("./other/FastVueMultiElement");
|
|
15
15
|
const FastVueMultiWindow_1 = require("./other/FastVueMultiWindow");
|
16
16
|
const FastVueMultiFile_1 = require("./other/FastVueMultiFile");
|
17
17
|
const FastVueMultiBase64_1 = require("./other/FastVueMultiBase64");
|
18
|
+
const FastVueMultiWatcher_1 = require("./other/FastVueMultiWatcher");
|
18
19
|
/**
|
19
20
|
* FastBaseApp 手机APP功能工具类
|
20
21
|
*/
|
@@ -75,5 +76,9 @@ class FastVueMultiTool {
|
|
75
76
|
* base64相关操作
|
76
77
|
*/
|
77
78
|
static Base64 = FastVueMultiBase64_1.FastVueMultiBase64;
|
79
|
+
/**
|
80
|
+
* 监听者
|
81
|
+
*/
|
82
|
+
static Watcher = FastVueMultiWatcher_1.FastVueMultiWatcher;
|
78
83
|
}
|
79
84
|
exports.FastVueMultiTool = FastVueMultiTool;
|
@@ -6,10 +6,10 @@ export declare class FastVueMultiFile {
|
|
6
6
|
static showUploadImage(multi: boolean): Promise<any>;
|
7
7
|
/**
|
8
8
|
* 将base64转为file对象
|
9
|
-
* @param
|
9
|
+
* @param content base64内容
|
10
10
|
* @param fileName 文件名
|
11
11
|
*/
|
12
|
-
static base64ToFile(
|
12
|
+
static base64ToFile(content: string, fileName: string): Promise<File>;
|
13
13
|
/**
|
14
14
|
* 将file对象转为base64
|
15
15
|
* @param file
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.FastVueMultiFile = void 0;
|
4
|
-
const file64_1 = require("file64");
|
5
4
|
class FastVueMultiFile {
|
6
5
|
/**
|
7
6
|
* 弹出上传文件的选择框
|
@@ -44,18 +43,41 @@ class FastVueMultiFile {
|
|
44
43
|
}
|
45
44
|
/**
|
46
45
|
* 将base64转为file对象
|
47
|
-
* @param
|
46
|
+
* @param content base64内容
|
48
47
|
* @param fileName 文件名
|
49
48
|
*/
|
50
|
-
static
|
51
|
-
return
|
49
|
+
static base64ToFile(content, fileName) {
|
50
|
+
return new Promise(function (resolved, rejected) {
|
51
|
+
// 将base64的数据部分提取出来
|
52
|
+
const parts = content.split(';base64,');
|
53
|
+
const contentType = parts[0].split(':')[1];
|
54
|
+
const raw = window.atob(parts[1]);
|
55
|
+
// 将原始数据转换为Uint8Array
|
56
|
+
const rawLength = raw.length;
|
57
|
+
const uInt8Array = new Uint8Array(rawLength);
|
58
|
+
for (let i = 0; i < rawLength; ++i) {
|
59
|
+
uInt8Array[i] = raw.charCodeAt(i);
|
60
|
+
}
|
61
|
+
// 使用Blob对象创建File对象
|
62
|
+
const blob = new Blob([uInt8Array], { type: contentType });
|
63
|
+
blob.lastModifiedDate = new Date();
|
64
|
+
blob.name = fileName;
|
65
|
+
resolved(new File([blob], fileName, { type: contentType }));
|
66
|
+
});
|
52
67
|
}
|
53
68
|
/**
|
54
69
|
* 将file对象转为base64
|
55
70
|
* @param file
|
56
71
|
*/
|
57
72
|
static async fileToBase64(file) {
|
58
|
-
return
|
73
|
+
return new Promise(function (resolved, rejected) {
|
74
|
+
const fileReader = new FileReader();
|
75
|
+
fileReader.onload = function (readEvent) {
|
76
|
+
let base64 = readEvent.target.result;
|
77
|
+
resolved(base64);
|
78
|
+
};
|
79
|
+
fileReader.readAsDataURL(file);
|
80
|
+
});
|
59
81
|
}
|
60
82
|
}
|
61
83
|
exports.FastVueMultiFile = FastVueMultiFile;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* 事件监听器
|
3
|
+
*/
|
4
|
+
export declare class FastVueMultiWatcher {
|
5
|
+
private static getWatcherConfig;
|
6
|
+
private static getWatcherTimer;
|
7
|
+
private static setWatcherTimer;
|
8
|
+
private static stopWatcherTimer;
|
9
|
+
private static startTimer;
|
10
|
+
/**
|
11
|
+
* 启动一个事件监听器
|
12
|
+
* @param eventName 事件名称 string|array
|
13
|
+
* @param callback 事件触发的回调 function(eventName,eventParams){}
|
14
|
+
*/
|
15
|
+
static startWatcher(eventName: any, callback: any): void;
|
16
|
+
/**
|
17
|
+
* 通知事件监听者
|
18
|
+
* @param eventName 事件名称 string|array
|
19
|
+
* @param eventParams 携带参数 any
|
20
|
+
*/
|
21
|
+
static notifyWatcher(eventName: any, eventParams?: any): void;
|
22
|
+
}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FastVueMultiWatcher = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
6
|
+
const js_cookie_1 = tslib_1.__importDefault(require("js-cookie"));
|
7
|
+
/**
|
8
|
+
* 事件监听器
|
9
|
+
*/
|
10
|
+
class FastVueMultiWatcher {
|
11
|
+
static getWatcherConfig() {
|
12
|
+
if (!window["__watcherConfig"]) {
|
13
|
+
window["__watcherConfig"] = {};
|
14
|
+
}
|
15
|
+
return window["__watcherConfig"];
|
16
|
+
}
|
17
|
+
static getWatcherTimer() {
|
18
|
+
return window["__watcherTimer"];
|
19
|
+
}
|
20
|
+
static setWatcherTimer(timer) {
|
21
|
+
window["__watcherTimer"] = timer;
|
22
|
+
}
|
23
|
+
static stopWatcherTimer() {
|
24
|
+
if (this.getWatcherTimer()) {
|
25
|
+
clearTimeout(this.getWatcherTimer());
|
26
|
+
}
|
27
|
+
}
|
28
|
+
static startTimer() {
|
29
|
+
this.stopWatcherTimer();
|
30
|
+
this.setWatcherTimer(setTimeout(() => {
|
31
|
+
for (let eventName in this.getWatcherConfig()) {
|
32
|
+
let watchValue = js_cookie_1.default.get("EVENT@" + eventName);
|
33
|
+
let config = this.getWatcherConfig()[eventName];
|
34
|
+
if (watchValue !== null && watchValue !== undefined && watchValue !== "null" && watchValue !== "undefined") {
|
35
|
+
let timestamp = parseInt(watchValue);
|
36
|
+
if (isNaN(timestamp)) {
|
37
|
+
continue;
|
38
|
+
}
|
39
|
+
if (config.timestamp < timestamp) {
|
40
|
+
let params = js_cookie_1.default.get("EVENT@PARMAS@" + eventName);
|
41
|
+
if (params) {
|
42
|
+
params = JSON.parse(params);
|
43
|
+
}
|
44
|
+
config.timestamp = timestamp;
|
45
|
+
config.callback(eventName, params);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
this.startTimer();
|
50
|
+
}, 500));
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* 启动一个事件监听器
|
54
|
+
* @param eventName 事件名称 string|array
|
55
|
+
* @param callback 事件触发的回调 function(eventName,eventParams){}
|
56
|
+
*/
|
57
|
+
static startWatcher(eventName, callback) {
|
58
|
+
if (!window["__watchCookieTimestamp"]) {
|
59
|
+
window["__watchCookieTimestamp"] = {};
|
60
|
+
}
|
61
|
+
if (!callback || lodash_1.default.isEmpty(eventName)) {
|
62
|
+
//未携带回调函数的监听者,认为是无效监听
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
if (lodash_1.default.isArray(eventName)) {
|
66
|
+
for (let cookieNameElement of eventName) {
|
67
|
+
this.getWatcherConfig()[cookieNameElement] = {
|
68
|
+
timestamp: new Date().getTime(),
|
69
|
+
callback: callback,
|
70
|
+
};
|
71
|
+
}
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
this.getWatcherConfig()[eventName] = {
|
75
|
+
timestamp: new Date().getTime(),
|
76
|
+
callback: callback,
|
77
|
+
};
|
78
|
+
}
|
79
|
+
this.startTimer();
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* 通知事件监听者
|
83
|
+
* @param eventName 事件名称 string|array
|
84
|
+
* @param eventParams 携带参数 any
|
85
|
+
*/
|
86
|
+
static notifyWatcher(eventName, eventParams) {
|
87
|
+
if (lodash_1.default.isEmpty(eventName)) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
if (lodash_1.default.isArray(eventName)) {
|
91
|
+
for (let cookieNameElement of eventName) {
|
92
|
+
js_cookie_1.default.set("EVENT@" + cookieNameElement, (new Date().getTime()).toString());
|
93
|
+
if (eventParams) {
|
94
|
+
js_cookie_1.default.set("EVENT@PARMAS@" + cookieNameElement, JSON.stringify(eventParams));
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
else {
|
99
|
+
js_cookie_1.default.set("EVENT@" + eventName, (new Date().getTime()).toString());
|
100
|
+
if (eventParams) {
|
101
|
+
js_cookie_1.default.set("EVENT@PARMAS@" + eventName, JSON.stringify(eventParams));
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
exports.FastVueMultiWatcher = FastVueMultiWatcher;
|
@@ -11,6 +11,7 @@ import { FastVueMultiElement } from "./other/FastVueMultiElement";
|
|
11
11
|
import { FastVueMultiWindow } from "./other/FastVueMultiWindow";
|
12
12
|
import { FastVueMultiFile } from "./other/FastVueMultiFile";
|
13
13
|
import { FastVueMultiBase64 } from "./other/FastVueMultiBase64";
|
14
|
+
import { FastVueMultiWatcher } from "./other/FastVueMultiWatcher";
|
14
15
|
/**
|
15
16
|
* FastBaseApp 手机APP功能工具类
|
16
17
|
*/
|
@@ -71,4 +72,8 @@ export declare class FastVueMultiTool {
|
|
71
72
|
* base64相关操作
|
72
73
|
*/
|
73
74
|
static Base64: typeof FastVueMultiBase64;
|
75
|
+
/**
|
76
|
+
* 监听者
|
77
|
+
*/
|
78
|
+
static Watcher: typeof FastVueMultiWatcher;
|
74
79
|
}
|
@@ -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", "./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) {
|
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", "./other/FastVueMultiWatcher"], 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, FastVueMultiWatcher_1) {
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
exports.FastVueMultiTool = void 0;
|
@@ -65,6 +65,10 @@ define(["require", "exports", "tslib", "lodash", "./http/FastVueMultiHttp", "./o
|
|
65
65
|
* base64相关操作
|
66
66
|
*/
|
67
67
|
FastVueMultiTool.Base64 = FastVueMultiBase64_1.FastVueMultiBase64;
|
68
|
+
/**
|
69
|
+
* 监听者
|
70
|
+
*/
|
71
|
+
FastVueMultiTool.Watcher = FastVueMultiWatcher_1.FastVueMultiWatcher;
|
68
72
|
return FastVueMultiTool;
|
69
73
|
}());
|
70
74
|
exports.FastVueMultiTool = FastVueMultiTool;
|
@@ -6,10 +6,10 @@ export declare class FastVueMultiFile {
|
|
6
6
|
static showUploadImage(multi: boolean): Promise<any>;
|
7
7
|
/**
|
8
8
|
* 将base64转为file对象
|
9
|
-
* @param
|
9
|
+
* @param content base64内容
|
10
10
|
* @param fileName 文件名
|
11
11
|
*/
|
12
|
-
static base64ToFile(
|
12
|
+
static base64ToFile(content: string, fileName: string): Promise<File>;
|
13
13
|
/**
|
14
14
|
* 将file对象转为base64
|
15
15
|
* @param file
|
@@ -1,4 +1,4 @@
|
|
1
|
-
define(["require", "exports", "tslib"
|
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;
|
@@ -53,17 +53,26 @@ define(["require", "exports", "tslib", "file64"], function (require, exports, ts
|
|
53
53
|
};
|
54
54
|
/**
|
55
55
|
* 将base64转为file对象
|
56
|
-
* @param
|
56
|
+
* @param content base64内容
|
57
57
|
* @param fileName 文件名
|
58
58
|
*/
|
59
|
-
FastVueMultiFile.base64ToFile = function (
|
60
|
-
return
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
59
|
+
FastVueMultiFile.base64ToFile = function (content, fileName) {
|
60
|
+
return new Promise(function (resolved, rejected) {
|
61
|
+
// 将base64的数据部分提取出来
|
62
|
+
var parts = content.split(';base64,');
|
63
|
+
var contentType = parts[0].split(':')[1];
|
64
|
+
var raw = window.atob(parts[1]);
|
65
|
+
// 将原始数据转换为Uint8Array
|
66
|
+
var rawLength = raw.length;
|
67
|
+
var uInt8Array = new Uint8Array(rawLength);
|
68
|
+
for (var i = 0; i < rawLength; ++i) {
|
69
|
+
uInt8Array[i] = raw.charCodeAt(i);
|
70
|
+
}
|
71
|
+
// 使用Blob对象创建File对象
|
72
|
+
var blob = new Blob([uInt8Array], { type: contentType });
|
73
|
+
blob.lastModifiedDate = new Date();
|
74
|
+
blob.name = fileName;
|
75
|
+
resolved(new File([blob], fileName, { type: contentType }));
|
67
76
|
});
|
68
77
|
};
|
69
78
|
/**
|
@@ -73,10 +82,14 @@ define(["require", "exports", "tslib", "file64"], function (require, exports, ts
|
|
73
82
|
FastVueMultiFile.fileToBase64 = function (file) {
|
74
83
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
75
84
|
return tslib_1.__generator(this, function (_a) {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
85
|
+
return [2 /*return*/, new Promise(function (resolved, rejected) {
|
86
|
+
var fileReader = new FileReader();
|
87
|
+
fileReader.onload = function (readEvent) {
|
88
|
+
var base64 = readEvent.target.result;
|
89
|
+
resolved(base64);
|
90
|
+
};
|
91
|
+
fileReader.readAsDataURL(file);
|
92
|
+
})];
|
80
93
|
});
|
81
94
|
});
|
82
95
|
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* 事件监听器
|
3
|
+
*/
|
4
|
+
export declare class FastVueMultiWatcher {
|
5
|
+
private static getWatcherConfig;
|
6
|
+
private static getWatcherTimer;
|
7
|
+
private static setWatcherTimer;
|
8
|
+
private static stopWatcherTimer;
|
9
|
+
private static startTimer;
|
10
|
+
/**
|
11
|
+
* 启动一个事件监听器
|
12
|
+
* @param eventName 事件名称 string|array
|
13
|
+
* @param callback 事件触发的回调 function(eventName,eventParams){}
|
14
|
+
*/
|
15
|
+
static startWatcher(eventName: any, callback: any): void;
|
16
|
+
/**
|
17
|
+
* 通知事件监听者
|
18
|
+
* @param eventName 事件名称 string|array
|
19
|
+
* @param eventParams 携带参数 any
|
20
|
+
*/
|
21
|
+
static notifyWatcher(eventName: any, eventParams?: any): void;
|
22
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
define(["require", "exports", "tslib", "lodash", "js-cookie"], function (require, exports, tslib_1, lodash_1, js_cookie_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.FastVueMultiWatcher = void 0;
|
5
|
+
lodash_1 = tslib_1.__importDefault(lodash_1);
|
6
|
+
js_cookie_1 = tslib_1.__importDefault(js_cookie_1);
|
7
|
+
/**
|
8
|
+
* 事件监听器
|
9
|
+
*/
|
10
|
+
var FastVueMultiWatcher = /** @class */ (function () {
|
11
|
+
function FastVueMultiWatcher() {
|
12
|
+
}
|
13
|
+
FastVueMultiWatcher.getWatcherConfig = function () {
|
14
|
+
if (!window["__watcherConfig"]) {
|
15
|
+
window["__watcherConfig"] = {};
|
16
|
+
}
|
17
|
+
return window["__watcherConfig"];
|
18
|
+
};
|
19
|
+
FastVueMultiWatcher.getWatcherTimer = function () {
|
20
|
+
return window["__watcherTimer"];
|
21
|
+
};
|
22
|
+
FastVueMultiWatcher.setWatcherTimer = function (timer) {
|
23
|
+
window["__watcherTimer"] = timer;
|
24
|
+
};
|
25
|
+
FastVueMultiWatcher.stopWatcherTimer = function () {
|
26
|
+
if (this.getWatcherTimer()) {
|
27
|
+
clearTimeout(this.getWatcherTimer());
|
28
|
+
}
|
29
|
+
};
|
30
|
+
FastVueMultiWatcher.startTimer = function () {
|
31
|
+
var _this = this;
|
32
|
+
this.stopWatcherTimer();
|
33
|
+
this.setWatcherTimer(setTimeout(function () {
|
34
|
+
for (var eventName in _this.getWatcherConfig()) {
|
35
|
+
var watchValue = js_cookie_1.default.get("EVENT@" + eventName);
|
36
|
+
var config = _this.getWatcherConfig()[eventName];
|
37
|
+
if (watchValue !== null && watchValue !== undefined && watchValue !== "null" && watchValue !== "undefined") {
|
38
|
+
var timestamp = parseInt(watchValue);
|
39
|
+
if (isNaN(timestamp)) {
|
40
|
+
continue;
|
41
|
+
}
|
42
|
+
if (config.timestamp < timestamp) {
|
43
|
+
var params = js_cookie_1.default.get("EVENT@PARMAS@" + eventName);
|
44
|
+
if (params) {
|
45
|
+
params = JSON.parse(params);
|
46
|
+
}
|
47
|
+
config.timestamp = timestamp;
|
48
|
+
config.callback(eventName, params);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
_this.startTimer();
|
53
|
+
}, 500));
|
54
|
+
};
|
55
|
+
/**
|
56
|
+
* 启动一个事件监听器
|
57
|
+
* @param eventName 事件名称 string|array
|
58
|
+
* @param callback 事件触发的回调 function(eventName,eventParams){}
|
59
|
+
*/
|
60
|
+
FastVueMultiWatcher.startWatcher = function (eventName, callback) {
|
61
|
+
if (!window["__watchCookieTimestamp"]) {
|
62
|
+
window["__watchCookieTimestamp"] = {};
|
63
|
+
}
|
64
|
+
if (!callback || lodash_1.default.isEmpty(eventName)) {
|
65
|
+
//未携带回调函数的监听者,认为是无效监听
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
if (lodash_1.default.isArray(eventName)) {
|
69
|
+
for (var _i = 0, eventName_1 = eventName; _i < eventName_1.length; _i++) {
|
70
|
+
var cookieNameElement = eventName_1[_i];
|
71
|
+
this.getWatcherConfig()[cookieNameElement] = {
|
72
|
+
timestamp: new Date().getTime(),
|
73
|
+
callback: callback,
|
74
|
+
};
|
75
|
+
}
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
this.getWatcherConfig()[eventName] = {
|
79
|
+
timestamp: new Date().getTime(),
|
80
|
+
callback: callback,
|
81
|
+
};
|
82
|
+
}
|
83
|
+
this.startTimer();
|
84
|
+
};
|
85
|
+
/**
|
86
|
+
* 通知事件监听者
|
87
|
+
* @param eventName 事件名称 string|array
|
88
|
+
* @param eventParams 携带参数 any
|
89
|
+
*/
|
90
|
+
FastVueMultiWatcher.notifyWatcher = function (eventName, eventParams) {
|
91
|
+
if (lodash_1.default.isEmpty(eventName)) {
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
if (lodash_1.default.isArray(eventName)) {
|
95
|
+
for (var _i = 0, eventName_2 = eventName; _i < eventName_2.length; _i++) {
|
96
|
+
var cookieNameElement = eventName_2[_i];
|
97
|
+
js_cookie_1.default.set("EVENT@" + cookieNameElement, (new Date().getTime()).toString());
|
98
|
+
if (eventParams) {
|
99
|
+
js_cookie_1.default.set("EVENT@PARMAS@" + cookieNameElement, JSON.stringify(eventParams));
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
js_cookie_1.default.set("EVENT@" + eventName, (new Date().getTime()).toString());
|
105
|
+
if (eventParams) {
|
106
|
+
js_cookie_1.default.set("EVENT@PARMAS@" + eventName, JSON.stringify(eventParams));
|
107
|
+
}
|
108
|
+
}
|
109
|
+
};
|
110
|
+
return FastVueMultiWatcher;
|
111
|
+
}());
|
112
|
+
exports.FastVueMultiWatcher = FastVueMultiWatcher;
|
113
|
+
});
|