@newview/base-vue 1.3.1 → 1.3.2

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/base-vue.mjs DELETED
@@ -1,1339 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import { defineComponent, openBlock, createElementBlock, ref, onMounted, resolveComponent, withDirectives, createElementVNode, vShow, createVNode, onUnmounted, shallowRef, Fragment, renderList, createBlock, resolveDynamicComponent, createCommentVNode, nextTick } from "vue";
8
- import ViewUIPlus, { Message, Modal } from "view-ui-plus";
9
- import { Utilities, utilities } from "@newview/tools";
10
- import { storageInfo, openObserve } from "@newview/infrastructure";
11
- import mitt from "mitt";
12
- import { useRouter } from "vue-router";
13
- import VxeTable from "vxe-table";
14
- import axios from "axios";
15
- class MessageInstance {
16
- constructor() {
17
- /**
18
- * 提示 info
19
- * @param prop
20
- */
21
- __publicField(this, "info", (prop) => {
22
- Message.info(prop);
23
- });
24
- /**
25
- * 提示 success
26
- * @param prop
27
- */
28
- __publicField(this, "success", (prop) => {
29
- Message.success(prop);
30
- });
31
- /**
32
- * 提示 warning
33
- * @param prop
34
- */
35
- __publicField(this, "warning", (prop) => {
36
- Message.warning(prop);
37
- });
38
- /**
39
- * 提示 error
40
- * @param prop
41
- */
42
- __publicField(this, "error", (prop) => {
43
- Message.error(prop);
44
- });
45
- }
46
- }
47
- const message = new MessageInstance();
48
- class ModalInstance {
49
- constructor() {
50
- __publicField(this, "zIndex", 1e4);
51
- /**
52
- * 确认对话框
53
- * @param prop
54
- */
55
- __publicField(this, "confirm", (prop) => {
56
- prop["z-index"] = this.zIndex;
57
- Modal.confirm(prop);
58
- });
59
- /**
60
- * 基础对话框 info
61
- * @param prop
62
- */
63
- __publicField(this, "info", (prop) => {
64
- prop["z-index"] = this.zIndex;
65
- Modal.info(prop);
66
- });
67
- /**
68
- * 基础对话框 success
69
- * @param prop
70
- */
71
- __publicField(this, "success", (prop) => {
72
- prop["z-index"] = this.zIndex;
73
- Modal.success(prop);
74
- });
75
- /**
76
- * 基础对话框 warning
77
- * @param prop
78
- */
79
- __publicField(this, "warning", (prop) => {
80
- prop["z-index"] = this.zIndex;
81
- Modal.warning(prop);
82
- });
83
- /**
84
- * 基础对话框 error
85
- * @param prop
86
- */
87
- __publicField(this, "error", (prop) => {
88
- prop["z-index"] = this.zIndex;
89
- Modal.error(prop);
90
- });
91
- }
92
- }
93
- const modal = new ModalInstance();
94
- const bus = mitt();
95
- class BaseInstance {
96
- constructor() {
97
- /**
98
- * IView 消息提示
99
- */
100
- __publicField(this, "message", new MessageInstance());
101
- /**
102
- * IView Modal
103
- */
104
- __publicField(this, "modal", new ModalInstance());
105
- /**
106
- * 工具类
107
- */
108
- __publicField(this, "utilities", new Utilities());
109
- /**
110
- * 存储信息
111
- */
112
- __publicField(this, "storageInfo", storageInfo);
113
- /**
114
- * 系统监视
115
- */
116
- __publicField(this, "openObserve", openObserve);
117
- /**
118
- * 事件总线
119
- */
120
- __publicField(this, "bus", bus);
121
- /**
122
- *
123
- * @param e
124
- * @returns
125
- */
126
- __publicField(this, "doInputControl", (e) => {
127
- if (this.utilities.isNull(e)) {
128
- return;
129
- }
130
- e.target.readOnly = false;
131
- });
132
- }
133
- }
134
- const propDefine$6 = {
135
- count: {
136
- type: Number,
137
- default: 0
138
- }
139
- };
140
- const _sfc_main$5 = defineComponent({
141
- name: "Root",
142
- components: {},
143
- emits: [""],
144
- // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
145
- props: propDefine$6,
146
- setup(props, ctx) {
147
- return new RootInstance(props, ctx);
148
- }
149
- });
150
- class RootInstance extends BaseInstance {
151
- constructor(props, ctx) {
152
- super();
153
- __publicField(this, "props");
154
- __publicField(this, "ctx");
155
- // API实例化
156
- // private platformApi: PlatformApi = new PlatformApi();
157
- // 全局属性
158
- __publicField(this, "router");
159
- this.props = props;
160
- this.ctx = ctx;
161
- this.useRoot();
162
- }
163
- //#region 页面调整
164
- // 私有方法 | private 方法名() {}
165
- /**
166
- * 初始化业务
167
- */
168
- useRoot() {
169
- this.router = useRouter();
170
- this.goPage();
171
- }
172
- /**
173
- * 调整页面
174
- */
175
- goPage() {
176
- const linkMain = this.getQueryString("linkMain");
177
- if (!this.utilities.isNull(linkMain)) {
178
- this.router.replace("/LinkMain");
179
- return;
180
- }
181
- const token = this.storageInfo.getToken();
182
- if (this.utilities.isNull(token)) {
183
- this.router.replace("/Login");
184
- } else {
185
- this.router.replace(this.storageInfo.getCurrentDefaultPath());
186
- }
187
- }
188
- /**
189
- * 获取地址栏参数
190
- * @param variable
191
- * @returns
192
- */
193
- getQueryString(variable) {
194
- let index = window.location.href.indexOf("?");
195
- let query = window.location.href.substring(
196
- index + 1,
197
- window.location.href.length
198
- );
199
- let vars = query.split("&");
200
- for (const item of vars) {
201
- let pair = item.split("=");
202
- if (pair[0] == variable) {
203
- return pair[1];
204
- }
205
- }
206
- return "";
207
- }
208
- //#endregion 页面调整 END
209
- }
210
- const Root_vue_vue_type_style_index_0_scoped_b392b4ac_lang = "";
211
- const _export_sfc = (sfc, props) => {
212
- const target = sfc.__vccOpts || sfc;
213
- for (const [key, val] of props) {
214
- target[key] = val;
215
- }
216
- return target;
217
- };
218
- const _hoisted_1$5 = { class: "root" };
219
- function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
220
- return openBlock(), createElementBlock("div", _hoisted_1$5);
221
- }
222
- const Root = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5], ["__scopeId", "data-v-b392b4ac"]]);
223
- const propDefine$5 = {
224
- tabPage: {
225
- // 要打开的页面信息
226
- type: Object,
227
- default: () => ({})
228
- }
229
- };
230
- const _sfc_main$4 = defineComponent({
231
- name: "LinkPanel",
232
- components: {},
233
- emits: [""],
234
- // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
235
- props: propDefine$5,
236
- setup(props, ctx) {
237
- return new LinkPanelInstance(props, ctx);
238
- }
239
- });
240
- class LinkPanelInstance extends BaseInstance {
241
- // API实例化
242
- // private platformApi: PlatformApi = new PlatformApi();
243
- // 全局属性
244
- constructor(props, ctx) {
245
- super();
246
- __publicField(this, "props");
247
- __publicField(this, "ctx");
248
- //#region 外链接
249
- // 私有属性 | private
250
- // 响应属性 | ref、reactive、computed、watch
251
- __publicField(this, "loading", ref(true));
252
- __publicField(this, "ifrPanel", ref());
253
- this.props = props;
254
- this.ctx = ctx;
255
- this.useLinkPanel();
256
- }
257
- // 私有方法 | private 方法名() {}
258
- /**
259
- * 初始化业务
260
- */
261
- useLinkPanel() {
262
- onMounted(() => {
263
- this.bindLoadEvent();
264
- });
265
- }
266
- /**
267
- * 绑定事件
268
- */
269
- bindLoadEvent() {
270
- const iframe = this.ifrPanel.value;
271
- if (iframe.attachEvent) {
272
- iframe.attachEvent("onload", () => {
273
- this.doLoaded(iframe);
274
- });
275
- } else {
276
- iframe.onload = () => {
277
- this.doLoaded(iframe);
278
- };
279
- }
280
- }
281
- /**
282
- * 加载完成
283
- * @param iframe
284
- */
285
- doLoaded(iframe) {
286
- this.loading.value = false;
287
- setTimeout(() => {
288
- const message2 = {
289
- token: this.storageInfo.getToken(),
290
- user: JSON.stringify(this.storageInfo.getUser()),
291
- currentPlatform: JSON.stringify(this.storageInfo.getCurrentPlatform()),
292
- currentBusiness: JSON.stringify(this.storageInfo.getCurrentBusiness()),
293
- currentModule: JSON.stringify(this.storageInfo.getCurrentModule())
294
- };
295
- iframe.contentWindow.postMessage(
296
- message2,
297
- "*"
298
- );
299
- }, 20);
300
- }
301
- // 响应式方法 | xxx = () => {}
302
- //#endregion 业务逻辑二 END
303
- }
304
- const LinkPanel_vue_vue_type_style_index_0_scoped_37023fbf_lang = "";
305
- const _hoisted_1$4 = { class: "link-panel" };
306
- const _hoisted_2$1 = ["src", "title"];
307
- function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
308
- const _component_Spin = resolveComponent("Spin");
309
- return openBlock(), createElementBlock("div", _hoisted_1$4, [
310
- withDirectives(createElementVNode("iframe", {
311
- src: _ctx.tabPage.path,
312
- class: "link-ifr",
313
- title: _ctx.tabPage.path,
314
- ref: "ifrPanel"
315
- }, null, 8, _hoisted_2$1), [
316
- [vShow, !_ctx.loading]
317
- ]),
318
- createVNode(_component_Spin, {
319
- size: "large",
320
- fix: "",
321
- show: _ctx.loading
322
- }, null, 8, ["show"])
323
- ]);
324
- }
325
- const LinkPanel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4], ["__scopeId", "data-v-37023fbf"]]);
326
- const propDefine$4 = {};
327
- const _sfc_main$3 = defineComponent({
328
- name: "LinkMain",
329
- components: { LinkPanel },
330
- emits: [""],
331
- // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
332
- props: propDefine$4,
333
- setup(props, ctx) {
334
- return new LinkMainInstance(props, ctx);
335
- }
336
- });
337
- class LinkMainInstance extends BaseInstance {
338
- // API实例化
339
- // private platformApi: PlatformApi = new PlatformApi();
340
- // 全局属性
341
- constructor(props, ctx) {
342
- super();
343
- __publicField(this, "props");
344
- __publicField(this, "ctx");
345
- //#region 业务逻辑二
346
- // 私有属性 | private
347
- // 响应属性 | ref、reactive、computed、watch
348
- __publicField(this, "pages", ref([]));
349
- __publicField(this, "activePath", ref(""));
350
- this.props = props;
351
- this.ctx = ctx;
352
- this.useLinkMain();
353
- }
354
- // 私有方法 | private 方法名() {}
355
- /**
356
- * 初始化
357
- */
358
- useLinkMain() {
359
- const event = (data) => {
360
- this.receiveMessage(data);
361
- };
362
- window.addEventListener("message", event);
363
- onUnmounted(() => {
364
- window.removeEventListener("message", event);
365
- });
366
- }
367
- /**
368
- * 接收消息
369
- * @param messageEvent
370
- * @returns
371
- */
372
- receiveMessage(messageEvent) {
373
- if (messageEvent.source != window.parent.window.parent)
374
- return;
375
- const data = messageEvent.data;
376
- const command = data.command;
377
- switch (command) {
378
- case "initStorageInfo":
379
- this.initStorageInfo(data.data);
380
- break;
381
- case "pushPage":
382
- this.pushPage(data.data);
383
- break;
384
- case "clearAllPage":
385
- this.clearAllPage(data.data);
386
- break;
387
- case "closePage":
388
- this.closePage(data.data);
389
- break;
390
- case "activePage":
391
- this.activePage(data.data);
392
- break;
393
- case "closePageByCommand":
394
- this.closePageByCommand(data.data);
395
- break;
396
- }
397
- }
398
- /**
399
- * 初始化存储信息
400
- * @param data
401
- */
402
- initStorageInfo(data) {
403
- const token = data.token;
404
- const user = this.utilities.isNull(data.user) ? void 0 : JSON.parse(data.user);
405
- const currentPlatform = this.utilities.isNull(data.currentPlatform) ? void 0 : JSON.parse(data.currentPlatform);
406
- const currentBusiness = this.utilities.isNull(data.currentBusiness) ? void 0 : JSON.parse(data.currentBusiness);
407
- const currentModule = this.utilities.isNull(data.currentModule) ? void 0 : JSON.parse(data.currentModule);
408
- this.storageInfo.setToken(token);
409
- this.storageInfo.setUser(user);
410
- this.storageInfo.setCurrentPlatform(currentPlatform);
411
- this.storageInfo.setCurrentBusiness(currentBusiness);
412
- this.storageInfo.setCurrentModule(currentModule);
413
- }
414
- /**
415
- * 插入页面
416
- * @param data { platformNo: string, path: string, loadMode: number, param: string, operates: string}
417
- */
418
- pushPage(data) {
419
- let component;
420
- if (data.loadMode == 0) {
421
- const menu = this.storageInfo.getMenuComponts().find((item) => item.path == data.path);
422
- if (typeof menu.component == "function") {
423
- component = shallowRef(menu.component());
424
- } else {
425
- component = shallowRef(menu.component);
426
- }
427
- }
428
- this.pages.value.push({
429
- path: data.path,
430
- loadMode: data.loadMode,
431
- param: data.param,
432
- operates: data.operates,
433
- component
434
- });
435
- }
436
- /**
437
- * 清除所有页面
438
- * @param data { platformNo: string }
439
- */
440
- clearAllPage(data) {
441
- this.pages.value = [];
442
- }
443
- /**
444
- * 关闭当前页面
445
- * @param data { platformNo: string, path: string }
446
- */
447
- closePage(data) {
448
- const index = this.pages.value.findIndex((item) => item.path == data.path);
449
- this.pages.value.splice(index, 1);
450
- }
451
- /**
452
- * 激活页面
453
- * @param data { platformNo: string, path: string }
454
- */
455
- activePage(data) {
456
- this.activePath.value = data.path;
457
- }
458
- /**
459
- * 根据命令关闭页面
460
- * @param data { platformNo: string, command: string }
461
- */
462
- closePageByCommand(data) {
463
- const currentIndex = this.pages.value.findIndex((item) => item.path == this.activePath.value);
464
- switch (data.command) {
465
- case "left":
466
- if (currentIndex == 0 || currentIndex == 1) {
467
- return;
468
- }
469
- this.pages.value.splice(1, currentIndex - 1);
470
- break;
471
- case "right":
472
- if (currentIndex == this.pages.value.length - 1) {
473
- return;
474
- }
475
- this.pages.value.splice(currentIndex + 1);
476
- break;
477
- case "other":
478
- const currentTabIndex = this.pages.value.findIndex((item) => item.path == this.activePath.value);
479
- const welcomTab = this.pages.value[0];
480
- if (currentTabIndex == 0) {
481
- this.pages.value = [welcomTab];
482
- } else {
483
- const currentTab = this.pages.value[currentTabIndex];
484
- this.pages.value = [welcomTab, currentTab];
485
- }
486
- break;
487
- case "all":
488
- this.pages.value.splice(1);
489
- break;
490
- }
491
- }
492
- // 响应式方法 | xxx = () => {}
493
- //#endregion 业务逻辑二 END
494
- }
495
- const LinkMain_vue_vue_type_style_index_0_scoped_026a2cc9_lang = "";
496
- const _hoisted_1$3 = { class: "line-main" };
497
- function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
498
- const _component_LinkPanel = resolveComponent("LinkPanel");
499
- return openBlock(), createElementBlock("div", _hoisted_1$3, [
500
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.pages, (item) => {
501
- return openBlock(), createElementBlock(Fragment, {
502
- key: item.path
503
- }, [
504
- item.loadMode == 0 ? withDirectives((openBlock(), createBlock(resolveDynamicComponent(item.component), {
505
- key: 0,
506
- linkParam: item.param,
507
- operates: item.operates
508
- }, null, 8, ["linkParam", "operates"])), [
509
- [vShow, item.path == _ctx.activePath]
510
- ]) : createCommentVNode("", true),
511
- item.loadMode == 1 ? withDirectives((openBlock(), createBlock(_component_LinkPanel, {
512
- key: 1,
513
- tabPage: item
514
- }, null, 8, ["tabPage"])), [
515
- [vShow, item.path == _ctx.activePath]
516
- ]) : createCommentVNode("", true)
517
- ], 64);
518
- }), 128))
519
- ]);
520
- }
521
- const LinkMain = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__scopeId", "data-v-026a2cc9"]]);
522
- const vFocus = (app) => {
523
- app.directive("focus", {
524
- // 当被绑定的元素挂载到 DOM 中时被调用
525
- mounted(el) {
526
- el.focus();
527
- el.select();
528
- }
529
- });
530
- };
531
- const viewuiplus = "";
532
- const style = "";
533
- const iviewExpand = "";
534
- let $router;
535
- function useAxios() {
536
- axios.interceptors.request.use(
537
- function(config) {
538
- const token = storageInfo.getToken();
539
- if (!utilities.isNull(token) && utilities.isNull(config.headers["Authorization"])) {
540
- config.headers["Authorization"] = "Bearer " + token;
541
- }
542
- const platformNo = storageInfo.getPlatformNo();
543
- if (!utilities.isNull(platformNo)) {
544
- config.headers["PlatformNo"] = platformNo;
545
- }
546
- const platform = storageInfo.getCurrentPlatform();
547
- if (!utilities.isNull(platform)) {
548
- config.headers["PlatformId"] = platform.Id;
549
- config.headers["PlatformName"] = encodeURI(platform.PlatformName);
550
- }
551
- const userInfo = storageInfo.getUser();
552
- if (!utilities.isNull(userInfo)) {
553
- config.headers["UserId"] = userInfo.Id;
554
- config.headers["UserName"] = encodeURI(`${userInfo.UserName}(${userInfo.Account})`);
555
- }
556
- const moduleInfo = storageInfo.getCurrentModule();
557
- if (!utilities.isNull(moduleInfo)) {
558
- config.headers["MenuId"] = moduleInfo.Id;
559
- config.headers["MenuName"] = encodeURI(moduleInfo.ModuleName);
560
- config.headers["MenuPath"] = encodeURI(moduleInfo.ModuleUrl);
561
- }
562
- return config;
563
- },
564
- function(error) {
565
- return Promise.reject(error);
566
- }
567
- );
568
- axios.interceptors.response.use(
569
- function(config) {
570
- return config;
571
- },
572
- function(error) {
573
- if (error.response && error.response.data && error.response.data.code == "401") {
574
- storageInfo.removeAll();
575
- $router.push("/Login");
576
- } else {
577
- openObserve.error("请求异常", error);
578
- }
579
- return Promise.reject(error);
580
- }
581
- );
582
- }
583
- function useOpenObserve() {
584
- const windowAny = window;
585
- if (utilities.isNull(windowAny.openObserveOption)) {
586
- return;
587
- }
588
- const option = windowAny.openObserveOption;
589
- openObserve.init(option);
590
- }
591
- function initWeb(app, platformNo, menus, router) {
592
- $router = router;
593
- app.use(ViewUIPlus);
594
- app.use(VxeTable);
595
- vFocus(app);
596
- storageInfo.setPlatformNo(platformNo);
597
- storageInfo.setMenuComponts(menus);
598
- useAxios();
599
- useOpenObserve();
600
- openObserve.info(`${platformNo} 初始化完成`, { platformNo });
601
- }
602
- const propDefine$3 = {
603
- loaderInfor: {
604
- // 加载信息
605
- type: Object,
606
- default: () => ({})
607
- }
608
- };
609
- const _sfc_main$2 = defineComponent({
610
- name: "LocalLoader",
611
- components: { LinkPanel },
612
- emits: [""],
613
- // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
614
- props: propDefine$3,
615
- setup(props, ctx) {
616
- return new LocalLoaderInstance(props, ctx);
617
- }
618
- });
619
- class LocalLoaderInstance extends BaseInstance {
620
- // API实例化
621
- // private platformApi: PlatformApi = new PlatformApi();
622
- // 全局属性
623
- constructor(props, ctx) {
624
- super();
625
- __publicField(this, "props");
626
- __publicField(this, "ctx");
627
- //#region 业务逻辑
628
- // 私有属性 | private
629
- // private business2Test1: number = 0;
630
- // 响应属性 | ref、reactive、computed、watch
631
- __publicField(this, "pages", ref([]));
632
- __publicField(this, "activePath", ref(""));
633
- this.props = props;
634
- this.ctx = ctx;
635
- this.useBusiness();
636
- }
637
- // 私有方法 | private 方法名() {}
638
- /**
639
- * 初始化业务
640
- */
641
- useBusiness() {
642
- onMounted(() => {
643
- });
644
- onUnmounted(() => {
645
- bus.off("pushPage");
646
- bus.off("clearAllPage");
647
- bus.off("closePage");
648
- bus.off("activePage");
649
- bus.off("closePageByCommand");
650
- });
651
- bus.on("pushPage", (data) => {
652
- this.pushPage(data);
653
- });
654
- bus.on("clearAllPage", (data) => {
655
- this.clearAllPage(data);
656
- });
657
- bus.on("closePage", (data) => {
658
- this.closePage(data);
659
- });
660
- bus.on("activePage", (data) => {
661
- this.activePage(data);
662
- });
663
- bus.on("closePageByCommand", (data) => {
664
- this.closePageByCommand(data);
665
- });
666
- }
667
- /**
668
- * 插入页面
669
- * @param data { platformNo: string, path: string, loadMode: number, param: string, operates: string}
670
- */
671
- pushPage(data) {
672
- if (data.platformNo != this.props.loaderInfor.platformNo) {
673
- return;
674
- }
675
- let component;
676
- if (data.loadMode == 0) {
677
- const menu = this.storageInfo.getMenuComponts().find((item) => item.path == data.path);
678
- if (typeof menu.component == "function") {
679
- component = shallowRef(menu.component());
680
- } else {
681
- component = shallowRef(menu.component);
682
- }
683
- }
684
- this.pages.value.push({
685
- path: data.path,
686
- loadMode: data.loadMode,
687
- param: data.param,
688
- operates: data.operates,
689
- component
690
- });
691
- }
692
- /**
693
- * 清除所有页面
694
- * @param data { platformNo: string }
695
- */
696
- clearAllPage(data) {
697
- if (data.platformNo != this.props.loaderInfor.platformNo) {
698
- return;
699
- }
700
- this.pages.value = [];
701
- }
702
- /**
703
- * 关闭当前页面
704
- * @param data { platformNo: string, path: string }
705
- */
706
- closePage(data) {
707
- if (data.platformNo != this.props.loaderInfor.platformNo) {
708
- return;
709
- }
710
- const index = this.pages.value.findIndex((item) => item.path == data.path);
711
- this.pages.value.splice(index, 1);
712
- }
713
- /**
714
- * 激活页面
715
- * @param data { platformNo: string, path: string }
716
- */
717
- activePage(data) {
718
- if (data.platformNo != this.props.loaderInfor.platformNo) {
719
- return;
720
- }
721
- this.activePath.value = data.path;
722
- }
723
- /**
724
- * 根据命令关闭页面
725
- * @param data { platformNo: string, command: string }
726
- */
727
- closePageByCommand(data) {
728
- if (data.platformNo != this.props.loaderInfor.platformNo) {
729
- return;
730
- }
731
- const currentIndex = this.pages.value.findIndex((item) => item.path == this.activePath.value);
732
- switch (data.command) {
733
- case "left":
734
- if (currentIndex == 0 || currentIndex == 1) {
735
- return;
736
- }
737
- this.pages.value.splice(1, currentIndex - 1);
738
- break;
739
- case "right":
740
- if (currentIndex == this.pages.value.length - 1) {
741
- return;
742
- }
743
- this.pages.value.splice(currentIndex + 1);
744
- break;
745
- case "other":
746
- const currentTabIndex = this.pages.value.findIndex((item) => item.path == this.activePath.value);
747
- const welcomTab = this.pages.value[0];
748
- if (currentTabIndex == 0) {
749
- this.pages.value = [welcomTab];
750
- } else {
751
- const currentTab = this.pages.value[currentTabIndex];
752
- this.pages.value = [welcomTab, currentTab];
753
- }
754
- break;
755
- case "all":
756
- this.pages.value.splice(1);
757
- break;
758
- }
759
- }
760
- // 响应式方法 | xxx = () => {}
761
- // doBtnClick2 = () = {}
762
- //#endregion 业务逻辑 END
763
- }
764
- const LocalLoader_vue_vue_type_style_index_0_scoped_1ff2be67_lang = "";
765
- const _hoisted_1$2 = { class: "local-loader" };
766
- function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
767
- const _component_LinkPanel = resolveComponent("LinkPanel");
768
- return openBlock(), createElementBlock("div", _hoisted_1$2, [
769
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.pages, (item) => {
770
- return openBlock(), createElementBlock(Fragment, {
771
- key: item.path
772
- }, [
773
- item.loadMode == 0 ? withDirectives((openBlock(), createBlock(resolveDynamicComponent(item.component), {
774
- key: 0,
775
- linkParam: item.param,
776
- operates: item.operates
777
- }, null, 8, ["linkParam", "operates"])), [
778
- [vShow, item.path == _ctx.activePath]
779
- ]) : createCommentVNode("", true),
780
- item.loadMode == 1 ? withDirectives((openBlock(), createBlock(_component_LinkPanel, {
781
- key: 1,
782
- tabPage: item
783
- }, null, 8, ["tabPage"])), [
784
- [vShow, item.path == _ctx.activePath]
785
- ]) : createCommentVNode("", true)
786
- ], 64);
787
- }), 128))
788
- ]);
789
- }
790
- const LocalLoader = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-1ff2be67"]]);
791
- const propDefine$2 = {
792
- loaderInfor: {
793
- // 加载项信息
794
- type: Object,
795
- default: () => ({})
796
- }
797
- };
798
- const _sfc_main$1 = defineComponent({
799
- name: "WebLoader",
800
- components: {},
801
- emits: ["loaded"],
802
- // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
803
- props: propDefine$2,
804
- setup(props, ctx) {
805
- return new WebLoaderInstance(props, ctx);
806
- }
807
- });
808
- class WebLoaderInstance extends BaseInstance {
809
- // API实例化
810
- // private platformApi: PlatformApi = new PlatformApi();
811
- // 全局属性
812
- constructor(props, ctx) {
813
- super();
814
- __publicField(this, "props");
815
- __publicField(this, "ctx");
816
- //#region 业务逻辑
817
- // 私有属性 | private
818
- __publicField(this, "commandStack", []);
819
- // 响应属性 | ref、reactive、computed、watch
820
- __publicField(this, "loading", ref(true));
821
- __publicField(this, "ifrWeb", ref());
822
- __publicField(this, "ifrId", ref(""));
823
- /**
824
- * 加载完成
825
- */
826
- __publicField(this, "doLoaded", () => {
827
- nextTick(() => {
828
- this.ctx.emit("loaded", this.props.loaderInfor.platformNo);
829
- this.loading.value = false;
830
- this.sendMessage("initStorageInfo", {
831
- token: this.storageInfo.getToken(),
832
- user: JSON.stringify(this.storageInfo.getUser()),
833
- currentPlatform: JSON.stringify(this.storageInfo.getCurrentPlatform()),
834
- currentBusiness: JSON.stringify(this.storageInfo.getCurrentBusiness()),
835
- currentModule: JSON.stringify(this.storageInfo.getCurrentModule())
836
- });
837
- this.sendStackCommand();
838
- });
839
- });
840
- // 响应式方法 | xxx = () => {}
841
- /**
842
- * 获取URL
843
- * @returns
844
- */
845
- __publicField(this, "getIfrUrl", () => {
846
- const url = this.props.loaderInfor.url;
847
- const isHasQuery = this.props.loaderInfor.url.indexOf("?") != -1;
848
- return url + (isHasQuery ? "&" : "?") + "linkMain=true";
849
- });
850
- this.props = props;
851
- this.ctx = ctx;
852
- this.useWebLoader();
853
- }
854
- // 私有方法 | private 方法名() {}
855
- /**
856
- * 初始化业务
857
- */
858
- useWebLoader() {
859
- this.ifrId.value = this.utilities.getUniqueCode();
860
- onUnmounted(() => {
861
- bus.off("pushPage");
862
- bus.off("clearAllPage");
863
- bus.off("closePage");
864
- bus.off("activePage");
865
- bus.off("closePageByCommand");
866
- });
867
- bus.on("pushPage", (data) => {
868
- this.pushPage(data);
869
- });
870
- bus.on("clearAllPage", (data) => {
871
- this.clearAllPage(data);
872
- });
873
- bus.on("closePage", (data) => {
874
- this.closePage(data);
875
- });
876
- bus.on("activePage", (data) => {
877
- this.activePage(data);
878
- });
879
- bus.on("closePageByCommand", (data) => {
880
- this.closePageByCommand(data);
881
- });
882
- }
883
- /**
884
- * 发送消息
885
- * @param iframe
886
- * @param command
887
- * @param data
888
- */
889
- sendMessage(command, data) {
890
- if (this.loading.value) {
891
- this.commandStack.push({ command, data });
892
- return;
893
- }
894
- const iframe = document.getElementById(this.ifrId.value);
895
- const message2 = {
896
- command,
897
- data
898
- };
899
- iframe.contentWindow.postMessage(
900
- message2,
901
- "*"
902
- );
903
- }
904
- /**
905
- * 发送栈中命令
906
- */
907
- sendStackCommand() {
908
- for (const item of this.commandStack) {
909
- this.sendMessage(item.command, item.data);
910
- }
911
- this.commandStack = [];
912
- }
913
- /**
914
- * 插入页面
915
- * @param data { platformNo: string, path: string, loadMode: number, param: string, operates: string}
916
- */
917
- pushPage(data) {
918
- if (data.platformNo != this.props.loaderInfor.platformNo) {
919
- return;
920
- }
921
- this.sendMessage("pushPage", data);
922
- }
923
- /**
924
- * 清除所有页面
925
- * @param data { platformNo: string }
926
- */
927
- clearAllPage(data) {
928
- if (data.platformNo != this.props.loaderInfor.platformNo) {
929
- return;
930
- }
931
- this.sendMessage("clearAllPage", data);
932
- }
933
- /**
934
- * 关闭当前页面
935
- * @param data { platformNo: string, path: string }
936
- */
937
- closePage(data) {
938
- if (data.platformNo != this.props.loaderInfor.platformNo) {
939
- return;
940
- }
941
- this.sendMessage("closePage", data);
942
- }
943
- /**
944
- * 激活页面
945
- * @param data { platformNo: string, path: string }
946
- */
947
- activePage(data) {
948
- if (data.platformNo != this.props.loaderInfor.platformNo) {
949
- return;
950
- }
951
- this.sendMessage("activePage", data);
952
- }
953
- /**
954
- * 根据命令关闭页面
955
- * @param data { platformNo: string, command: string }
956
- */
957
- closePageByCommand(data) {
958
- if (data.platformNo != this.props.loaderInfor.platformNo) {
959
- return;
960
- }
961
- this.sendMessage("closePageByCommand", data);
962
- }
963
- //#endregion 业务逻辑二 END
964
- }
965
- const WebLoader_vue_vue_type_style_index_0_scoped_12870e01_lang = "";
966
- const _hoisted_1$1 = { class: "web-loader" };
967
- const _hoisted_2 = ["id", "src", "title"];
968
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
969
- const _component_Spin = resolveComponent("Spin");
970
- return openBlock(), createElementBlock("div", _hoisted_1$1, [
971
- createElementVNode("iframe", {
972
- id: _ctx.ifrId,
973
- src: _ctx.getIfrUrl(),
974
- class: "web-ifr",
975
- title: _ctx.loaderInfor.platformNo,
976
- onLoad: _cache[0] || (_cache[0] = (...args) => _ctx.doLoaded && _ctx.doLoaded(...args))
977
- }, null, 40, _hoisted_2),
978
- createVNode(_component_Spin, {
979
- size: "large",
980
- fix: "",
981
- show: _ctx.loading
982
- }, null, 8, ["show"])
983
- ]);
984
- }
985
- const WebLoader = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-12870e01"]]);
986
- const propDefine$1 = {};
987
- const _sfc_main = defineComponent({
988
- name: "LoaderManage",
989
- components: { LocalLoader, WebLoader },
990
- emits: ["loaded"],
991
- // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
992
- props: propDefine$1,
993
- setup(props, ctx) {
994
- return new LoaderManageInstance$1(props, ctx);
995
- }
996
- });
997
- let LoaderManageInstance$1 = class LoaderManageInstance extends BaseInstance {
998
- // API实例化
999
- // private platformApi: PlatformApi = new PlatformApi();
1000
- // 全局属性
1001
- constructor(props, ctx) {
1002
- super();
1003
- __publicField(this, "props");
1004
- __publicField(this, "ctx");
1005
- //#region 加载器
1006
- // 私有属性 | private
1007
- __publicField(this, "pages", []);
1008
- // 响应属性 | ref、reactive、computed、watch
1009
- __publicField(this, "loaderStack", ref([]));
1010
- // 加载器堆栈
1011
- __publicField(this, "currentPlatformNo", ref(""));
1012
- // 响应式方法 | xxx = () => {}
1013
- /**
1014
- * Web加载器加载完成
1015
- * @param item
1016
- */
1017
- __publicField(this, "doLoaded", (platformNo) => {
1018
- const item = this.loaderStack.value.find((item2) => item2.platformNo == platformNo);
1019
- if (this.utilities.isNull(item)) {
1020
- return;
1021
- }
1022
- item.isloaded = true;
1023
- this.ctx.emit("loaded", item);
1024
- });
1025
- /**
1026
- * 加载平台
1027
- * @param platform
1028
- */
1029
- __publicField(this, "loadPlatform", (url, platformNo) => {
1030
- this.currentPlatformNo.value = platformNo;
1031
- if (this.loaderStack.value.findIndex((item) => item.platformNo == platformNo) != -1) {
1032
- return;
1033
- }
1034
- const isLocal = this.isLocal(url, platformNo);
1035
- this.loaderStack.value.push({
1036
- url,
1037
- // 站点URL
1038
- platformNo,
1039
- // 平台编码
1040
- isloaded: isLocal ? true : false,
1041
- // 是否加载
1042
- isLocal
1043
- // 是否本地站点
1044
- });
1045
- });
1046
- /**
1047
- * 插入页面
1048
- * @param path
1049
- * @param loadMode 0:路由 1:Url 2:低代码
1050
- * @param param
1051
- * @param operates
1052
- */
1053
- __publicField(this, "pushPage", (path, loadMode, param, operates) => {
1054
- this.pages.push({
1055
- path,
1056
- loadMode,
1057
- param,
1058
- operates,
1059
- component: void 0
1060
- });
1061
- const data = {
1062
- platformNo: this.currentPlatformNo.value,
1063
- path,
1064
- loadMode,
1065
- param,
1066
- operates
1067
- };
1068
- bus.emit("pushPage", data);
1069
- });
1070
- /**
1071
- * 清除所有页面
1072
- */
1073
- __publicField(this, "clearAllPage", () => {
1074
- this.pages = [];
1075
- const data = { platformNo: this.currentPlatformNo.value };
1076
- bus.emit("clearAllPage", data);
1077
- });
1078
- /**
1079
- * 关闭页面
1080
- * @param path
1081
- */
1082
- __publicField(this, "closePage", (path) => {
1083
- const index = this.pages.findIndex((item) => item.path == path);
1084
- this.pages.splice(index, 1);
1085
- const data = {
1086
- platformNo: this.currentPlatformNo.value,
1087
- path
1088
- };
1089
- bus.emit("closePage", data);
1090
- });
1091
- /**
1092
- * 激活页面
1093
- * @param path
1094
- */
1095
- __publicField(this, "activePage", (path) => {
1096
- const data = {
1097
- platformNo: this.currentPlatformNo.value,
1098
- path
1099
- };
1100
- bus.emit("activePage", data);
1101
- });
1102
- /**
1103
- * 根据命令关闭页面
1104
- * @param command
1105
- */
1106
- __publicField(this, "closePageByCommand", (command) => {
1107
- const data = {
1108
- platformNo: this.currentPlatformNo.value,
1109
- command
1110
- };
1111
- bus.emit("closePageByCommand", data);
1112
- });
1113
- this.props = props;
1114
- this.ctx = ctx;
1115
- this.useBusinessLoader();
1116
- }
1117
- // 当前平台
1118
- // 私有方法 | private 方法名() {}
1119
- /**
1120
- * 初始化加载器
1121
- */
1122
- useBusinessLoader() {
1123
- onMounted(() => {
1124
- });
1125
- onUnmounted(() => {
1126
- });
1127
- }
1128
- /**
1129
- * 判断是否为本地站点
1130
- * @param urlStr URL 地址
1131
- * @param platformNo 系统代号
1132
- * @returns
1133
- */
1134
- isLocal(urlStr, platformNo) {
1135
- if (platformNo == this.storageInfo.getPlatformNo()) {
1136
- return true;
1137
- }
1138
- const url = new URL(urlStr);
1139
- const currentUrl = new URL(location.href);
1140
- return url.host == currentUrl.host && url.port == currentUrl.host;
1141
- }
1142
- //#endregion 加载器 END
1143
- };
1144
- const LoaderManage_vue_vue_type_style_index_0_scoped_ee346895_lang = "";
1145
- const _hoisted_1 = { class: "loader-manage" };
1146
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1147
- const _component_LocalLoader = resolveComponent("LocalLoader");
1148
- const _component_WebLoader = resolveComponent("WebLoader");
1149
- return openBlock(), createElementBlock("div", _hoisted_1, [
1150
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.loaderStack, (item) => {
1151
- return withDirectives((openBlock(), createElementBlock("div", {
1152
- key: item.platformNo,
1153
- class: "loader-manage_content"
1154
- }, [
1155
- item.isLocal ? (openBlock(), createBlock(_component_LocalLoader, {
1156
- key: 0,
1157
- loaderInfor: item
1158
- }, null, 8, ["loaderInfor"])) : (openBlock(), createBlock(_component_WebLoader, {
1159
- key: 1,
1160
- loaderInfor: item,
1161
- onLoaded: _ctx.doLoaded
1162
- }, null, 8, ["loaderInfor", "onLoaded"]))
1163
- ], 512)), [
1164
- [vShow, item.platformNo == _ctx.currentPlatformNo]
1165
- ]);
1166
- }), 128))
1167
- ]);
1168
- }
1169
- const LoaderManage = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-ee346895"]]);
1170
- const propDefine = {};
1171
- defineComponent({
1172
- name: "LoaderManage",
1173
- components: { LocalLoader, WebLoader },
1174
- emits: ["loaded"],
1175
- // 例如: ['clearRadioRow', 'change', 'delete', 'addchild']
1176
- props: propDefine,
1177
- setup(props, ctx) {
1178
- return new LoaderManageInstance2(props, ctx);
1179
- }
1180
- });
1181
- class LoaderManageInstance2 extends BaseInstance {
1182
- // API实例化
1183
- // private platformApi: PlatformApi = new PlatformApi();
1184
- // 全局属性
1185
- constructor(props, ctx) {
1186
- super();
1187
- __publicField(this, "props");
1188
- __publicField(this, "ctx");
1189
- //#region 加载器
1190
- // 私有属性 | private
1191
- __publicField(this, "pages", []);
1192
- // 响应属性 | ref、reactive、computed、watch
1193
- __publicField(this, "loaderStack", ref([]));
1194
- // 加载器堆栈
1195
- __publicField(this, "currentPlatformNo", ref(""));
1196
- // 响应式方法 | xxx = () => {}
1197
- /**
1198
- * Web加载器加载完成
1199
- * @param item
1200
- */
1201
- __publicField(this, "doLoaded", (platformNo) => {
1202
- const item = this.loaderStack.value.find((item2) => item2.platformNo == platformNo);
1203
- if (this.utilities.isNull(item)) {
1204
- return;
1205
- }
1206
- item.isloaded = true;
1207
- this.ctx.emit("loaded", item);
1208
- });
1209
- /**
1210
- * 加载平台
1211
- * @param platform
1212
- */
1213
- __publicField(this, "loadPlatform", (url, platformNo) => {
1214
- this.currentPlatformNo.value = platformNo;
1215
- if (this.loaderStack.value.findIndex((item) => item.platformNo == platformNo) != -1) {
1216
- return;
1217
- }
1218
- const isLocal = this.isLocal(url, platformNo);
1219
- this.loaderStack.value.push({
1220
- url,
1221
- // 站点URL
1222
- platformNo,
1223
- // 平台编码
1224
- isloaded: isLocal ? true : false,
1225
- // 是否加载
1226
- isLocal
1227
- // 是否本地站点
1228
- });
1229
- });
1230
- /**
1231
- * 插入页面
1232
- * @param path
1233
- * @param loadMode 0:路由 1:Url 2:低代码
1234
- * @param param
1235
- * @param operates
1236
- */
1237
- __publicField(this, "pushPage", (path, loadMode, param, operates) => {
1238
- this.pages.push({
1239
- path,
1240
- loadMode,
1241
- param,
1242
- operates,
1243
- component: void 0
1244
- });
1245
- const data = {
1246
- platformNo: this.currentPlatformNo.value,
1247
- path,
1248
- loadMode,
1249
- param,
1250
- operates
1251
- };
1252
- bus.emit("pushPage", data);
1253
- });
1254
- /**
1255
- * 清除所有页面
1256
- */
1257
- __publicField(this, "clearAllPage", () => {
1258
- this.pages = [];
1259
- const data = { platformNo: this.currentPlatformNo.value };
1260
- bus.emit("clearAllPage", data);
1261
- });
1262
- /**
1263
- * 关闭页面
1264
- * @param path
1265
- */
1266
- __publicField(this, "closePage", (path) => {
1267
- const index = this.pages.findIndex((item) => item.path == path);
1268
- this.pages.splice(index, 1);
1269
- const data = {
1270
- platformNo: this.currentPlatformNo.value,
1271
- path
1272
- };
1273
- bus.emit("closePage", data);
1274
- });
1275
- /**
1276
- * 激活页面
1277
- * @param path
1278
- */
1279
- __publicField(this, "activePage", (path) => {
1280
- const data = {
1281
- platformNo: this.currentPlatformNo.value,
1282
- path
1283
- };
1284
- bus.emit("activePage", data);
1285
- });
1286
- /**
1287
- * 根据命令关闭页面
1288
- * @param command
1289
- */
1290
- __publicField(this, "closePageByCommand", (command) => {
1291
- const data = {
1292
- platformNo: this.currentPlatformNo.value,
1293
- command
1294
- };
1295
- bus.emit("closePageByCommand", data);
1296
- });
1297
- this.props = props;
1298
- this.ctx = ctx;
1299
- this.useBusinessLoader();
1300
- }
1301
- // 当前平台
1302
- // 私有方法 | private 方法名() {}
1303
- /**
1304
- * 初始化加载器
1305
- */
1306
- useBusinessLoader() {
1307
- onMounted(() => {
1308
- });
1309
- onUnmounted(() => {
1310
- });
1311
- }
1312
- /**
1313
- * 判断是否为本地站点
1314
- * @param urlStr URL 地址
1315
- * @param platformNo 系统代号
1316
- * @returns
1317
- */
1318
- isLocal(urlStr, platformNo) {
1319
- if (platformNo == this.storageInfo.getPlatformNo()) {
1320
- return true;
1321
- }
1322
- const url = new URL(urlStr);
1323
- const currentUrl = new URL(location.href);
1324
- return url.host == currentUrl.host && url.port == currentUrl.host;
1325
- }
1326
- //#endregion 加载器 END
1327
- }
1328
- export {
1329
- BaseInstance,
1330
- LinkMain,
1331
- LoaderManage,
1332
- LoaderManageInstance2 as LoaderManageInstance,
1333
- MessageInstance,
1334
- ModalInstance,
1335
- Root,
1336
- initWeb,
1337
- message,
1338
- modal
1339
- };