xctc-utils 1.6.68 → 1.6.69
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/canvas/index.js +202 -216
- package/dist/crypto/index.js +16 -16
- package/dist/event/changed.js +13 -13
- package/dist/event/drop.js +6 -6
- package/dist/event/index.js +5 -5
- package/dist/event/mouse-down.js +6 -6
- package/dist/event/mouse-move.js +6 -6
- package/dist/event/mouse-up.js +8 -8
- package/dist/event/mouse-wheel.js +2 -2
- package/dist/format/index.js +1 -1
- package/dist/handle/create.js +84 -60
- package/dist/handle/index.js +9 -9
- package/dist/handle/query.js +22 -22
- package/dist/handle/register.js +3 -3
- package/dist/handle/update.js +17 -17
- package/dist/iframe/index.js +30 -30
- package/dist/index.js +29 -24
- package/dist/is/has.js +2 -2
- package/dist/is/index.js +4 -4
- package/dist/modal/index.js +32 -23
- package/dist/params/index.js +59 -59
- package/dist/storage/index.js +4 -4
- package/dist/test.js +3 -3
- package/dist/time/index.js +32 -32
- package/dist/update/index.d.ts +1 -0
- package/dist/update/index.js +48 -0
- package/dist/utils.js +29 -29
- package/dist/weixin/index.d.ts +1 -0
- package/dist/weixin/index.js +109 -106
- package/package.json +1 -1
- package/tsconfig.json +1 -1
package/dist/handle/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SetCanvasBaseConfigFn = exports.RegisterZoomHandleFn = void 0;
|
|
4
|
-
|
|
4
|
+
const is_1 = require("../is");
|
|
5
5
|
function RegisterZoomHandleFn(options) {
|
|
6
6
|
var _a;
|
|
7
7
|
if (!(0, is_1.isObject)(options)) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
const _ = this;
|
|
11
11
|
if (!_.canvasDataSource) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
// 滚轮,向上滚一下是 -100,向下滚一下是 100
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const delta = options.e.deltaY;
|
|
16
|
+
let zoom = _.canvasDataSource.getZoom(); // 获取画布当前缩放值
|
|
17
17
|
console.log("registerZoomHandleFn--zoom=", zoom);
|
|
18
18
|
zoom += 0.001 * delta;
|
|
19
19
|
if (zoom > 10)
|
|
@@ -27,7 +27,7 @@ function RegisterZoomHandleFn(options) {
|
|
|
27
27
|
y: options.e.offsetY
|
|
28
28
|
}, zoom // 传入修改后的缩放级别
|
|
29
29
|
);
|
|
30
|
-
|
|
30
|
+
const fn = ((_a = _.callBackEventConfig) === null || _a === void 0 ? void 0 : _a.zoomListenEvent) || "";
|
|
31
31
|
if (fn && fn instanceof Function) {
|
|
32
32
|
fn(zoom, _.zoomDataSource);
|
|
33
33
|
}
|
|
@@ -35,17 +35,17 @@ function RegisterZoomHandleFn(options) {
|
|
|
35
35
|
exports.RegisterZoomHandleFn = RegisterZoomHandleFn;
|
|
36
36
|
function SetCanvasBaseConfigFn(zoom) {
|
|
37
37
|
var _a;
|
|
38
|
-
|
|
38
|
+
const _ = this;
|
|
39
39
|
if (!_.canvasDataSource) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
if (!zoom) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
let x = 0;
|
|
46
|
+
let y = 0;
|
|
47
47
|
if ((_a = _.mouseWheelPointerDataSource) === null || _a === void 0 ? void 0 : _a.e) {
|
|
48
|
-
|
|
48
|
+
const { offsetX = 0, offsetY = 0 } = _.mouseWheelPointerDataSource.e;
|
|
49
49
|
x = offsetX;
|
|
50
50
|
y = offsetY;
|
|
51
51
|
}
|
package/dist/handle/query.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QuerySelectionElementsFn = exports.QuerySelectionAllElementsFn = exports.QueryElementSizeFn = exports.QueryCanvasActionDataFn = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const is_1 = require("../is");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
6
|
function QueryCanvasActionDataFn() {
|
|
7
7
|
var _a, _b, _c, _d, _e;
|
|
8
|
-
|
|
8
|
+
const _ = this;
|
|
9
9
|
if (!_.canvasDataSource) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
const zoom = _.canvasDataSource.getZoom();
|
|
13
13
|
console.log("getCanvasActionDataFn--zoom=", zoom);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
let x = 0;
|
|
15
|
+
let y = 0;
|
|
16
|
+
let left = 0;
|
|
17
|
+
let top = 0;
|
|
18
18
|
if ((_a = _.mouseWheelPointerDataSource) === null || _a === void 0 ? void 0 : _a.e) {
|
|
19
|
-
|
|
19
|
+
const { offsetX = 0, offsetY = 0 } = _.mouseWheelPointerDataSource.e;
|
|
20
20
|
x = offsetX;
|
|
21
21
|
y = offsetY;
|
|
22
22
|
left = ((_c = (_b = _.mouseWheelPointerDataSource) === null || _b === void 0 ? void 0 : _b.absolutePointer) === null || _c === void 0 ? void 0 : _c.x) || 0;
|
|
@@ -35,19 +35,19 @@ function QueryElementSizeFn(id) {
|
|
|
35
35
|
if (!(0, is_1.isString)(id)) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const _ = this;
|
|
39
|
+
const box = (0, utils_1.getDomFn)(id);
|
|
40
40
|
if (!box) {
|
|
41
41
|
console.error("canvas外层必须套一层id=canvasContainer的DOM元素");
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const height = box.clientHeight;
|
|
44
|
+
const width = box.clientWidth;
|
|
45
45
|
console.log("canvasContainer=", box);
|
|
46
46
|
console.log("box-height=", height);
|
|
47
47
|
console.log("box-width=", width);
|
|
48
48
|
return {
|
|
49
|
-
height
|
|
50
|
-
width
|
|
49
|
+
height,
|
|
50
|
+
width
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
exports.QueryElementSizeFn = QueryElementSizeFn;
|
|
@@ -55,16 +55,16 @@ function QuerySelectionAllElementsFn(options) {
|
|
|
55
55
|
if (!(0, is_1.isObject)(options)) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
const _ = this;
|
|
59
59
|
if (!_.canvasDataSource) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
const dataList = [];
|
|
63
|
+
const selection = _.canvasSelectionElementsDataSource || [];
|
|
64
64
|
// 检查哪些图标在选择框内
|
|
65
65
|
_.canvasDataSource.forEachObject(function (obj) {
|
|
66
|
-
|
|
67
|
-
selection.map(
|
|
66
|
+
let isTarget = false;
|
|
67
|
+
selection.map((item) => {
|
|
68
68
|
if (obj.intersectsWithObject(item)) {
|
|
69
69
|
isTarget = true;
|
|
70
70
|
}
|
|
@@ -80,11 +80,11 @@ function QuerySelectionElementsFn(item) {
|
|
|
80
80
|
if (!(0, is_1.isObject)(item)) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
const _ = this;
|
|
84
84
|
if (!_.canvasDataSource) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
const dataList = [];
|
|
88
88
|
// 检查哪些图标在选择框内
|
|
89
89
|
_.canvasDataSource.forEachObject(function (obj) {
|
|
90
90
|
if (item && obj.intersectsWithObject(item) && (obj === null || obj === void 0 ? void 0 : obj.elementKey) == "data") {
|
package/dist/handle/register.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RegisterCanvasZoomChangeEventFn = exports.RegisterCanvasEventFn = void 0;
|
|
4
4
|
// 注册回调事件--页面生成画布实例的时候,调用该函数
|
|
5
5
|
function RegisterCanvasEventFn(config) {
|
|
6
|
-
|
|
6
|
+
const _ = this;
|
|
7
7
|
console.log("canvasDataSource--", _.canvasDataSource);
|
|
8
8
|
if (!_.canvasDataSource) {
|
|
9
9
|
return;
|
|
@@ -14,8 +14,8 @@ function RegisterCanvasEventFn(config) {
|
|
|
14
14
|
}
|
|
15
15
|
exports.RegisterCanvasEventFn = RegisterCanvasEventFn;
|
|
16
16
|
function RegisterCanvasZoomChangeEventFn() {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const _ = this;
|
|
18
|
+
const zoom = _.canvasDataSource.getZoom();
|
|
19
19
|
return zoom;
|
|
20
20
|
}
|
|
21
21
|
exports.RegisterCanvasZoomChangeEventFn = RegisterCanvasZoomChangeEventFn;
|
package/dist/handle/update.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoveAllElementFn = exports.RemoveElementFn = exports.HiddenRightClickMenuFn = exports.CreateSelectionRectFinishFn = exports.UpdateSelectionRectFn = exports.RemoveAllSelectionRectFn = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const is_1 = require("../is");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
6
|
function RemoveAllSelectionRectFn() {
|
|
7
|
-
|
|
7
|
+
const _ = this;
|
|
8
8
|
if (!_.canvasDataSource) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
@@ -17,26 +17,26 @@ function UpdateSelectionRectFn(options) {
|
|
|
17
17
|
if (!(0, is_1.isObject)(options)) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
const _ = this;
|
|
21
21
|
if (!_.canvasDataSource) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
if (_.createSelectionRectDataSource) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
let pointer = _.canvasDataSource.getPointer(options.e);
|
|
26
|
+
let width = pointer.x - ((_a = _.mousePointerDataSource) === null || _a === void 0 ? void 0 : _a.x);
|
|
27
|
+
let height = pointer.y - ((_b = _.mousePointerDataSource) === null || _b === void 0 ? void 0 : _b.y);
|
|
28
28
|
_.createSelectionRectDataSource.set({ width: Math.abs(width), height: Math.abs(height) });
|
|
29
29
|
// _.createSelectionRectDataSource.setCoords(); // 更新控制点坐标
|
|
30
30
|
_.canvasDataSource.requestRenderAll();
|
|
31
31
|
_.createSelectionStatus = 3;
|
|
32
|
-
setTimeout(
|
|
32
|
+
setTimeout(() => {
|
|
33
33
|
_.createSelectionStatus = 0;
|
|
34
34
|
}, 0);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
exports.UpdateSelectionRectFn = UpdateSelectionRectFn;
|
|
38
38
|
function CreateSelectionRectFinishFn() {
|
|
39
|
-
|
|
39
|
+
const _ = this;
|
|
40
40
|
if (!_.canvasDataSource) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
@@ -53,9 +53,9 @@ function CreateSelectionRectFinishFn() {
|
|
|
53
53
|
}
|
|
54
54
|
exports.CreateSelectionRectFinishFn = CreateSelectionRectFinishFn;
|
|
55
55
|
function HiddenRightClickMenuFn() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const _ = this;
|
|
57
|
+
const canvasContainer = (0, utils_1.getDomFn)("canvasContainer");
|
|
58
|
+
const menuBox = (0, utils_1.getDomFn)("menuBox");
|
|
59
59
|
if (canvasContainer && menuBox) {
|
|
60
60
|
canvasContainer === null || canvasContainer === void 0 ? void 0 : canvasContainer.removeChild(menuBox);
|
|
61
61
|
}
|
|
@@ -65,11 +65,11 @@ function RemoveElementFn(id) {
|
|
|
65
65
|
if (!(0, is_1.isString)(id)) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
const _ = this;
|
|
69
69
|
if (!_.canvasDataSource) {
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
const list = _.canvasCreateElementsDataSource;
|
|
73
73
|
var targetElement = list.find(function (obj) {
|
|
74
74
|
return obj.id === id;
|
|
75
75
|
});
|
|
@@ -80,11 +80,11 @@ function RemoveElementFn(id) {
|
|
|
80
80
|
}
|
|
81
81
|
exports.RemoveElementFn = RemoveElementFn;
|
|
82
82
|
function RemoveAllElementFn() {
|
|
83
|
-
|
|
83
|
+
const _ = this;
|
|
84
84
|
if (!_.canvasDataSource) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
const list = _.canvasCreateElementsDataSource;
|
|
88
88
|
_.createSelectionRectDataSource = [];
|
|
89
89
|
_.canvasCreateElementsDataSource = [];
|
|
90
90
|
_.createSelectionRectDataSource = [];
|
|
@@ -92,7 +92,7 @@ function RemoveAllElementFn() {
|
|
|
92
92
|
_.canvasSelectionElementsDataSource = [];
|
|
93
93
|
_.canvasCreateTargetElementsDataSource = [];
|
|
94
94
|
_.defaultCreateDataList = [];
|
|
95
|
-
list.map(
|
|
95
|
+
list.map((item) => {
|
|
96
96
|
if (item) {
|
|
97
97
|
_.canvasDataSource.remove(item);
|
|
98
98
|
}
|
package/dist/iframe/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.iframeSendToParentData = exports.updateParentToIframeData = exports.updateIframeToParentData = exports.parentSendIframeData = exports.initParentDataToIframe = exports.$iframe = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const is_1 = require("../is");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const storage_1 = require("../storage");
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
9
|
* @param id
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const win = window;
|
|
13
|
+
const $iframe = (id) => {
|
|
14
14
|
if (!id) {
|
|
15
15
|
console.error("请传入 iframe id属性值!");
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
let iframe = (0, utils_1.getDomFn)(id) || {};
|
|
19
19
|
if ((iframe === null || iframe === void 0 ? void 0 : iframe.tagName) === 'IFRAME') {
|
|
20
20
|
return iframe;
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
|
-
console.error(
|
|
23
|
+
console.error(`未查询到id=${id}的iframe标签`);
|
|
24
24
|
}
|
|
25
25
|
return;
|
|
26
26
|
};
|
|
@@ -33,7 +33,7 @@ exports.$iframe = $iframe;
|
|
|
33
33
|
* @param keys 微信分享链接存储的键,默认是 urlParamsData
|
|
34
34
|
* @returns
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
const initParentDataToIframe = (id, url, keys) => {
|
|
37
37
|
var _a;
|
|
38
38
|
if (!id) {
|
|
39
39
|
console.error("请传入 iframe id属性值!");
|
|
@@ -46,8 +46,8 @@ var initParentDataToIframe = function (id, url, keys) {
|
|
|
46
46
|
if (!keys) {
|
|
47
47
|
keys = "urlParamsData";
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const stateData = (0, storage_1.getSessionStorage)(keys) || {};
|
|
50
|
+
let data = {};
|
|
51
51
|
if ((_a = stateData === null || stateData === void 0 ? void 0 : stateData.state) === null || _a === void 0 ? void 0 : _a.data) {
|
|
52
52
|
data = stateData.state.data || {};
|
|
53
53
|
}
|
|
@@ -55,7 +55,7 @@ var initParentDataToIframe = function (id, url, keys) {
|
|
|
55
55
|
};
|
|
56
56
|
exports.initParentDataToIframe = initParentDataToIframe;
|
|
57
57
|
function sendDataFormat(data, msg) {
|
|
58
|
-
|
|
58
|
+
let sendData = {
|
|
59
59
|
type: "data",
|
|
60
60
|
data: {},
|
|
61
61
|
msg: msg
|
|
@@ -79,20 +79,20 @@ function onloadIframe(id, url, data) {
|
|
|
79
79
|
alert("onloadIframe:请传入iframe元素的src属性值");
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const msg = `父页面向子页面${url}传递参数`;
|
|
83
|
+
const sendData = sendDataFormat(data, msg);
|
|
84
|
+
const iframe = (0, exports.$iframe)(id);
|
|
85
85
|
iframe.src = url;
|
|
86
86
|
if (iframe.hasOwnProperty("attachEvent")) {
|
|
87
87
|
iframe.attachEvent('onload', function () {
|
|
88
|
-
setTimeout(
|
|
88
|
+
setTimeout(() => {
|
|
89
89
|
iframe.contentWindow.postMessage(sendData, iframe.src);
|
|
90
90
|
}, 0);
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
iframe.onload = function () {
|
|
95
|
-
setTimeout(
|
|
95
|
+
setTimeout(() => {
|
|
96
96
|
iframe.contentWindow.postMessage(sendData, iframe.src);
|
|
97
97
|
}, 0);
|
|
98
98
|
};
|
|
@@ -106,7 +106,7 @@ function onloadIframe(id, url, data) {
|
|
|
106
106
|
* @param duration 父页面向子页面传输数据时,如果和initParentDataToIframe函数同时调用,则需要加入定时器传递参数,子页面才能获取到数据
|
|
107
107
|
* @returns
|
|
108
108
|
*/
|
|
109
|
-
|
|
109
|
+
const parentSendIframeData = (id, data, url, duration) => {
|
|
110
110
|
if (!id) {
|
|
111
111
|
console.error("请传入iframe元素的id属性值");
|
|
112
112
|
return;
|
|
@@ -117,7 +117,7 @@ var parentSendIframeData = function (id, data, url, duration) {
|
|
|
117
117
|
}
|
|
118
118
|
if (!duration)
|
|
119
119
|
duration = 100;
|
|
120
|
-
|
|
120
|
+
const iframe = (0, exports.$iframe)(id);
|
|
121
121
|
if (!iframe['src']) {
|
|
122
122
|
if (!url) {
|
|
123
123
|
console.error("请传入iframe src属性值");
|
|
@@ -128,9 +128,9 @@ var parentSendIframeData = function (id, data, url, duration) {
|
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
setTimeout(
|
|
131
|
+
const msg = `父页面向子页面${iframe.src}传递参数`;
|
|
132
|
+
const sendData = sendDataFormat(data, msg);
|
|
133
|
+
setTimeout(() => {
|
|
134
134
|
iframe.contentWindow.postMessage(sendData, iframe.src);
|
|
135
135
|
}, duration);
|
|
136
136
|
};
|
|
@@ -139,10 +139,10 @@ exports.parentSendIframeData = parentSendIframeData;
|
|
|
139
139
|
* 主应用 获取到 子应用Iframe传递的数据
|
|
140
140
|
* @param cb
|
|
141
141
|
*/
|
|
142
|
-
|
|
142
|
+
const updateIframeToParentData = (cb) => {
|
|
143
143
|
window.addEventListener('message', function (event) {
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
const data = (event === null || event === void 0 ? void 0 : event.data) || {};
|
|
145
|
+
const messageData = (0, utils_1.isJson)(data) || "";
|
|
146
146
|
if (typeof cb === "function" && (messageData === null || messageData === void 0 ? void 0 : messageData.type) == "data") {
|
|
147
147
|
cb(messageData === null || messageData === void 0 ? void 0 : messageData.data);
|
|
148
148
|
}
|
|
@@ -153,10 +153,10 @@ exports.updateIframeToParentData = updateIframeToParentData;
|
|
|
153
153
|
* 子应用 获取到 主应用 传递的数据
|
|
154
154
|
* @param cb
|
|
155
155
|
*/
|
|
156
|
-
|
|
156
|
+
const updateParentToIframeData = (cb) => {
|
|
157
157
|
window.addEventListener('message', function (event) {
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
let data = event.data;
|
|
159
|
+
const mainData = (0, utils_1.isJson)(data);
|
|
160
160
|
if (typeof cb === "function") {
|
|
161
161
|
cb(mainData);
|
|
162
162
|
}
|
|
@@ -169,13 +169,13 @@ exports.updateParentToIframeData = updateParentToIframeData;
|
|
|
169
169
|
* @param url 父页面地址
|
|
170
170
|
* @returns
|
|
171
171
|
*/
|
|
172
|
-
|
|
172
|
+
const iframeSendToParentData = (data, url) => {
|
|
173
173
|
if (!url) {
|
|
174
174
|
console.error("必须传入父页面的地址!");
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
const msg = `子页面向父页面${url}传递参数`;
|
|
178
|
+
const sendData = sendDataFormat(data, msg);
|
|
179
179
|
window.parent.postMessage(sendData, url);
|
|
180
180
|
};
|
|
181
181
|
exports.iframeSendToParentData = iframeSendToParentData;
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -37,18 +26,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
27
|
};
|
|
39
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
29
|
+
const storage = __importStar(require("./storage"));
|
|
30
|
+
const utils = __importStar(require("./utils"));
|
|
31
|
+
const crypto = __importStar(require("./crypto"));
|
|
32
|
+
const weixin = __importStar(require("./weixin"));
|
|
33
|
+
const time = __importStar(require("./time"));
|
|
34
|
+
const format = __importStar(require("./format"));
|
|
35
|
+
const isType = __importStar(require("./is"));
|
|
36
|
+
const modal = __importStar(require("./modal"));
|
|
37
|
+
const params = __importStar(require("./params"));
|
|
38
|
+
const iframe = __importStar(require("./iframe"));
|
|
39
|
+
const update = __importStar(require("./update"));
|
|
40
|
+
const canvas_1 = __importDefault(require("./canvas"));
|
|
41
|
+
const obj = {
|
|
42
|
+
...storage,
|
|
43
|
+
...utils,
|
|
44
|
+
weixin: { ...weixin },
|
|
45
|
+
crypto: { ...crypto },
|
|
46
|
+
date: { ...time },
|
|
47
|
+
format: { ...format },
|
|
48
|
+
type: { ...isType },
|
|
49
|
+
modal: { ...modal },
|
|
50
|
+
params: { ...params },
|
|
51
|
+
iframe: { ...iframe },
|
|
52
|
+
update: {
|
|
53
|
+
...update,
|
|
54
|
+
},
|
|
55
|
+
canvas: {
|
|
52
56
|
CanvasHooks: canvas_1.default,
|
|
53
|
-
}
|
|
57
|
+
},
|
|
58
|
+
};
|
|
54
59
|
exports.default = obj;
|
package/dist/is/has.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasProperty = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const is_1 = require("../is");
|
|
5
|
+
const hasProperty = (obj, attr) => {
|
|
6
6
|
if (!obj || !attr) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
package/dist/is/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isWindow = exports.isArray = exports.isBoolean = exports.isString = exports.isNumber = exports.isDate = exports.isObject = exports.isFunction = exports.is = void 0;
|
|
4
|
-
|
|
4
|
+
const toString = Object.prototype.toString;
|
|
5
5
|
/**
|
|
6
6
|
* @description: 判断传入的值是否为指定类型
|
|
7
7
|
*/
|
|
8
8
|
function is(val, type) {
|
|
9
9
|
if (!type)
|
|
10
10
|
return false;
|
|
11
|
-
return toString.call(val) ===
|
|
11
|
+
return toString.call(val) === `[object ${type}]`;
|
|
12
12
|
}
|
|
13
13
|
exports.is = is;
|
|
14
14
|
/**
|
|
@@ -23,7 +23,7 @@ exports.isFunction = isFunction;
|
|
|
23
23
|
/**
|
|
24
24
|
* @description: 是否为对象
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
const isObject = (val) => {
|
|
27
27
|
return val !== null && is(val, "Object");
|
|
28
28
|
};
|
|
29
29
|
exports.isObject = isObject;
|
|
@@ -67,7 +67,7 @@ exports.isArray = isArray;
|
|
|
67
67
|
/**
|
|
68
68
|
* @description: 是否为浏览器
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
const isWindow = (val) => {
|
|
71
71
|
return typeof window !== "undefined" && is(val, "Window");
|
|
72
72
|
};
|
|
73
73
|
exports.isWindow = isWindow;
|
package/dist/modal/index.js
CHANGED
|
@@ -5,31 +5,31 @@ exports.destroyMessageModule = exports.createMessageModule = exports.destroySpin
|
|
|
5
5
|
function getDomFn(id) {
|
|
6
6
|
if (!id)
|
|
7
7
|
return false;
|
|
8
|
-
|
|
8
|
+
let dom = document.getElementById(id);
|
|
9
9
|
if (id && dom instanceof HTMLElement) {
|
|
10
10
|
return dom;
|
|
11
11
|
}
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const createSpinModule = () => {
|
|
15
|
+
let parentBox = toggleDomModule("serveSpinModule", "block");
|
|
16
|
+
let containerBox = "";
|
|
17
|
+
let canvasBox = "";
|
|
18
|
+
let spinnerFourBox = "";
|
|
19
19
|
if (!parentBox) {
|
|
20
20
|
styleModule();
|
|
21
21
|
parentBox = createDom("div");
|
|
22
22
|
containerBox = createDom("div");
|
|
23
23
|
canvasBox = createDom("div");
|
|
24
24
|
spinnerFourBox = createDom("div");
|
|
25
|
-
|
|
25
|
+
const parentBoxStyle = `width:100vw!important; height:100vh!important;background-color:rgba(0,0,0,0.5);z-index:100000000;position: fixed;top:0;left:0;text-align:center;`;
|
|
26
26
|
parentBox.setAttribute("style", parentBoxStyle);
|
|
27
27
|
parentBox.id = 'serveSpinModule';
|
|
28
|
-
|
|
28
|
+
const containerBoxStyle = `display: inline-block;padding-top:23%;`;
|
|
29
29
|
containerBox.setAttribute("style", containerBoxStyle);
|
|
30
|
-
|
|
30
|
+
const canvasBoxStyle = `align-items: center;background: #eeeeee;border-radius: 50%;display: flex;justify-content: center;margin: 1em;width: 3em;height: 3em;`;
|
|
31
31
|
canvasBox.setAttribute("style", canvasBoxStyle);
|
|
32
|
-
|
|
32
|
+
const spinnerFourBoxStyle = `animation: spinnerFour 1s linear infinite;border: solid 7px transparent;border-top: solid 7px #4db6ac;border-radius: 100%;width: 3em;height: 3em;`;
|
|
33
33
|
spinnerFourBox.setAttribute("style", spinnerFourBoxStyle);
|
|
34
34
|
parentBox.appendChild(containerBox);
|
|
35
35
|
containerBox.appendChild(canvasBox);
|
|
@@ -38,38 +38,47 @@ var createSpinModule = function () {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
exports.createSpinModule = createSpinModule;
|
|
41
|
-
|
|
41
|
+
const styleModule = () => {
|
|
42
42
|
// 创建一个新的style元素
|
|
43
43
|
var styleElement = document.createElement('style');
|
|
44
44
|
// 将css字符串作为文本内容添加到style元素中
|
|
45
|
-
styleElement.textContent =
|
|
45
|
+
styleElement.textContent = `
|
|
46
|
+
@keyframes spinnerFour {
|
|
47
|
+
0% {
|
|
48
|
+
transform: rotate(0deg);
|
|
49
|
+
}
|
|
50
|
+
100% {
|
|
51
|
+
transform: rotate(360deg);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
46
55
|
// 将style元素添加到head部分,使得样式生效
|
|
47
56
|
document.head.appendChild(styleElement);
|
|
48
57
|
};
|
|
49
|
-
|
|
58
|
+
const destroySpinModule = () => {
|
|
50
59
|
toggleDomModule("serveSpinModule", "none");
|
|
51
60
|
removeDom("serveSpinModule");
|
|
52
61
|
};
|
|
53
62
|
exports.destroySpinModule = destroySpinModule;
|
|
54
|
-
|
|
63
|
+
const toggleDomModule = (id, val) => {
|
|
55
64
|
if (!id)
|
|
56
65
|
return;
|
|
57
|
-
|
|
66
|
+
const div = getDomFn(id) || "";
|
|
58
67
|
if (div) {
|
|
59
68
|
div.style.display = val;
|
|
60
69
|
}
|
|
61
70
|
return div;
|
|
62
71
|
};
|
|
63
|
-
|
|
72
|
+
const createDom = (dom) => {
|
|
64
73
|
if (!dom)
|
|
65
74
|
return;
|
|
66
75
|
return document.createElement(dom);
|
|
67
76
|
};
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
const createMessageModule = (title, duration, type) => {
|
|
78
|
+
let box = toggleDomModule("serveMessageModule", "block");
|
|
70
79
|
if (!type)
|
|
71
80
|
type = "success";
|
|
72
|
-
|
|
81
|
+
let containerBoxStyle = `display:inline-block;margin:auto;z-index:100000000;position: fixed;top:10px;left:50%;text-align:center;padding:6px 12px;box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);box-sizing: border-box;border-radius:4px;color:${type == "success" ? "#52c41a" : "#f50"} `;
|
|
73
82
|
box = createDom("div");
|
|
74
83
|
box.id = "serveMessageModule";
|
|
75
84
|
box.setAttribute("style", containerBoxStyle);
|
|
@@ -78,18 +87,18 @@ var createMessageModule = function (title, duration, type) {
|
|
|
78
87
|
if (!(typeof duration === "number")) {
|
|
79
88
|
duration = 1500;
|
|
80
89
|
}
|
|
81
|
-
setTimeout(
|
|
90
|
+
setTimeout(() => {
|
|
82
91
|
(0, exports.destroyMessageModule)();
|
|
83
92
|
}, duration);
|
|
84
93
|
};
|
|
85
94
|
exports.createMessageModule = createMessageModule;
|
|
86
|
-
|
|
95
|
+
const destroyMessageModule = () => {
|
|
87
96
|
toggleDomModule("serveMessageModule", "none");
|
|
88
97
|
removeDom("serveMessageModule");
|
|
89
98
|
};
|
|
90
99
|
exports.destroyMessageModule = destroyMessageModule;
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
const removeDom = (id) => {
|
|
101
|
+
const div = getDomFn(id);
|
|
93
102
|
if (div)
|
|
94
103
|
div.remove();
|
|
95
104
|
};
|