@widget-js/core 0.7.10 → 0.10.6
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/index.cjs +31 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1384 -1356
- package/dist/index.js +30 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -65,6 +65,7 @@ var Page = class {
|
|
|
65
65
|
description;
|
|
66
66
|
keywords;
|
|
67
67
|
security;
|
|
68
|
+
permissions;
|
|
68
69
|
/**
|
|
69
70
|
* 组件默认语言
|
|
70
71
|
*/
|
|
@@ -107,6 +108,7 @@ var Page = class {
|
|
|
107
108
|
this.path = options.path;
|
|
108
109
|
this.meta = options.meta ?? {};
|
|
109
110
|
this.security = options.security ?? false;
|
|
111
|
+
this.permissions = options.permissions ?? [];
|
|
110
112
|
}
|
|
111
113
|
/**
|
|
112
114
|
* 获取组件标题
|
|
@@ -155,10 +157,15 @@ var Widget = class extends Page {
|
|
|
155
157
|
* 配置页面路径,没有则不能修改
|
|
156
158
|
*/
|
|
157
159
|
configPagePath;
|
|
160
|
+
/**
|
|
161
|
+
* @deprecated
|
|
162
|
+
*/
|
|
163
|
+
routes;
|
|
158
164
|
constructor(options) {
|
|
159
165
|
super(options);
|
|
160
166
|
this.configPagePath = options.configPagePath;
|
|
161
167
|
this.supportDeployMode = options.supportDeployMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
|
|
168
|
+
this.routes = options.routes ?? [];
|
|
162
169
|
}
|
|
163
170
|
static parseJSON(json) {
|
|
164
171
|
const object = JSON.parse(json);
|
|
@@ -806,7 +813,7 @@ var WidgetUrlUtils = class {
|
|
|
806
813
|
arr.push(widgetParams.toUrlParams().toString());
|
|
807
814
|
return normalizeUrl(arr.join("")).replaceAll("//", "/");
|
|
808
815
|
}
|
|
809
|
-
static getWidgetPackageUrl(url, entry, hash) {
|
|
816
|
+
static getWidgetPackageUrl(url, entry, hash, path = "") {
|
|
810
817
|
const arr = [url];
|
|
811
818
|
if (url.startsWith("http")) {
|
|
812
819
|
if (hash) {
|
|
@@ -815,11 +822,11 @@ var WidgetUrlUtils = class {
|
|
|
815
822
|
} else {
|
|
816
823
|
arr.push(`/${entry}`);
|
|
817
824
|
if (hash) {
|
|
818
|
-
arr.push("
|
|
825
|
+
arr.push("#");
|
|
819
826
|
}
|
|
820
827
|
}
|
|
821
|
-
|
|
822
|
-
;
|
|
828
|
+
arr.push(path);
|
|
829
|
+
return arr.join("");
|
|
823
830
|
}
|
|
824
831
|
};
|
|
825
832
|
|
|
@@ -967,6 +974,9 @@ var WidgetPackage = class {
|
|
|
967
974
|
getIndexUrl(hash) {
|
|
968
975
|
return WidgetUrlUtils.getWidgetPackageUrl(this.url, this.entry, hash == null ? this.hash : hash);
|
|
969
976
|
}
|
|
977
|
+
getUrl(path, hash) {
|
|
978
|
+
return WidgetUrlUtils.getWidgetPackageUrl(this.url, this.entry, hash == null ? this.hash : hash, path);
|
|
979
|
+
}
|
|
970
980
|
};
|
|
971
981
|
|
|
972
982
|
// src/utils/ElectronUtils.ts
|
|
@@ -1207,6 +1217,9 @@ var WidgetApiImpl = class extends BaseApi {
|
|
|
1207
1217
|
async openConfigPage(widgetId) {
|
|
1208
1218
|
return this.invokeMethod("openConfigPage", widgetId);
|
|
1209
1219
|
}
|
|
1220
|
+
async openConfigPageByName(widgetName) {
|
|
1221
|
+
return this.invokeMethod("openConfigPageByName", widgetName);
|
|
1222
|
+
}
|
|
1210
1223
|
async getWidgetPackages() {
|
|
1211
1224
|
return await this.invokeMethod("getWidgetPackages");
|
|
1212
1225
|
}
|
|
@@ -1307,16 +1320,19 @@ var WidgetDataApiImpl = class {
|
|
|
1307
1320
|
/**
|
|
1308
1321
|
* 保存组件数据
|
|
1309
1322
|
* @param data
|
|
1323
|
+
* @param options
|
|
1310
1324
|
*/
|
|
1311
|
-
async save(data) {
|
|
1325
|
+
async save(data, options = { sendBroadcast: true }) {
|
|
1312
1326
|
let store = this.getStore(data.name);
|
|
1313
1327
|
let json = JSON.stringify(data);
|
|
1314
1328
|
const result = await store.setItem(this.getKey(data.name, data.id), json);
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1329
|
+
if (options.sendBroadcast) {
|
|
1330
|
+
const broadcastEvent = new BroadcastEvent({
|
|
1331
|
+
event: "event::cn.widgetjs.core.widget.data-changed" /* DATA_CHANGED */,
|
|
1332
|
+
payload: { name: data.name, json }
|
|
1333
|
+
});
|
|
1334
|
+
await BroadcastApi.send(broadcastEvent);
|
|
1335
|
+
}
|
|
1320
1336
|
return result;
|
|
1321
1337
|
}
|
|
1322
1338
|
/**
|
|
@@ -1529,9 +1545,6 @@ var BrowserWindowApiImpl = class extends BaseApi {
|
|
|
1529
1545
|
if (options.alwaysOnTop) {
|
|
1530
1546
|
await this.setAlwaysOnTop(true);
|
|
1531
1547
|
}
|
|
1532
|
-
if (options.center) {
|
|
1533
|
-
await this.center();
|
|
1534
|
-
}
|
|
1535
1548
|
await this.setResizable(!!options.resizable);
|
|
1536
1549
|
await this.setMovable(!!options.movable);
|
|
1537
1550
|
if (options.width && options.height) {
|
|
@@ -1543,6 +1556,9 @@ var BrowserWindowApiImpl = class extends BaseApi {
|
|
|
1543
1556
|
if (options.maxWidth && options.maxHeight) {
|
|
1544
1557
|
await this.setMaximumSize(options.maxWidth, options.maxHeight);
|
|
1545
1558
|
}
|
|
1559
|
+
if (options.center) {
|
|
1560
|
+
await this.center();
|
|
1561
|
+
}
|
|
1546
1562
|
}
|
|
1547
1563
|
};
|
|
1548
1564
|
var BrowserWindowApi = new BrowserWindowApiImpl();
|
|
@@ -1977,6 +1993,7 @@ export {
|
|
|
1977
1993
|
WidgetPackage,
|
|
1978
1994
|
WidgetParams,
|
|
1979
1995
|
WidgetUrlUtils,
|
|
1996
|
+
getTextByLanguageCode,
|
|
1980
1997
|
normalizeUrl,
|
|
1981
1998
|
parseQuery,
|
|
1982
1999
|
stringifyQuery
|