@widget-js/core 0.1.6 → 0.1.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/LICENSE +21 -21
- package/dist/cjs/api/ApiConstants.js +8 -8
- package/dist/cjs/api/AppApi.js +31 -31
- package/dist/cjs/api/BroadcastApi.js +20 -20
- package/dist/cjs/api/BrowserWindowApi.js +58 -24
- package/dist/cjs/api/Channel.js +12 -11
- package/dist/cjs/api/DialogApi.js +16 -0
- package/dist/cjs/api/ElectronApi.js +13 -13
- package/dist/cjs/api/NotificationApi.js +83 -83
- package/dist/cjs/api/WidgetApi.js +58 -49
- package/dist/cjs/index.js +36 -34
- package/dist/cjs/model/HostedMode.js +14 -0
- package/dist/cjs/model/Notification.js +15 -15
- package/dist/cjs/model/SocialInfo.js +10 -10
- package/dist/cjs/model/Widget.js +79 -79
- package/dist/cjs/model/WidgetData.js +16 -16
- package/dist/cjs/model/WidgetPackage.js +21 -6
- package/dist/cjs/model/WidgetParams.js +139 -144
- package/dist/cjs/model/event/BroadcastEvent.js +14 -14
- package/dist/cjs/model/event/WebSocketEvent.js +14 -14
- package/dist/cjs/model/interface/IHostedWidget.js +2 -0
- package/dist/cjs/repository/WidgetDataRepository.js +71 -71
- package/dist/cjs/router/encoding.js +144 -144
- package/dist/cjs/router/query.js +84 -84
- package/dist/cjs/utils/ElectronUtils.js +24 -24
- package/dist/esm/api/ApiConstants.js +4 -4
- package/dist/esm/api/AppApi.js +27 -27
- package/dist/esm/api/BroadcastApi.js +16 -16
- package/dist/esm/api/BrowserWindowApi.js +54 -20
- package/dist/esm/api/Channel.js +9 -8
- package/dist/esm/api/DialogApi.js +12 -0
- package/dist/esm/api/ElectronApi.js +9 -9
- package/dist/esm/api/NotificationApi.js +79 -79
- package/dist/esm/api/WidgetApi.js +54 -45
- package/dist/esm/index.js +20 -18
- package/dist/esm/model/HostedMode.js +11 -0
- package/dist/esm/model/Notification.js +11 -11
- package/dist/esm/model/SocialInfo.js +6 -6
- package/dist/esm/model/Widget.js +75 -75
- package/dist/esm/model/WidgetData.js +12 -12
- package/dist/esm/model/WidgetPackage.js +17 -2
- package/dist/esm/model/WidgetParams.js +135 -140
- package/dist/esm/model/event/BroadcastEvent.js +10 -10
- package/dist/esm/model/event/WebSocketEvent.js +10 -10
- package/dist/esm/model/interface/IHostedWidget.js +1 -0
- package/dist/esm/repository/WidgetDataRepository.js +64 -64
- package/dist/esm/router/encoding.js +135 -135
- package/dist/esm/router/query.js +79 -79
- package/dist/esm/utils/ElectronUtils.js +20 -20
- package/dist/types/api/ApiConstants.d.ts +4 -4
- package/dist/types/api/AppApi.d.ts +10 -10
- package/dist/types/api/BroadcastApi.d.ts +6 -6
- package/dist/types/api/BrowserWindowApi.d.ts +37 -10
- package/dist/types/api/Channel.d.ts +8 -7
- package/dist/types/api/DialogApi.d.ts +8 -0
- package/dist/types/api/ElectronApi.d.ts +4 -4
- package/dist/types/api/NotificationApi.d.ts +14 -14
- package/dist/types/api/WidgetApi.d.ts +30 -24
- package/dist/types/index.d.ts +20 -18
- package/dist/types/model/HostedMode.d.ts +10 -0
- package/dist/types/model/Notification.d.ts +16 -16
- package/dist/types/model/SocialInfo.d.ts +6 -6
- package/dist/types/model/Widget.d.ts +96 -85
- package/dist/types/model/WidgetData.d.ts +35 -35
- package/dist/types/model/WidgetPackage.d.ts +43 -41
- package/dist/types/model/WidgetParams.d.ts +60 -63
- package/dist/types/model/event/BroadcastEvent.d.ts +12 -12
- package/dist/types/model/event/WebSocketEvent.d.ts +8 -8
- package/dist/types/model/interface/IHostedWidget.d.ts +13 -0
- package/dist/types/repository/WidgetDataRepository.d.ts +26 -26
- package/dist/types/router/encoding.d.ts +62 -62
- package/dist/types/router/query.d.ts +53 -53
- package/dist/types/utils/ElectronUtils.d.ts +8 -8
- package/dist/umd/index.js +1 -1
- package/package.json +15 -16
package/dist/cjs/index.js
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./model/Widget"), exports);
|
|
18
|
-
__exportStar(require("./model/event/BroadcastEvent"), exports);
|
|
19
|
-
__exportStar(require("./model/event/WebSocketEvent"), exports);
|
|
20
|
-
__exportStar(require("./model/WidgetData"), exports);
|
|
21
|
-
__exportStar(require("./model/WidgetParams"), exports);
|
|
22
|
-
__exportStar(require("./model/Notification"), exports);
|
|
23
|
-
__exportStar(require("./model/
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./
|
|
26
|
-
__exportStar(require("./
|
|
27
|
-
__exportStar(require("./api/
|
|
28
|
-
__exportStar(require("./api/
|
|
29
|
-
__exportStar(require("./api/
|
|
30
|
-
__exportStar(require("./api/
|
|
31
|
-
__exportStar(require("./api/
|
|
32
|
-
__exportStar(require("./api/
|
|
33
|
-
__exportStar(require("./
|
|
34
|
-
__exportStar(require("./
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./model/Widget"), exports);
|
|
18
|
+
__exportStar(require("./model/event/BroadcastEvent"), exports);
|
|
19
|
+
__exportStar(require("./model/event/WebSocketEvent"), exports);
|
|
20
|
+
__exportStar(require("./model/WidgetData"), exports);
|
|
21
|
+
__exportStar(require("./model/WidgetParams"), exports);
|
|
22
|
+
__exportStar(require("./model/Notification"), exports);
|
|
23
|
+
__exportStar(require("./model/HostedMode"), exports);
|
|
24
|
+
__exportStar(require("./model/WidgetPackage"), exports);
|
|
25
|
+
__exportStar(require("./api/ElectronApi"), exports);
|
|
26
|
+
__exportStar(require("./repository/WidgetDataRepository"), exports);
|
|
27
|
+
__exportStar(require("./api/BrowserWindowApi"), exports);
|
|
28
|
+
__exportStar(require("./api/NotificationApi"), exports);
|
|
29
|
+
__exportStar(require("./api/Channel"), exports);
|
|
30
|
+
__exportStar(require("./api/WidgetApi"), exports);
|
|
31
|
+
__exportStar(require("./api/ApiConstants"), exports);
|
|
32
|
+
__exportStar(require("./api/BroadcastApi"), exports);
|
|
33
|
+
__exportStar(require("./api/AppApi"), exports);
|
|
34
|
+
__exportStar(require("./api/DialogApi"), exports);
|
|
35
|
+
__exportStar(require("./utils/ElectronUtils"), exports);
|
|
36
|
+
__exportStar(require("./router/query"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HostedMode = void 0;
|
|
4
|
+
var HostedMode;
|
|
5
|
+
(function (HostedMode) {
|
|
6
|
+
HostedMode[HostedMode["NORMAL"] = 1] = "NORMAL";
|
|
7
|
+
/**
|
|
8
|
+
* 悬浮窗
|
|
9
|
+
*/
|
|
10
|
+
HostedMode[HostedMode["OVERLAP"] = 16] = "OVERLAP";
|
|
11
|
+
HostedMode[HostedMode["WALLPAPER"] = 256] = "WALLPAPER";
|
|
12
|
+
HostedMode[HostedMode["SCREEN"] = 4096] = "SCREEN";
|
|
13
|
+
HostedMode[HostedMode["ALL"] = 4369] = "ALL";
|
|
14
|
+
})(HostedMode = exports.HostedMode || (exports.HostedMode = {}));
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Notification = void 0;
|
|
4
|
-
class Notification {
|
|
5
|
-
constructor(option) {
|
|
6
|
-
var _a, _b;
|
|
7
|
-
this.type = "message";
|
|
8
|
-
this.type = (_a = option.type) !== null && _a !== void 0 ? _a : "message";
|
|
9
|
-
this.title = option.title;
|
|
10
|
-
this.message = option.message;
|
|
11
|
-
this.targetTime = option.targetTime;
|
|
12
|
-
this.duration = (_b = option.duration) !== null && _b !== void 0 ? _b : 5000;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.Notification = Notification;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Notification = void 0;
|
|
4
|
+
class Notification {
|
|
5
|
+
constructor(option) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
this.type = "message";
|
|
8
|
+
this.type = (_a = option.type) !== null && _a !== void 0 ? _a : "message";
|
|
9
|
+
this.title = option.title;
|
|
10
|
+
this.message = option.message;
|
|
11
|
+
this.targetTime = option.targetTime;
|
|
12
|
+
this.duration = (_b = option.duration) !== null && _b !== void 0 ? _b : 5000;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.Notification = Notification;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SocialInfo = void 0;
|
|
4
|
-
class SocialInfo {
|
|
5
|
-
constructor(name, url) {
|
|
6
|
-
this.name = name;
|
|
7
|
-
this.content = url;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.SocialInfo = SocialInfo;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocialInfo = void 0;
|
|
4
|
+
class SocialInfo {
|
|
5
|
+
constructor(name, url) {
|
|
6
|
+
this.name = name;
|
|
7
|
+
this.content = url;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SocialInfo = SocialInfo;
|
package/dist/cjs/model/Widget.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WidgetKeyword = exports.Widget = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.Widget = Widget;
|
|
67
|
-
var WidgetKeyword;
|
|
68
|
-
(function (WidgetKeyword) {
|
|
69
|
-
WidgetKeyword["RECOMMEND"] = "recommend";
|
|
70
|
-
WidgetKeyword["TOOLS"] = "tools";
|
|
71
|
-
WidgetKeyword["EFFICIENCY"] = "efficiency";
|
|
72
|
-
WidgetKeyword["PICTURE"] = "picture";
|
|
73
|
-
WidgetKeyword["LIFE"] = "life";
|
|
74
|
-
WidgetKeyword["SHORTCUT"] = "shortcut";
|
|
75
|
-
WidgetKeyword["COUNTDOWN"] = "countdown";
|
|
76
|
-
WidgetKeyword["TIMER"] = "timer";
|
|
77
|
-
WidgetKeyword["INFO"] = "info";
|
|
78
|
-
WidgetKeyword["DASHBOARD"] = "dashboard";
|
|
79
|
-
})(WidgetKeyword = exports.WidgetKeyword || (exports.WidgetKeyword = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetKeyword = exports.Widget = void 0;
|
|
4
|
+
const HostedMode_1 = require("./HostedMode");
|
|
5
|
+
class Widget {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8
|
+
/**
|
|
9
|
+
* 组件默认语言
|
|
10
|
+
*/
|
|
11
|
+
this.lang = "zh";
|
|
12
|
+
this.name = options.name;
|
|
13
|
+
this.title = options.title;
|
|
14
|
+
this.description = options.description;
|
|
15
|
+
this.keywords = options.keywords;
|
|
16
|
+
this.lang = options.lang;
|
|
17
|
+
this.width = options.width;
|
|
18
|
+
this.height = options.height;
|
|
19
|
+
this.maxWidth = (_a = options.maxWidth) !== null && _a !== void 0 ? _a : options.width;
|
|
20
|
+
this.maxHeight = (_b = options.maxHeight) !== null && _b !== void 0 ? _b : options.height;
|
|
21
|
+
this.minWidth = (_c = options.minWidth) !== null && _c !== void 0 ? _c : options.width;
|
|
22
|
+
this.minHeight = (_d = options.minHeight) !== null && _d !== void 0 ? _d : options.height;
|
|
23
|
+
this.url = options.url;
|
|
24
|
+
this.packageName = options.packageName;
|
|
25
|
+
this.configUrl = options.configUrl;
|
|
26
|
+
this.extraUrl = (_e = options.extraUrl) !== null && _e !== void 0 ? _e : {};
|
|
27
|
+
this.supportHostedMode = (_f = options.supportHostedMode) !== null && _f !== void 0 ? _f : HostedMode_1.HostedMode.NORMAL | HostedMode_1.HostedMode.OVERLAP;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 获取组件标题
|
|
31
|
+
* @param lang 语言环境,不传则获取默认语言
|
|
32
|
+
*/
|
|
33
|
+
getTitle(lang) {
|
|
34
|
+
var _a;
|
|
35
|
+
return lang ? (_a = this.title[lang]) !== null && _a !== void 0 ? _a : this.title[this.lang] : this.title[this.lang];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 获取组件标描述
|
|
39
|
+
* @param lang 语言环境,不传则获取默认标题
|
|
40
|
+
*/
|
|
41
|
+
getDescription(lang) {
|
|
42
|
+
return lang ? this.description[lang] : this.description[this.lang];
|
|
43
|
+
}
|
|
44
|
+
static parseJSON(json) {
|
|
45
|
+
const object = JSON.parse(json);
|
|
46
|
+
return this.parseObject(object);
|
|
47
|
+
}
|
|
48
|
+
static parseObject(obj) {
|
|
49
|
+
return new Widget({
|
|
50
|
+
...obj
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 是否支持悬浮窗
|
|
55
|
+
*/
|
|
56
|
+
isSupportOverlap() {
|
|
57
|
+
return (this.supportHostedMode & HostedMode_1.HostedMode.OVERLAP) > 0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 是否支持普通模式
|
|
61
|
+
*/
|
|
62
|
+
isSupportNormal() {
|
|
63
|
+
return (this.supportHostedMode & HostedMode_1.HostedMode.NORMAL) > 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.Widget = Widget;
|
|
67
|
+
var WidgetKeyword;
|
|
68
|
+
(function (WidgetKeyword) {
|
|
69
|
+
WidgetKeyword["RECOMMEND"] = "recommend";
|
|
70
|
+
WidgetKeyword["TOOLS"] = "tools";
|
|
71
|
+
WidgetKeyword["EFFICIENCY"] = "efficiency";
|
|
72
|
+
WidgetKeyword["PICTURE"] = "picture";
|
|
73
|
+
WidgetKeyword["LIFE"] = "life";
|
|
74
|
+
WidgetKeyword["SHORTCUT"] = "shortcut";
|
|
75
|
+
WidgetKeyword["COUNTDOWN"] = "countdown";
|
|
76
|
+
WidgetKeyword["TIMER"] = "timer";
|
|
77
|
+
WidgetKeyword["INFO"] = "info";
|
|
78
|
+
WidgetKeyword["DASHBOARD"] = "dashboard";
|
|
79
|
+
})(WidgetKeyword = exports.WidgetKeyword || (exports.WidgetKeyword = {}));
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WidgetData = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 组件配置数据,用于存储组件自定义页面所设置的数据
|
|
6
|
-
*/
|
|
7
|
-
class WidgetData {
|
|
8
|
-
constructor(name, id) {
|
|
9
|
-
this.id = id;
|
|
10
|
-
this.name = name;
|
|
11
|
-
}
|
|
12
|
-
parseJSON(json) {
|
|
13
|
-
Object.assign(this, json);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.WidgetData = WidgetData;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetData = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 组件配置数据,用于存储组件自定义页面所设置的数据
|
|
6
|
+
*/
|
|
7
|
+
class WidgetData {
|
|
8
|
+
constructor(name, id) {
|
|
9
|
+
this.id = id;
|
|
10
|
+
this.name = name;
|
|
11
|
+
}
|
|
12
|
+
parseJSON(json) {
|
|
13
|
+
Object.assign(this, json);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.WidgetData = WidgetData;
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WidgetPackage = void 0;
|
|
4
|
-
class WidgetPackage {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WidgetPackage = void 0;
|
|
4
|
+
class WidgetPackage {
|
|
5
|
+
static parseJSON(json) {
|
|
6
|
+
const object = JSON.parse(json);
|
|
7
|
+
return this.parseObject(object);
|
|
8
|
+
}
|
|
9
|
+
static parseObject(obj) {
|
|
10
|
+
let widgetPackage = new WidgetPackage();
|
|
11
|
+
Object.assign(widgetPackage, obj);
|
|
12
|
+
return widgetPackage;
|
|
13
|
+
}
|
|
14
|
+
getFullUrl() {
|
|
15
|
+
if (this.url.startsWith("http")) {
|
|
16
|
+
return this.url;
|
|
17
|
+
}
|
|
18
|
+
return this.url + (this.entry.startsWith("/") ? this.entry : `/${this.entry}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.WidgetPackage = WidgetPackage;
|
|
@@ -1,144 +1,139 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
/**
|
|
5
|
-
* 组件参数,如宽,高,id,语言等环境参数
|
|
6
|
-
*/
|
|
7
|
-
const query_1 = require("../router/query");
|
|
8
|
-
const change_case_1 = require("change-case");
|
|
9
|
-
class WidgetParams {
|
|
10
|
-
/**
|
|
11
|
-
* 将组件参数转为url参数
|
|
12
|
-
* @param object
|
|
13
|
-
* @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
|
|
14
|
-
*/
|
|
15
|
-
toUrlParams() {
|
|
16
|
-
const urlParams = new URLSearchParams();
|
|
17
|
-
const ownPropertyNames = Object.getOwnPropertyNames(this);
|
|
18
|
-
for (let ownPropertyName of ownPropertyNames) {
|
|
19
|
-
const key = ownPropertyName;
|
|
20
|
-
const value = this[key];
|
|
21
|
-
if (value) {
|
|
22
|
-
urlParams.append(WidgetParams.PARAM_PREFIX + (0, change_case_1.snakeCase)(ownPropertyName), value.toString());
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return urlParams;
|
|
26
|
-
}
|
|
27
|
-
getPersistKey() {
|
|
28
|
-
return `${this.name}-${this.id}`;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 从当前地址解析组件参数:
|
|
32
|
-
* http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
|
|
33
|
-
* =>
|
|
34
|
-
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
35
|
-
*/
|
|
36
|
-
static fromCurrentLocation() {
|
|
37
|
-
const href = window.location.href;
|
|
38
|
-
let queryString = href.split("?")[1];
|
|
39
|
-
return this.fromObject((0, query_1.parseQuery)(queryString));
|
|
40
|
-
}
|
|
41
|
-
static setValue(widgetEnv, key, value) {
|
|
42
|
-
const keyWithoutPrefix = key.replace(this.PARAM_PREFIX, "");
|
|
43
|
-
if (keyWithoutPrefix == WidgetParams.PARAM_ID) {
|
|
44
|
-
widgetEnv.id = value;
|
|
45
|
-
}
|
|
46
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_X) {
|
|
47
|
-
widgetEnv.x = parseInt(value);
|
|
48
|
-
}
|
|
49
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_Y) {
|
|
50
|
-
widgetEnv.y = parseInt(value);
|
|
51
|
-
}
|
|
52
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT) {
|
|
53
|
-
widgetEnv.height = parseInt(value);
|
|
54
|
-
}
|
|
55
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH) {
|
|
56
|
-
widgetEnv.width = parseInt(value);
|
|
57
|
-
}
|
|
58
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_LANG) {
|
|
59
|
-
widgetEnv.lang = value;
|
|
60
|
-
}
|
|
61
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_THEME) {
|
|
62
|
-
widgetEnv.theme = value;
|
|
63
|
-
}
|
|
64
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_MODE) {
|
|
65
|
-
widgetEnv.mode = parseInt(value);
|
|
66
|
-
}
|
|
67
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_RADIUS) {
|
|
68
|
-
widgetEnv.radius = parseInt(value);
|
|
69
|
-
}
|
|
70
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH_PX) {
|
|
71
|
-
widgetEnv.widthPx = parseInt(value);
|
|
72
|
-
}
|
|
73
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT_PX) {
|
|
74
|
-
widgetEnv.heightPx = parseInt(value);
|
|
75
|
-
}
|
|
76
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_NAME) {
|
|
77
|
-
widgetEnv.name = value;
|
|
78
|
-
}
|
|
79
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_TITLE) {
|
|
80
|
-
widgetEnv.title = value;
|
|
81
|
-
}
|
|
82
|
-
else if (keyWithoutPrefix == WidgetParams.PARAM_PREVIEW) {
|
|
83
|
-
widgetEnv.preview = (value === 'true');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* 从对象键值对中初始化组件参数
|
|
88
|
-
* {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
|
|
89
|
-
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
90
|
-
* @param object
|
|
91
|
-
*/
|
|
92
|
-
static fromObject(object) {
|
|
93
|
-
const widgetEnv = new WidgetParams();
|
|
94
|
-
const ownPropertyNames = Object.getOwnPropertyNames(object);
|
|
95
|
-
for (let ownPropertyName of ownPropertyNames) {
|
|
96
|
-
const key = ownPropertyName;
|
|
97
|
-
const value = object[key];
|
|
98
|
-
this.setValue(widgetEnv, key, value);
|
|
99
|
-
}
|
|
100
|
-
return widgetEnv;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.WidgetParams = WidgetParams;
|
|
104
|
-
WidgetParams.PARAM_PREFIX = "w_";
|
|
105
|
-
WidgetParams.PARAM_ID = "id";
|
|
106
|
-
WidgetParams.PARAM_WIDTH = "width";
|
|
107
|
-
WidgetParams.PARAM_HEIGHT = "height";
|
|
108
|
-
WidgetParams.PARAM_WIDTH_PX = "width_px";
|
|
109
|
-
WidgetParams.PARAM_HEIGHT_PX = "height_px";
|
|
110
|
-
WidgetParams.PARAM_X = "x";
|
|
111
|
-
WidgetParams.PARAM_Y = "y";
|
|
112
|
-
WidgetParams.PARAM_LANG = "lang";
|
|
113
|
-
WidgetParams.PARAM_THEME = "theme";
|
|
114
|
-
WidgetParams.PARAM_MODE = "mode";
|
|
115
|
-
WidgetParams.PARAM_RADIUS = "radius";
|
|
116
|
-
WidgetParams.PARAM_NAME = "name";
|
|
117
|
-
WidgetParams.PARAM_TITLE = "title";
|
|
118
|
-
WidgetParams.PARAM_PREVIEW = "preview";
|
|
119
|
-
WidgetParams.PARAMS = [
|
|
120
|
-
WidgetParams.PARAM_ID,
|
|
121
|
-
WidgetParams.PARAM_WIDTH,
|
|
122
|
-
WidgetParams.PARAM_HEIGHT,
|
|
123
|
-
WidgetParams.PARAM_X,
|
|
124
|
-
WidgetParams.PARAM_Y,
|
|
125
|
-
WidgetParams.PARAM_LANG,
|
|
126
|
-
WidgetParams.PARAM_THEME,
|
|
127
|
-
WidgetParams.PARAM_MODE,
|
|
128
|
-
WidgetParams.PARAM_WIDTH_PX,
|
|
129
|
-
WidgetParams.PARAM_HEIGHT_PX,
|
|
130
|
-
WidgetParams.PARAM_NAME,
|
|
131
|
-
WidgetParams.PARAM_TITLE,
|
|
132
|
-
WidgetParams.PARAM_PREVIEW,
|
|
133
|
-
];
|
|
134
|
-
var ThemeMode;
|
|
135
|
-
(function (ThemeMode) {
|
|
136
|
-
ThemeMode["AUTO"] = "auto";
|
|
137
|
-
ThemeMode["LIGHT"] = "LIGHT";
|
|
138
|
-
ThemeMode["DARK"] = "DARK";
|
|
139
|
-
})(ThemeMode = exports.ThemeMode || (exports.ThemeMode = {}));
|
|
140
|
-
var WidgetHostMode;
|
|
141
|
-
(function (WidgetHostMode) {
|
|
142
|
-
WidgetHostMode[WidgetHostMode["DEFAULT"] = 0] = "DEFAULT";
|
|
143
|
-
WidgetHostMode[WidgetHostMode["OVERLAP"] = 1] = "OVERLAP";
|
|
144
|
-
})(WidgetHostMode = exports.WidgetHostMode || (exports.WidgetHostMode = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThemeMode = exports.WidgetParams = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 组件参数,如宽,高,id,语言等环境参数
|
|
6
|
+
*/
|
|
7
|
+
const query_1 = require("../router/query");
|
|
8
|
+
const change_case_1 = require("change-case");
|
|
9
|
+
class WidgetParams {
|
|
10
|
+
/**
|
|
11
|
+
* 将组件参数转为url参数
|
|
12
|
+
* @param object
|
|
13
|
+
* @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
|
|
14
|
+
*/
|
|
15
|
+
toUrlParams() {
|
|
16
|
+
const urlParams = new URLSearchParams();
|
|
17
|
+
const ownPropertyNames = Object.getOwnPropertyNames(this);
|
|
18
|
+
for (let ownPropertyName of ownPropertyNames) {
|
|
19
|
+
const key = ownPropertyName;
|
|
20
|
+
const value = this[key];
|
|
21
|
+
if (value) {
|
|
22
|
+
urlParams.append(WidgetParams.PARAM_PREFIX + (0, change_case_1.snakeCase)(ownPropertyName), value.toString());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return urlParams;
|
|
26
|
+
}
|
|
27
|
+
getPersistKey() {
|
|
28
|
+
return `${this.name}-${this.id}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 从当前地址解析组件参数:
|
|
32
|
+
* http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
|
|
33
|
+
* =>
|
|
34
|
+
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
35
|
+
*/
|
|
36
|
+
static fromCurrentLocation() {
|
|
37
|
+
const href = window.location.href;
|
|
38
|
+
let queryString = href.split("?")[1];
|
|
39
|
+
return this.fromObject((0, query_1.parseQuery)(queryString));
|
|
40
|
+
}
|
|
41
|
+
static setValue(widgetEnv, key, value) {
|
|
42
|
+
const keyWithoutPrefix = key.replace(this.PARAM_PREFIX, "");
|
|
43
|
+
if (keyWithoutPrefix == WidgetParams.PARAM_ID) {
|
|
44
|
+
widgetEnv.id = value;
|
|
45
|
+
}
|
|
46
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_X) {
|
|
47
|
+
widgetEnv.x = parseInt(value);
|
|
48
|
+
}
|
|
49
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_Y) {
|
|
50
|
+
widgetEnv.y = parseInt(value);
|
|
51
|
+
}
|
|
52
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT) {
|
|
53
|
+
widgetEnv.height = parseInt(value);
|
|
54
|
+
}
|
|
55
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH) {
|
|
56
|
+
widgetEnv.width = parseInt(value);
|
|
57
|
+
}
|
|
58
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_LANG) {
|
|
59
|
+
widgetEnv.lang = value;
|
|
60
|
+
}
|
|
61
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_THEME) {
|
|
62
|
+
widgetEnv.theme = value;
|
|
63
|
+
}
|
|
64
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_MODE) {
|
|
65
|
+
widgetEnv.mode = parseInt(value);
|
|
66
|
+
}
|
|
67
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_RADIUS) {
|
|
68
|
+
widgetEnv.radius = parseInt(value);
|
|
69
|
+
}
|
|
70
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH_PX) {
|
|
71
|
+
widgetEnv.widthPx = parseInt(value);
|
|
72
|
+
}
|
|
73
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT_PX) {
|
|
74
|
+
widgetEnv.heightPx = parseInt(value);
|
|
75
|
+
}
|
|
76
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_NAME) {
|
|
77
|
+
widgetEnv.name = value;
|
|
78
|
+
}
|
|
79
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_TITLE) {
|
|
80
|
+
widgetEnv.title = value;
|
|
81
|
+
}
|
|
82
|
+
else if (keyWithoutPrefix == WidgetParams.PARAM_PREVIEW) {
|
|
83
|
+
widgetEnv.preview = (value === 'true');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 从对象键值对中初始化组件参数
|
|
88
|
+
* {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
|
|
89
|
+
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
90
|
+
* @param object
|
|
91
|
+
*/
|
|
92
|
+
static fromObject(object) {
|
|
93
|
+
const widgetEnv = new WidgetParams();
|
|
94
|
+
const ownPropertyNames = Object.getOwnPropertyNames(object);
|
|
95
|
+
for (let ownPropertyName of ownPropertyNames) {
|
|
96
|
+
const key = ownPropertyName;
|
|
97
|
+
const value = object[key];
|
|
98
|
+
this.setValue(widgetEnv, key, value);
|
|
99
|
+
}
|
|
100
|
+
return widgetEnv;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.WidgetParams = WidgetParams;
|
|
104
|
+
WidgetParams.PARAM_PREFIX = "w_";
|
|
105
|
+
WidgetParams.PARAM_ID = "id";
|
|
106
|
+
WidgetParams.PARAM_WIDTH = "width";
|
|
107
|
+
WidgetParams.PARAM_HEIGHT = "height";
|
|
108
|
+
WidgetParams.PARAM_WIDTH_PX = "width_px";
|
|
109
|
+
WidgetParams.PARAM_HEIGHT_PX = "height_px";
|
|
110
|
+
WidgetParams.PARAM_X = "x";
|
|
111
|
+
WidgetParams.PARAM_Y = "y";
|
|
112
|
+
WidgetParams.PARAM_LANG = "lang";
|
|
113
|
+
WidgetParams.PARAM_THEME = "theme";
|
|
114
|
+
WidgetParams.PARAM_MODE = "mode";
|
|
115
|
+
WidgetParams.PARAM_RADIUS = "radius";
|
|
116
|
+
WidgetParams.PARAM_NAME = "name";
|
|
117
|
+
WidgetParams.PARAM_TITLE = "title";
|
|
118
|
+
WidgetParams.PARAM_PREVIEW = "preview";
|
|
119
|
+
WidgetParams.PARAMS = [
|
|
120
|
+
WidgetParams.PARAM_ID,
|
|
121
|
+
WidgetParams.PARAM_WIDTH,
|
|
122
|
+
WidgetParams.PARAM_HEIGHT,
|
|
123
|
+
WidgetParams.PARAM_X,
|
|
124
|
+
WidgetParams.PARAM_Y,
|
|
125
|
+
WidgetParams.PARAM_LANG,
|
|
126
|
+
WidgetParams.PARAM_THEME,
|
|
127
|
+
WidgetParams.PARAM_MODE,
|
|
128
|
+
WidgetParams.PARAM_WIDTH_PX,
|
|
129
|
+
WidgetParams.PARAM_HEIGHT_PX,
|
|
130
|
+
WidgetParams.PARAM_NAME,
|
|
131
|
+
WidgetParams.PARAM_TITLE,
|
|
132
|
+
WidgetParams.PARAM_PREVIEW,
|
|
133
|
+
];
|
|
134
|
+
var ThemeMode;
|
|
135
|
+
(function (ThemeMode) {
|
|
136
|
+
ThemeMode["AUTO"] = "auto";
|
|
137
|
+
ThemeMode["LIGHT"] = "LIGHT";
|
|
138
|
+
ThemeMode["DARK"] = "DARK";
|
|
139
|
+
})(ThemeMode = exports.ThemeMode || (exports.ThemeMode = {}));
|