yuang-framework-ui-pc 1.1.1 → 1.1.3

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.
@@ -0,0 +1,1041 @@
1
+ import { defineComponent, ref, shallowRef, computed, markRaw, watch, unref, shallowReactive, provide, nextTick, onMounted, resolveComponent, openBlock, createBlock, normalizeClass, createSlots, withCtx, createCommentVNode, renderSlot, renderList, normalizeProps, guardReactiveProps } from "vue";
2
+ import { useRouter } from "vue-router";
3
+ import { HomeOutlined } from "../icons";
4
+ import { useTimer, useMediaQuery, useWindowListener } from "../utils/hook";
5
+ import { debounce, isExternalLink, mapTree } from "../utils/core";
6
+ import ProIframe from "./components/pro-iframe";
7
+ import { getMenuItems, getRouteMatched, getActiveChilds, findTabByKey, getMatchedLevels, getRouteTab, findMenuByPath, findTabByPath } from "./util";
8
+ import { proLayoutProps, proLayoutEmits, PRO_LAYOUT_KEY } from "./props";
9
+ import EleAdminLayout from "../ele-admin-layout/index";
10
+ const _sfc_main = defineComponent({
11
+ name: "EleProLayout",
12
+ components: { EleAdminLayout, ProIframe },
13
+ props: proLayoutProps,
14
+ emits: proLayoutEmits,
15
+ setup(props, { emit }) {
16
+ const { currentRoute, push } = useRouter();
17
+ const [startTimer, stopTimer] = useTimer(() => props.menuHoverTimeout);
18
+ const state = { navData: [], sideData: [], boxData: [] };
19
+ const mobileQuery = "(max-width: 768px)";
20
+ const layoutRef = ref(null);
21
+ const menuData = shallowRef([]);
22
+ const navData = shallowRef([]);
23
+ const navActive = ref();
24
+ const sideData = shallowRef([]);
25
+ const sideActive = ref();
26
+ const boxData = shallowRef([]);
27
+ const boxActive = ref();
28
+ const tabData = shallowRef([]);
29
+ const tabActive = ref();
30
+ const levelData = shallowRef([]);
31
+ const mobile = ref(false);
32
+ const homeMenuPath = ref();
33
+ const isHome = ref(false);
34
+ const hideHeader = ref(false);
35
+ const hideSidebar = ref(false);
36
+ const hideSidebox = ref(false);
37
+ const hideTabs = ref(false);
38
+ const hideFooter = ref(false);
39
+ const computedNavigation = () => {
40
+ let nav = "default";
41
+ if (hideHeader.value) {
42
+ nav = "side";
43
+ } else if (hideSidebar.value && hideSidebox.value) {
44
+ nav = "top";
45
+ } else if (props.layout === "top" || props.layout === "mix") {
46
+ nav = props.layout;
47
+ }
48
+ if (mobile.value && (nav === "top" || nav === "mix")) {
49
+ nav = "default";
50
+ }
51
+ return nav;
52
+ };
53
+ const computedSideNavigation = () => {
54
+ if (!hideSidebox.value && hideSidebar.value) {
55
+ return "box";
56
+ }
57
+ return props.sidebarLayout === "mix" ? "mix" : "default";
58
+ };
59
+ const navigation = ref(computedNavigation());
60
+ const sideNavigation = ref(computedSideNavigation());
61
+ const layoutHeaders = computed(() => {
62
+ const navRoute = props.navTrigger !== "click" && props.navTrigger !== "hover";
63
+ return getMenuItems(navData.value, navRoute);
64
+ });
65
+ const layoutSidebars = computed(() => {
66
+ const menuRoute = props.itemTrigger !== "click" && props.itemTrigger !== "hover";
67
+ return getMenuItems(sideData.value, menuRoute);
68
+ });
69
+ const layoutSideboxs = computed(() => {
70
+ const boxRoute = props.boxTrigger !== "click" && props.boxTrigger !== "hover";
71
+ return getMenuItems(boxData.value, boxRoute);
72
+ });
73
+ const layoutTabs = computed(() => {
74
+ const data = props.fixedHome ? tabData.value.filter((t) => !t.home) : tabData.value;
75
+ const onlyOne = !props.fixedHome && data.length === 1;
76
+ return data.map((d) => {
77
+ return {
78
+ name: d.key,
79
+ label: d.title,
80
+ closable: onlyOne && d.home ? false : d.closable,
81
+ meta: d.meta
82
+ };
83
+ });
84
+ });
85
+ const layoutLevels = computed(() => {
86
+ const data = [];
87
+ if (!isHome.value) {
88
+ const to = homeMenuPath.value;
89
+ const is = { transform: "scale(1.13)", transformOrigin: "8px -2px" };
90
+ data.push({
91
+ key: to,
92
+ to,
93
+ icon: markRaw(HomeOutlined),
94
+ iconStyle: is
95
+ });
96
+ }
97
+ levelData.value.forEach((d) => {
98
+ data.push({ key: d.path, title: d.title });
99
+ });
100
+ return data;
101
+ });
102
+ const routeLayout = computed(() => {
103
+ if (navigation.value !== "top" && navigation.value !== "side" && !layoutSidebars.value.length && !layoutSideboxs.value.length) {
104
+ return "top";
105
+ }
106
+ return navigation.value;
107
+ });
108
+ const routeSideType = computed(() => {
109
+ if (sideNavigation.value === "mix" && !layoutSidebars.value.length) {
110
+ return "box";
111
+ }
112
+ return sideNavigation.value;
113
+ });
114
+ const isBoxSide = computed(() => routeSideType.value === "box");
115
+ const routeTabBar = computed(() => {
116
+ return hideTabs.value ? false : props.tabBar;
117
+ });
118
+ const routeMaximized = computed(() => {
119
+ const max = props.maximized;
120
+ if (hideHeader.value && hideSidebar.value && hideSidebox.value && !max) {
121
+ return true;
122
+ }
123
+ return max === true && props.expanded ? "expanded" : max;
124
+ });
125
+ const sidebar = computed(() => {
126
+ return routeLayout.value !== "top" && !isBoxSide.value || mobile.value;
127
+ });
128
+ const breadcrumbProps = computed(() => {
129
+ if (!props.breadcrumb || props.breadcrumbSeparator == null) {
130
+ return props.breadcrumb;
131
+ }
132
+ if (props.breadcrumb === true) {
133
+ return { separator: props.breadcrumbSeparator };
134
+ }
135
+ return { separator: props.breadcrumbSeparator, ...props.breadcrumb };
136
+ });
137
+ const backTopProps = computed(() => {
138
+ const backTop = props.backTop;
139
+ const r = props.backTopRight;
140
+ const b = props.backTopBottom;
141
+ const vh = props.backTopVisibilityHeight;
142
+ const t = props.backTopTarget;
143
+ if (!backTop || vh == null && r == null && b == null && t == null) {
144
+ return backTop;
145
+ }
146
+ const prop = backTop === true ? {} : { ...backTop };
147
+ if (vh != null && prop.visibilityHeight == null) {
148
+ prop.visibilityHeight = vh;
149
+ }
150
+ if (r != null && prop.right == null) {
151
+ prop.right = r;
152
+ }
153
+ if (b != null && prop.bottom == null) {
154
+ prop.bottom = b;
155
+ }
156
+ if (t != null && prop.target == null) {
157
+ prop.target = t;
158
+ }
159
+ return prop;
160
+ });
161
+ const navMenuProps = computed(() => {
162
+ const mProps = props.headerMenuProps;
163
+ const e = props.ellipsis;
164
+ const ep = props.ellipsisProps;
165
+ const mt = props.menuTrigger;
166
+ const mtet = props.menuTextEllipsisTooltip;
167
+ if (e == null && ep == null && mt == null && mtet == null) {
168
+ return mProps;
169
+ }
170
+ const prop = mProps == null ? {} : { ...mProps };
171
+ if (e != null && prop.ellipsis == null) {
172
+ prop.ellipsis = e;
173
+ }
174
+ if (ep != null && prop.ellipsisProps == null) {
175
+ prop.ellipsisProps = ep;
176
+ }
177
+ if (mt != null && prop.menuTrigger == null) {
178
+ prop.menuTrigger = mt;
179
+ }
180
+ if (mtet != null && prop.textEllipsisTooltip == null) {
181
+ prop.textEllipsisTooltip = mtet;
182
+ }
183
+ return prop;
184
+ });
185
+ const sideMenuProps = computed(() => {
186
+ const mProps = props.sidebarMenuProps;
187
+ const s = props.sidebarOpeneds;
188
+ const u = props.uniqueOpened;
189
+ const c = props.colorfulIcon;
190
+ const t = props.tooltipEffect;
191
+ const mtet = props.menuTextEllipsisTooltip;
192
+ if (s == null && u == null && c == null && t == null && mtet == null) {
193
+ return mProps;
194
+ }
195
+ const prop = mProps == null ? {} : { ...mProps };
196
+ if (s != null && prop.defaultOpeneds == null) {
197
+ prop.defaultOpeneds = s;
198
+ }
199
+ if (u != null && prop.uniqueOpened == null) {
200
+ prop.uniqueOpened = u;
201
+ }
202
+ if (c != null && prop.colorful == null) {
203
+ prop.colorful = c;
204
+ }
205
+ if (t != null && prop.popperEffect == null) {
206
+ prop.popperEffect = t;
207
+ }
208
+ if (mtet != null && prop.textEllipsisTooltip == null) {
209
+ prop.textEllipsisTooltip = mtet;
210
+ }
211
+ return prop;
212
+ });
213
+ const boxMenuProps = computed(() => {
214
+ const mProps = props.sideboxMenuProps;
215
+ const ci = props.colorfulIcon;
216
+ const te = props.tooltipEffect;
217
+ const mtet = props.menuTextEllipsisTooltip;
218
+ if (ci == null && te == null && mtet == null) {
219
+ return mProps;
220
+ }
221
+ const prop = mProps == null ? {} : { ...mProps };
222
+ if (ci != null && prop.popupColorful == null) {
223
+ prop.popupColorful = ci;
224
+ }
225
+ if (te != null && prop.popperEffect == null) {
226
+ prop.popperEffect = te;
227
+ }
228
+ if (mtet != null && prop.textEllipsisTooltip == null) {
229
+ prop.textEllipsisTooltip = mtet;
230
+ }
231
+ return prop;
232
+ });
233
+ const updateNavigation = () => {
234
+ const value = computedNavigation();
235
+ if (navigation.value !== value) {
236
+ navigation.value = value;
237
+ return true;
238
+ }
239
+ };
240
+ const updateSideNavigation = () => {
241
+ const value = computedSideNavigation();
242
+ if (sideNavigation.value !== value) {
243
+ sideNavigation.value = value;
244
+ return true;
245
+ }
246
+ };
247
+ const resetMenuState = () => {
248
+ if (!state.isHover) {
249
+ return;
250
+ }
251
+ startTimer(() => {
252
+ state.isHover = false;
253
+ const isMixSide = sideNavigation.value === "mix" || sideNavigation.value === "box";
254
+ if (navActive.value !== state.navActive) {
255
+ navActive.value = state.navActive;
256
+ if (isMixSide) {
257
+ boxData.value = state.boxData;
258
+ } else {
259
+ sideData.value = state.sideData;
260
+ }
261
+ }
262
+ if (isMixSide && boxActive.value !== state.boxActive) {
263
+ boxActive.value = state.boxActive;
264
+ sideData.value = state.sideData;
265
+ }
266
+ });
267
+ };
268
+ const updateCollapse = (collapse) => {
269
+ if (collapse !== props.collapse) {
270
+ emit("update:collapse", collapse);
271
+ }
272
+ };
273
+ const updateMaximized = (maximized) => {
274
+ if (maximized !== props.maximized) {
275
+ emit("update:maximized", maximized);
276
+ }
277
+ };
278
+ const handleLogoClick = (e) => {
279
+ emit("logoClick", isHome.value, e);
280
+ };
281
+ const handleHeadMenuOpen = (index2, indexPath) => {
282
+ emit("headMenuOpen", index2, indexPath);
283
+ };
284
+ const handleHeadMenuClose = (index2, indexPath) => {
285
+ emit("headMenuClose", index2, indexPath);
286
+ };
287
+ const handleHeadMenuItemClick = (item, e) => {
288
+ const path = item.index;
289
+ const trigger = props.navTrigger;
290
+ if (!path || trigger !== "click" && trigger !== "hover") {
291
+ return;
292
+ }
293
+ if (isExternalLink(path)) {
294
+ e.stopPropagation();
295
+ if (props.beforeClick && props.beforeClick(item, e) === false) {
296
+ return;
297
+ }
298
+ window.open(path);
299
+ return;
300
+ }
301
+ const childMenus = getActiveChilds(navData.value, path, "tempChildren");
302
+ const isChild = !childMenus.some((d) => {
303
+ var _a;
304
+ return !((_a = d.meta) == null ? void 0 : _a.hide);
305
+ });
306
+ if (trigger !== "click" && !isChild) {
307
+ e.stopPropagation();
308
+ return;
309
+ }
310
+ if (props.beforeClick && props.beforeClick(item, e) === false) {
311
+ return;
312
+ }
313
+ if (isChild && path !== unref(currentRoute).fullPath) {
314
+ push(path);
315
+ return;
316
+ }
317
+ e.stopPropagation();
318
+ if (navActive.value !== path) {
319
+ navActive.value = path;
320
+ const isMixSide = sideNavigation.value === "mix" || sideNavigation.value === "box";
321
+ const isCollapse = sideNavigation.value === "box" || props.collapse && !mobile.value;
322
+ if (!isMixSide) {
323
+ sideData.value = childMenus;
324
+ return;
325
+ }
326
+ boxData.value = childMenus.map((d) => {
327
+ return {
328
+ ...d,
329
+ children: isCollapse ? d.children : void 0,
330
+ tempChildren: d.children
331
+ };
332
+ });
333
+ }
334
+ };
335
+ const handleHeadMenuItemMouseenter = (item, e) => {
336
+ if (navigation.value !== "mix") {
337
+ return;
338
+ }
339
+ stopTimer();
340
+ const path = item.index;
341
+ const trigger = props.navTrigger;
342
+ if (trigger !== "hover" || !path) {
343
+ return;
344
+ }
345
+ if (!isExternalLink(path) && props.beforeClick && props.beforeClick(item, e) === false) {
346
+ return;
347
+ }
348
+ const temp = getActiveChilds(navData.value, path, "tempChildren");
349
+ if (navActive.value !== path) {
350
+ state.isHover = true;
351
+ navActive.value = temp.some((d) => {
352
+ var _a;
353
+ return !((_a = d.meta) == null ? void 0 : _a.hide);
354
+ }) ? path : void 0;
355
+ const isMixSide = sideNavigation.value === "mix" || sideNavigation.value === "box";
356
+ if (!isMixSide) {
357
+ sideData.value = temp;
358
+ return;
359
+ }
360
+ boxData.value = temp.map((d) => {
361
+ return {
362
+ ...d,
363
+ children: props.collapse ? d.children : void 0,
364
+ tempChildren: d.children
365
+ };
366
+ });
367
+ }
368
+ };
369
+ const handleHeadMouseenter = () => {
370
+ stopTimer();
371
+ };
372
+ const handleHeadMouseleave = () => {
373
+ resetMenuState();
374
+ };
375
+ const handleBoxMenuItemClick = (item, e) => {
376
+ const path = item.index;
377
+ const trigger = props.boxTrigger;
378
+ if (!path || trigger !== "click" && trigger !== "hover") {
379
+ return;
380
+ }
381
+ if (isExternalLink(path)) {
382
+ e.stopPropagation();
383
+ if (props.beforeClick && props.beforeClick(item, e) === false) {
384
+ return;
385
+ }
386
+ window.open(path);
387
+ return;
388
+ }
389
+ if (props.collapse) {
390
+ if (props.beforeClick && props.beforeClick(item, e) === false) {
391
+ return;
392
+ }
393
+ if (path !== unref(currentRoute).fullPath) {
394
+ push(path);
395
+ }
396
+ return;
397
+ }
398
+ const childMenus = getActiveChilds(boxData.value, path, "tempChildren");
399
+ const isChild = !childMenus.some((d) => {
400
+ var _a;
401
+ return !((_a = d.meta) == null ? void 0 : _a.hide);
402
+ });
403
+ if (trigger !== "click" && !isChild) {
404
+ e.stopPropagation();
405
+ return;
406
+ }
407
+ if (props.beforeClick && props.beforeClick(item, e) === false) {
408
+ return;
409
+ }
410
+ if (isChild && path !== unref(currentRoute).fullPath) {
411
+ push(path);
412
+ return;
413
+ }
414
+ e.stopPropagation();
415
+ if (boxActive.value !== path) {
416
+ boxActive.value = path;
417
+ sideData.value = childMenus;
418
+ }
419
+ };
420
+ const handleBoxMenuItemMouseenter = (item, e) => {
421
+ if (props.collapse) {
422
+ return;
423
+ }
424
+ stopTimer();
425
+ const path = item.index;
426
+ const trigger = props.boxTrigger;
427
+ if (trigger !== "hover" || !path) {
428
+ return;
429
+ }
430
+ if (!isExternalLink(path) && props.beforeClick && props.beforeClick(item, e) === false) {
431
+ return;
432
+ }
433
+ const temp = getActiveChilds(boxData.value, path, "tempChildren");
434
+ if (boxActive.value !== path) {
435
+ state.isHover = true;
436
+ boxActive.value = temp.some((d) => {
437
+ var _a;
438
+ return !((_a = d.meta) == null ? void 0 : _a.hide);
439
+ }) ? path : void 0;
440
+ sideData.value = temp;
441
+ }
442
+ };
443
+ const handleBoxMouseEnter = () => {
444
+ stopTimer();
445
+ };
446
+ const handleBoxMouseLeave = () => {
447
+ resetMenuState();
448
+ };
449
+ const handleSideMenuOpen = (index2, indexPath) => {
450
+ emit("sideMenuOpen", index2, indexPath);
451
+ };
452
+ const handleSideMenuClose = (index2, indexPath) => {
453
+ emit("sideMenuClose", index2, indexPath);
454
+ };
455
+ const handleSideMenuItemClick = (item, e) => {
456
+ const path = item.index;
457
+ const trigger = props.itemTrigger;
458
+ if (!path || trigger !== "click" && trigger !== "hover") {
459
+ return;
460
+ }
461
+ if (props.beforeClick && props.beforeClick(item, e) === false) {
462
+ return;
463
+ }
464
+ if (isExternalLink(path)) {
465
+ e.stopPropagation();
466
+ window.open(path);
467
+ return;
468
+ }
469
+ sideActive.value = path;
470
+ if (path !== unref(currentRoute).fullPath) {
471
+ push(path);
472
+ }
473
+ };
474
+ const handleSideMouseEnter = () => {
475
+ stopTimer();
476
+ };
477
+ const handleSideMouseLeave = () => {
478
+ resetMenuState();
479
+ };
480
+ const handleTabClick = (option) => {
481
+ const key = option.name;
482
+ const item = findTabByKey(key, props.tabs);
483
+ const opt = { key, item, active: tabActive.value };
484
+ emit("tabClick", opt);
485
+ };
486
+ const handleTabRemove = (key) => {
487
+ const item = findTabByKey(key, props.tabs);
488
+ const opt = { key, item, active: tabActive.value };
489
+ emit("tabRemove", opt);
490
+ };
491
+ const handleTabContextMenu = (option) => {
492
+ const opt = {
493
+ key: option.name,
494
+ item: findTabByKey(option.name, props.tabs),
495
+ active: tabActive.value,
496
+ command: option.command
497
+ };
498
+ emit("tabContextMenu", opt);
499
+ };
500
+ const handleTabSortChange = (data) => {
501
+ const result = data.map((d) => {
502
+ return findTabByKey(d.name, props.tabs);
503
+ });
504
+ if (props.fixedHome && props.tabs != null) {
505
+ const homeTab = props.tabs.find((t) => t.home);
506
+ if (homeTab) {
507
+ result.unshift(homeTab);
508
+ }
509
+ }
510
+ emit("tabSortChange", result);
511
+ };
512
+ const getContentElem = () => {
513
+ if (!layoutRef.value) {
514
+ return null;
515
+ }
516
+ return layoutRef.value.getContentEl();
517
+ };
518
+ const handleRouteChange = (route) => {
519
+ const { path, meta } = route;
520
+ hideFooter.value = !!meta.hideFooter;
521
+ const contentEl = getContentElem();
522
+ if (props.autoScrollTop && contentEl) {
523
+ contentEl.scrollTop = 0;
524
+ }
525
+ if (props.redirectPath && path.startsWith(props.redirectPath)) {
526
+ return;
527
+ }
528
+ hideSidebar.value = !!meta.hideSidebar;
529
+ hideSidebox.value = props.sidebarLayout === "mix" ? !!meta.hideSidebox : true;
530
+ hideHeader.value = !!meta.hideHeader;
531
+ hideTabs.value = !!meta.hideTabs;
532
+ const navigationIsChanged = updateNavigation();
533
+ const sideNavigationIsChanged = updateSideNavigation();
534
+ const { active, title, matched, activeOther } = getRouteMatched(
535
+ route,
536
+ menuData.value
537
+ );
538
+ levelData.value = getMatchedLevels(
539
+ matched,
540
+ activeOther,
541
+ route,
542
+ menuData.value,
543
+ tabData.value
544
+ );
545
+ const t = getRouteTab(route, tabData.value, homeMenuPath.value, title);
546
+ isHome.value = t.home;
547
+ tabActive.value = t.key;
548
+ emit("tabAdd", t);
549
+ if (!navigationIsChanged && !sideNavigationIsChanged) {
550
+ updateMenuActive(active, matched);
551
+ if (navigation.value === "mix" || sideNavigation.value === "mix" || sideNavigation.value === "box") {
552
+ splitMenuData();
553
+ }
554
+ }
555
+ if (mobile.value) {
556
+ updateCollapse(true);
557
+ }
558
+ };
559
+ const updateMenuActive = (active, matched) => {
560
+ const [active1, active2] = (matched == null ? void 0 : matched.length) ? [matched[0].path, (matched[1] ?? matched[0]).path] : [];
561
+ if (navigation.value === "top") {
562
+ navActive.value = active;
563
+ boxActive.value = void 0;
564
+ } else if (navigation.value === "mix") {
565
+ navActive.value = active1;
566
+ boxActive.value = active2;
567
+ } else {
568
+ navActive.value = void 0;
569
+ boxActive.value = active1;
570
+ }
571
+ sideActive.value = active;
572
+ state.navActive = navActive.value;
573
+ state.boxActive = boxActive.value;
574
+ state.sideActive = sideActive.value;
575
+ };
576
+ const splitMenuData = () => {
577
+ var _a;
578
+ const isTopNav = navigation.value === "top";
579
+ const isMixNav = navigation.value === "mix";
580
+ const isMixSide = sideNavigation.value === "mix" || sideNavigation.value === "box";
581
+ const isCollapse = sideNavigation.value === "box" || props.collapse && !mobile.value;
582
+ if (!((_a = menuData.value) == null ? void 0 : _a.length)) {
583
+ navData.value = [];
584
+ boxData.value = [];
585
+ sideData.value = [];
586
+ } else if (isTopNav) {
587
+ navData.value = menuData.value;
588
+ boxData.value = [];
589
+ sideData.value = [];
590
+ } else if (isMixNav) {
591
+ navData.value = menuData.value.map((d) => {
592
+ return { ...d, children: void 0, tempChildren: d.children };
593
+ });
594
+ const childMenus = getActiveChilds(menuData.value, navActive.value);
595
+ if (!childMenus.length) {
596
+ boxData.value = [];
597
+ sideData.value = [];
598
+ } else if (isMixSide) {
599
+ boxData.value = childMenus.map((d) => {
600
+ return {
601
+ ...d,
602
+ children: isCollapse ? d.children : void 0,
603
+ tempChildren: d.children
604
+ };
605
+ });
606
+ sideData.value = getActiveChilds(childMenus, boxActive.value);
607
+ } else {
608
+ boxData.value = [];
609
+ sideData.value = childMenus;
610
+ }
611
+ } else {
612
+ navData.value = [];
613
+ if (isMixSide) {
614
+ boxData.value = menuData.value.map((d) => {
615
+ return {
616
+ ...d,
617
+ children: isCollapse ? d.children : void 0,
618
+ tempChildren: d.children
619
+ };
620
+ });
621
+ sideData.value = getActiveChilds(menuData.value, boxActive.value);
622
+ } else {
623
+ boxData.value = [];
624
+ sideData.value = menuData.value;
625
+ }
626
+ }
627
+ state.navData = navData.value;
628
+ state.boxData = boxData.value;
629
+ state.sideData = sideData.value;
630
+ };
631
+ const updateMenuData = () => {
632
+ let home;
633
+ menuData.value = mapTree(props.menus, (item) => {
634
+ var _a, _b;
635
+ if (!home && !((_a = item.children) == null ? void 0 : _a.length)) {
636
+ home = item;
637
+ }
638
+ const title = routeI18n(item.path, item) || ((_b = item.meta) == null ? void 0 : _b.title);
639
+ return { ...item, meta: { ...item.meta, title } };
640
+ });
641
+ splitMenuData();
642
+ homeMenuPath.value = props.homePath || (home == null ? void 0 : home.path) || "/";
643
+ };
644
+ const updateTabData = () => {
645
+ if (!props.tabs) {
646
+ tabData.value = [];
647
+ return;
648
+ }
649
+ tabData.value = props.tabs.map((item) => {
650
+ const m = findMenuByPath(item.path, menuData.value);
651
+ return {
652
+ ...item,
653
+ title: routeI18n(item.path, m, item) || item.title
654
+ };
655
+ });
656
+ };
657
+ const updateLevelData = () => {
658
+ levelData.value = levelData.value.map((item) => {
659
+ var _a;
660
+ const t = findTabByPath(item.path, tabData.value);
661
+ const m = findMenuByPath(item.path, menuData.value);
662
+ const title = (t == null ? void 0 : t.title) || ((_a = m == null ? void 0 : m.meta) == null ? void 0 : _a.title) || routeI18n(item.path, m, t, item);
663
+ return { ...item, title: title || item.title };
664
+ });
665
+ };
666
+ const routeI18n = (path, menu, tab, level) => {
667
+ if (props.i18n && path) {
668
+ return props.i18n({
669
+ locale: props.locale,
670
+ path,
671
+ menu,
672
+ tab,
673
+ level
674
+ });
675
+ }
676
+ };
677
+ watch(
678
+ () => props.menus,
679
+ () => {
680
+ updateMenuData();
681
+ },
682
+ { deep: true }
683
+ );
684
+ watch(
685
+ () => props.tabs,
686
+ () => {
687
+ updateTabData();
688
+ updateLevelData();
689
+ },
690
+ { deep: true }
691
+ );
692
+ watch([() => props.layout, mobile], () => {
693
+ updateNavigation();
694
+ });
695
+ watch(
696
+ () => props.sidebarLayout,
697
+ () => {
698
+ updateSideNavigation();
699
+ }
700
+ );
701
+ watch([navigation, sideNavigation], () => {
702
+ const route = unref(currentRoute);
703
+ const { active, matched } = getRouteMatched(route, menuData.value);
704
+ updateMenuActive(active, matched);
705
+ splitMenuData();
706
+ });
707
+ watch(
708
+ () => props.collapse,
709
+ () => {
710
+ if (sideNavigation.value === "mix" && !mobile.value) {
711
+ if (props.collapse) {
712
+ boxData.value = boxData.value.map((d) => {
713
+ return { ...d, children: d.tempChildren };
714
+ });
715
+ } else {
716
+ boxData.value = boxData.value.map((d) => {
717
+ return { ...d, children: void 0 };
718
+ });
719
+ }
720
+ state.boxData = boxData.value;
721
+ }
722
+ }
723
+ );
724
+ watch(
725
+ () => props.locale,
726
+ () => {
727
+ updateMenuData();
728
+ updateTabData();
729
+ updateLevelData();
730
+ },
731
+ { immediate: true }
732
+ );
733
+ watch(
734
+ currentRoute,
735
+ (route) => {
736
+ handleRouteChange(unref(route));
737
+ },
738
+ { immediate: true }
739
+ );
740
+ const layoutProvide = shallowReactive({
741
+ keepAlive: props.tabBar && props.keepAlive,
742
+ responsive: props.responsive
743
+ });
744
+ provide(PRO_LAYOUT_KEY, layoutProvide);
745
+ watch([() => props.tabBar, () => props.keepAlive], () => {
746
+ layoutProvide.keepAlive = props.tabBar && props.keepAlive;
747
+ });
748
+ const [media, startMedia, stopMedia] = useMediaQuery(mobileQuery, () => {
749
+ const isMobile = props.responsive ? media.matches : false;
750
+ if (mobile.value !== isMobile) {
751
+ mobile.value = isMobile;
752
+ updateCollapse(mobile.value);
753
+ }
754
+ });
755
+ watch(
756
+ () => props.responsive,
757
+ () => {
758
+ layoutProvide.responsive = props.responsive;
759
+ if (props.responsive) {
760
+ startMedia();
761
+ } else {
762
+ stopMedia();
763
+ }
764
+ },
765
+ { immediate: true }
766
+ );
767
+ useWindowListener("keydown", (e) => {
768
+ if (e.keyCode === 27 && props.compressOnEsc && props.maximized) {
769
+ e.stopPropagation();
770
+ updateMaximized(false);
771
+ }
772
+ });
773
+ const handleResize = () => {
774
+ const el = getContentElem();
775
+ if (el) {
776
+ const width = el.clientWidth;
777
+ const height = el.clientHeight;
778
+ if (width !== state.contentWidth || height !== state.contentHeight) {
779
+ state.contentWidth = width;
780
+ state.contentHeight = height;
781
+ emit("bodySizeChange", { width, height, mobile: mobile.value });
782
+ }
783
+ }
784
+ };
785
+ useWindowListener(debounce(() => handleResize(), 500));
786
+ const [startBodyResizeTimer] = useTimer(600);
787
+ watch([() => props.collapse, () => props.compact], () => {
788
+ startBodyResizeTimer(() => {
789
+ handleResize();
790
+ });
791
+ });
792
+ watch(
793
+ [
794
+ routeLayout,
795
+ routeSideType,
796
+ routeTabBar,
797
+ routeMaximized,
798
+ () => props.fluid
799
+ ],
800
+ () => {
801
+ nextTick(() => {
802
+ handleResize();
803
+ });
804
+ }
805
+ );
806
+ onMounted(() => {
807
+ handleResize();
808
+ });
809
+ return {
810
+ layoutRef,
811
+ navActive,
812
+ sideActive,
813
+ boxActive,
814
+ tabData,
815
+ tabActive,
816
+ levelData,
817
+ mobile,
818
+ homeMenuPath,
819
+ isHome,
820
+ hideFooter,
821
+ layoutHeaders,
822
+ layoutSidebars,
823
+ layoutSideboxs,
824
+ layoutTabs,
825
+ layoutLevels,
826
+ routeLayout,
827
+ routeSideType,
828
+ isBoxSide,
829
+ routeTabBar,
830
+ routeMaximized,
831
+ sidebar,
832
+ breadcrumbProps,
833
+ backTopProps,
834
+ navMenuProps,
835
+ sideMenuProps,
836
+ boxMenuProps,
837
+ updateCollapse,
838
+ handleLogoClick,
839
+ handleHeadMenuOpen,
840
+ handleHeadMenuClose,
841
+ handleHeadMenuItemClick,
842
+ handleHeadMenuItemMouseenter,
843
+ handleHeadMouseenter,
844
+ handleHeadMouseleave,
845
+ handleBoxMenuItemClick,
846
+ handleBoxMenuItemMouseenter,
847
+ handleBoxMouseEnter,
848
+ handleBoxMouseLeave,
849
+ handleSideMenuOpen,
850
+ handleSideMenuClose,
851
+ handleSideMenuItemClick,
852
+ handleSideMouseEnter,
853
+ handleSideMouseLeave,
854
+ handleTabClick,
855
+ handleTabRemove,
856
+ handleTabContextMenu,
857
+ handleTabSortChange
858
+ };
859
+ }
860
+ });
861
+ const _export_sfc = (sfc, props) => {
862
+ const target = sfc.__vccOpts || sfc;
863
+ for (const [key, val] of props) {
864
+ target[key] = val;
865
+ }
866
+ return target;
867
+ };
868
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
869
+ const _component_ProIframe = resolveComponent("ProIframe");
870
+ const _component_EleAdminLayout = resolveComponent("EleAdminLayout");
871
+ return openBlock(), createBlock(_component_EleAdminLayout, {
872
+ ref: "layoutRef",
873
+ height: _ctx.height,
874
+ headerMenus: _ctx.layoutHeaders,
875
+ headerActive: _ctx.navActive,
876
+ sidebarMenus: _ctx.layoutSidebars,
877
+ sidebarActive: _ctx.sideActive,
878
+ sideboxMenus: _ctx.layoutSideboxs,
879
+ sideboxActive: _ctx.isBoxSide || _ctx.collapse && !_ctx.mobile ? _ctx.sideActive : _ctx.boxActive,
880
+ tabs: _ctx.layoutTabs,
881
+ tabActive: _ctx.tabActive,
882
+ levels: _ctx.layoutLevels,
883
+ collapse: _ctx.collapse,
884
+ compact: _ctx.compact,
885
+ maximized: _ctx.routeMaximized,
886
+ tabBar: _ctx.routeTabBar,
887
+ breadcrumb: _ctx.breadcrumbProps,
888
+ backTop: _ctx.backTopProps,
889
+ headerMenuProps: _ctx.navMenuProps,
890
+ sidebarMenuProps: _ctx.sideMenuProps,
891
+ sideboxMenuProps: _ctx.boxMenuProps,
892
+ layout: _ctx.routeLayout,
893
+ sidebarLayout: _ctx.routeSideType,
894
+ headerStyle: _ctx.headerStyle,
895
+ sidebarStyle: _ctx.sidebarStyle,
896
+ tabStyle: _ctx.tabStyle,
897
+ fixedHeader: _ctx.fixedHeader,
898
+ fixedSidebar: _ctx.fixedSidebar,
899
+ fixedBody: _ctx.fixedBody,
900
+ logoInHeader: _ctx.logoInHeader,
901
+ fixedHome: _ctx.fixedHome,
902
+ homePath: _ctx.homeMenuPath,
903
+ isHome: _ctx.isHome,
904
+ tabContextMenu: _ctx.tabContextMenu,
905
+ tabContextMenus: _ctx.tabContextMenus,
906
+ tabSortable: _ctx.tabSortable,
907
+ headerTitleSlot: _ctx.headerTitleSlot,
908
+ headerIconSlot: _ctx.headerIconSlot,
909
+ sidebarTitleSlot: _ctx.sidebarTitleSlot,
910
+ sidebarIconSlot: _ctx.sidebarIconSlot,
911
+ sideboxTitleSlot: _ctx.sideboxTitleSlot,
912
+ sideboxIconSlot: _ctx.sideboxIconSlot,
913
+ headerCustomStyle: _ctx.headerCustomStyle,
914
+ sidebarCustomStyle: _ctx.sidebarCustomStyle,
915
+ sideboxCustomStyle: _ctx.sideboxCustomStyle,
916
+ tabsCustomStyle: _ctx.tabsCustomStyle,
917
+ contentCustomStyle: _ctx.contentCustomStyle,
918
+ logoStyle: _ctx.logoStyle,
919
+ logoTitleStyle: _ctx.logoTitleStyle,
920
+ headerMenusStyle: _ctx.headerMenusStyle,
921
+ sidebarMenusStyle: _ctx.sidebarMenusStyle,
922
+ sideboxMenusStyle: _ctx.sideboxMenusStyle,
923
+ mobile: _ctx.mobile,
924
+ class: normalizeClass(["ele-pro-layout", { "ele-admin-limited": !_ctx.fluid }]),
925
+ "onUpdate:collapse": _ctx.updateCollapse,
926
+ onLogoClick: _ctx.handleLogoClick,
927
+ onHeadMenuOpen: _ctx.handleHeadMenuOpen,
928
+ onHeadMenuClose: _ctx.handleHeadMenuClose,
929
+ onHeadMenuItemClick: _ctx.handleHeadMenuItemClick,
930
+ onHeadMenuItemMouseenter: _ctx.handleHeadMenuItemMouseenter,
931
+ onHeadMouseenter: _ctx.handleHeadMouseenter,
932
+ onHeadMouseleave: _ctx.handleHeadMouseleave,
933
+ onBoxMenuItemClick: _ctx.handleBoxMenuItemClick,
934
+ onBoxMenuItemMouseenter: _ctx.handleBoxMenuItemMouseenter,
935
+ onBoxMouseenter: _ctx.handleBoxMouseEnter,
936
+ onBoxMouseleave: _ctx.handleBoxMouseLeave,
937
+ onSideMenuOpen: _ctx.handleSideMenuOpen,
938
+ onSideMenuClose: _ctx.handleSideMenuClose,
939
+ onSideMenuItemClick: _ctx.handleSideMenuItemClick,
940
+ onSideMouseenter: _ctx.handleSideMouseEnter,
941
+ onSideMouseleave: _ctx.handleSideMouseLeave,
942
+ onTabClick: _ctx.handleTabClick,
943
+ onTabRemove: _ctx.handleTabRemove,
944
+ onTabContextMenu: _ctx.handleTabContextMenu,
945
+ onTabSortChange: _ctx.handleTabSortChange
946
+ }, createSlots({
947
+ body: withCtx(() => [
948
+ _ctx.tabBar && _ctx.keepAlive ? (openBlock(), createBlock(_component_ProIframe, {
949
+ key: 0,
950
+ keepAlive: _ctx.keepAlive,
951
+ transitionName: _ctx.transitionName,
952
+ transitionDelay: _ctx.transitionDelay,
953
+ tabData: _ctx.tabData,
954
+ tabActive: _ctx.tabActive
955
+ }, null, 8, ["keepAlive", "transitionName", "transitionDelay", "tabData", "tabActive"])) : createCommentVNode("", true)
956
+ ]),
957
+ default: withCtx(() => [
958
+ renderSlot(_ctx.$slots, "default"),
959
+ !_ctx.hideFooter ? renderSlot(_ctx.$slots, "footer", { key: 0 }) : createCommentVNode("", true)
960
+ ]),
961
+ _: 2
962
+ }, [
963
+ _ctx.$slots.logo ? {
964
+ name: "logo",
965
+ fn: withCtx(() => [
966
+ renderSlot(_ctx.$slots, "logo", {
967
+ collapse: _ctx.collapse,
968
+ sidebar: _ctx.sidebar
969
+ })
970
+ ]),
971
+ key: "0"
972
+ } : void 0,
973
+ _ctx.$slots.logoTitle ? {
974
+ name: "logoTitle",
975
+ fn: withCtx(() => [
976
+ renderSlot(_ctx.$slots, "logoTitle", {
977
+ collapse: _ctx.collapse,
978
+ sidebar: _ctx.sidebar
979
+ })
980
+ ]),
981
+ key: "1"
982
+ } : void 0,
983
+ _ctx.$slots.breadcrumb ? {
984
+ name: "breadcrumb",
985
+ fn: withCtx(() => [
986
+ renderSlot(_ctx.$slots, "breadcrumb", {
987
+ levels: _ctx.levelData,
988
+ isHome: _ctx.isHome,
989
+ homePath: _ctx.homeMenuPath,
990
+ sidebar: _ctx.sidebar
991
+ })
992
+ ]),
993
+ key: "2"
994
+ } : void 0,
995
+ _ctx.$slots.left ? {
996
+ name: "left",
997
+ fn: withCtx(() => [
998
+ renderSlot(_ctx.$slots, "left", { sidebar: _ctx.sidebar })
999
+ ]),
1000
+ key: "3"
1001
+ } : void 0,
1002
+ _ctx.$slots.center ? {
1003
+ name: "center",
1004
+ fn: withCtx(() => [
1005
+ renderSlot(_ctx.$slots, "center", { sidebar: _ctx.sidebar })
1006
+ ]),
1007
+ key: "4"
1008
+ } : void 0,
1009
+ _ctx.$slots.right ? {
1010
+ name: "right",
1011
+ fn: withCtx(() => [
1012
+ renderSlot(_ctx.$slots, "right", { sidebar: _ctx.sidebar })
1013
+ ]),
1014
+ key: "5"
1015
+ } : void 0,
1016
+ renderList(Object.keys(_ctx.$slots).filter(
1017
+ (k) => ![
1018
+ "default",
1019
+ "logo",
1020
+ "logoTitle",
1021
+ "breadcrumb",
1022
+ "left",
1023
+ "center",
1024
+ "right",
1025
+ "footer",
1026
+ "body"
1027
+ ].includes(k)
1028
+ ), (name) => {
1029
+ return {
1030
+ name,
1031
+ fn: withCtx((slotProps) => [
1032
+ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(slotProps || {})))
1033
+ ])
1034
+ };
1035
+ })
1036
+ ]), 1032, ["height", "headerMenus", "headerActive", "sidebarMenus", "sidebarActive", "sideboxMenus", "sideboxActive", "tabs", "tabActive", "levels", "collapse", "compact", "maximized", "tabBar", "breadcrumb", "backTop", "headerMenuProps", "sidebarMenuProps", "sideboxMenuProps", "layout", "sidebarLayout", "headerStyle", "sidebarStyle", "tabStyle", "fixedHeader", "fixedSidebar", "fixedBody", "logoInHeader", "fixedHome", "homePath", "isHome", "tabContextMenu", "tabContextMenus", "tabSortable", "headerTitleSlot", "headerIconSlot", "sidebarTitleSlot", "sidebarIconSlot", "sideboxTitleSlot", "sideboxIconSlot", "headerCustomStyle", "sidebarCustomStyle", "sideboxCustomStyle", "tabsCustomStyle", "contentCustomStyle", "logoStyle", "logoTitleStyle", "headerMenusStyle", "sidebarMenusStyle", "sideboxMenusStyle", "mobile", "class", "onUpdate:collapse", "onLogoClick", "onHeadMenuOpen", "onHeadMenuClose", "onHeadMenuItemClick", "onHeadMenuItemMouseenter", "onHeadMouseenter", "onHeadMouseleave", "onBoxMenuItemClick", "onBoxMenuItemMouseenter", "onBoxMouseenter", "onBoxMouseleave", "onSideMenuOpen", "onSideMenuClose", "onSideMenuItemClick", "onSideMouseenter", "onSideMouseleave", "onTabClick", "onTabRemove", "onTabContextMenu", "onTabSortChange"]);
1037
+ }
1038
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
1039
+ export {
1040
+ index as default
1041
+ };