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.
- package/README.md +13 -0
- package/es/ele-pro-layout/components/pro-iframe.d.ts +39 -0
- package/es/ele-pro-layout/components/pro-iframe.js +124 -0
- package/es/ele-pro-layout/index.d.ts +407 -0
- package/es/ele-pro-layout/index.js +1041 -0
- package/es/ele-pro-layout/props.d.ts +253 -0
- package/es/ele-pro-layout/props.js +237 -0
- package/es/ele-pro-layout/style/index.d.ts +1 -0
- package/es/ele-pro-layout/style/index.js +2 -0
- package/es/ele-pro-layout/{types.ts → types.d.ts} +11 -2
- package/es/ele-pro-layout/util.d.ts +88 -0
- package/es/ele-pro-layout/util.js +171 -0
- package/es/utils/resolvers.js +1 -1
- package/lib/utils/resolvers.cjs +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +58 -58
- package/es/ele-pro-layout/components/pro-iframe.vue +0 -120
- package/es/ele-pro-layout/index.vue +0 -1277
- package/es/ele-pro-layout/props.ts +0 -255
- package/es/ele-pro-layout/style/index.ts +0 -2
- package/es/ele-pro-layout/util.ts +0 -277
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { inject, computed } from "vue";
|
|
2
|
+
import { findTree, mapTree, omit } from "../utils/core";
|
|
3
|
+
import { LAYOUT_KEY } from "../ele-admin-layout/props";
|
|
4
|
+
import { PRO_LAYOUT_KEY } from "./props";
|
|
5
|
+
function findMenuByPath(path, menus) {
|
|
6
|
+
return path == null ? void 0 : findTree(menus, (d) => path === d.path);
|
|
7
|
+
}
|
|
8
|
+
function findTabByPath(path, tabs) {
|
|
9
|
+
if (path != null && tabs != null) {
|
|
10
|
+
return tabs.find((d) => path === d.key || path === d.fullPath);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function findTabByKey(key, tabs) {
|
|
14
|
+
if (key != null && tabs != null) {
|
|
15
|
+
return tabs.find((d) => key === d.key);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function getMatchedMenus(path, menus, parents) {
|
|
19
|
+
var _a;
|
|
20
|
+
for (const m of menus) {
|
|
21
|
+
const p = parents ? [...parents, m] : [m];
|
|
22
|
+
if (m.path === path) {
|
|
23
|
+
return p;
|
|
24
|
+
} else if ((_a = m.children) == null ? void 0 : _a.length) {
|
|
25
|
+
const result = getMatchedMenus(path, m.children, p);
|
|
26
|
+
if (result) {
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function getRouteMatched(route, menus) {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const { path, fullPath, meta } = route;
|
|
35
|
+
if (meta == null ? void 0 : meta.active) {
|
|
36
|
+
const m2 = findMenuByPath(fullPath, menus) ?? findMenuByPath(path, menus);
|
|
37
|
+
return {
|
|
38
|
+
active: meta.active,
|
|
39
|
+
activeOther: true,
|
|
40
|
+
title: ((_a = m2 == null ? void 0 : m2.meta) == null ? void 0 : _a.title) ?? meta.title,
|
|
41
|
+
matched: getMatchedMenus(meta.active, menus)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const fm = findMenuByPath(fullPath, menus);
|
|
45
|
+
if (fm) {
|
|
46
|
+
return {
|
|
47
|
+
active: fullPath,
|
|
48
|
+
title: ((_b = fm.meta) == null ? void 0 : _b.title) ?? meta.title,
|
|
49
|
+
matched: getMatchedMenus(fullPath, menus)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const m = findMenuByPath(path, menus);
|
|
53
|
+
return {
|
|
54
|
+
active: path,
|
|
55
|
+
title: ((_c = m == null ? void 0 : m.meta) == null ? void 0 : _c.title) ?? meta.title,
|
|
56
|
+
matched: getMatchedMenus(path, menus)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getMatchedLevels(matched, activeOther, route, menus, tabs) {
|
|
60
|
+
var _a;
|
|
61
|
+
const levels = [];
|
|
62
|
+
if (matched) {
|
|
63
|
+
matched.forEach((m) => {
|
|
64
|
+
var _a2;
|
|
65
|
+
if (m.meta && m.meta.title && m.meta.breadcrumb !== false) {
|
|
66
|
+
const title = ((_a2 = findTabByPath(m.path, tabs)) == null ? void 0 : _a2.title) || m.meta.title;
|
|
67
|
+
levels.push({ path: m.path, title });
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (activeOther) {
|
|
72
|
+
const { path, fullPath, meta } = route;
|
|
73
|
+
const notIn = !levels.length || fullPath !== levels[levels.length - 1].path;
|
|
74
|
+
if (notIn && meta.title) {
|
|
75
|
+
const m = findMenuByPath(fullPath, menus) ?? findMenuByPath(path, menus);
|
|
76
|
+
const t = findTabByPath(fullPath, tabs) ?? findTabByPath(path, tabs);
|
|
77
|
+
const title = (t == null ? void 0 : t.title) || ((_a = m == null ? void 0 : m.meta) == null ? void 0 : _a.title) || meta.title;
|
|
78
|
+
levels.push({ path: fullPath, title });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return levels;
|
|
82
|
+
}
|
|
83
|
+
function getMatchedComponents(matched) {
|
|
84
|
+
const components = [];
|
|
85
|
+
matched.forEach((m) => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
if ((_b = (_a = m.components) == null ? void 0 : _a.default) == null ? void 0 : _b.name) {
|
|
88
|
+
components.push(m.components.default.name);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return components;
|
|
92
|
+
}
|
|
93
|
+
function getRouteTab(route, tabs, homePath, routeTitle) {
|
|
94
|
+
const { path, fullPath, meta, matched } = route;
|
|
95
|
+
const key = meta.tabUnique === false ? fullPath : path;
|
|
96
|
+
const t = findTabByPath(key, tabs);
|
|
97
|
+
const title = (t == null ? void 0 : t.title) || routeTitle;
|
|
98
|
+
const home = path === homePath || fullPath === homePath;
|
|
99
|
+
const closable = (t == null ? void 0 : t.closable) ?? meta.closable !== false;
|
|
100
|
+
const components = getMatchedComponents(matched);
|
|
101
|
+
return { key, path, fullPath, title, closable, home, components, meta };
|
|
102
|
+
}
|
|
103
|
+
function getActiveChilds(menus, active, childrenName) {
|
|
104
|
+
const field = childrenName || "children";
|
|
105
|
+
if (!menus.length) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
if (!active) {
|
|
109
|
+
return menus[0][field] || [];
|
|
110
|
+
}
|
|
111
|
+
const m = menus.find((m2) => m2.path === active);
|
|
112
|
+
if (m == null) {
|
|
113
|
+
return menus[0][field] || [];
|
|
114
|
+
}
|
|
115
|
+
return m[field] || [];
|
|
116
|
+
}
|
|
117
|
+
function getIframeSrc(routePath, iframeUrl) {
|
|
118
|
+
const [_path1, query1 = ""] = (routePath ?? "").split("?");
|
|
119
|
+
const [path2, query2 = ""] = (iframeUrl ?? "").split("?");
|
|
120
|
+
const params1 = new URLSearchParams(query1);
|
|
121
|
+
const params2 = new URLSearchParams(query2);
|
|
122
|
+
for (const [key, value] of params2.entries()) {
|
|
123
|
+
params1.append(key, value);
|
|
124
|
+
}
|
|
125
|
+
const newQuery = params1.toString();
|
|
126
|
+
return `${path2}${newQuery ? `?${newQuery}` : ""}`;
|
|
127
|
+
}
|
|
128
|
+
function getMenuItems(menus, link) {
|
|
129
|
+
return mapTree(menus, (m) => {
|
|
130
|
+
const { path, meta } = m;
|
|
131
|
+
const { hide, icon, title, props } = meta ?? {};
|
|
132
|
+
if (hide) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const item = {
|
|
136
|
+
title,
|
|
137
|
+
icon,
|
|
138
|
+
path: link ? path : void 0,
|
|
139
|
+
index: path,
|
|
140
|
+
...omit(props, ["title", "icon", "path", "index"]),
|
|
141
|
+
meta
|
|
142
|
+
};
|
|
143
|
+
return item;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function useLayoutState() {
|
|
147
|
+
return inject(LAYOUT_KEY, {});
|
|
148
|
+
}
|
|
149
|
+
function useProLayoutState() {
|
|
150
|
+
return inject(PRO_LAYOUT_KEY, {});
|
|
151
|
+
}
|
|
152
|
+
function useResponsive(props) {
|
|
153
|
+
const state = useProLayoutState();
|
|
154
|
+
return computed(() => props.responsive ?? state.responsive ?? true);
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
findMenuByPath,
|
|
158
|
+
findTabByKey,
|
|
159
|
+
findTabByPath,
|
|
160
|
+
getActiveChilds,
|
|
161
|
+
getIframeSrc,
|
|
162
|
+
getMatchedComponents,
|
|
163
|
+
getMatchedLevels,
|
|
164
|
+
getMatchedMenus,
|
|
165
|
+
getMenuItems,
|
|
166
|
+
getRouteMatched,
|
|
167
|
+
getRouteTab,
|
|
168
|
+
useLayoutState,
|
|
169
|
+
useProLayoutState,
|
|
170
|
+
useResponsive
|
|
171
|
+
};
|
package/es/utils/resolvers.js
CHANGED
|
@@ -27,7 +27,7 @@ function EleAdminResolver(options) {
|
|
|
27
27
|
var _a;
|
|
28
28
|
const { path, exclude } = options || {};
|
|
29
29
|
if (name.match(/^Ele[A-Z]/) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name))) {
|
|
30
|
-
const packageName = "
|
|
30
|
+
const packageName = "yuang-framework-ui-pc";
|
|
31
31
|
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
32
32
|
const stylePath = getStylePath(namePath, packageName, path);
|
|
33
33
|
if (!path || path === "/es/core" || path === "/lib/core") {
|
package/lib/utils/resolvers.cjs
CHANGED
|
@@ -29,7 +29,7 @@ function EleAdminResolver(options) {
|
|
|
29
29
|
var _a;
|
|
30
30
|
const { path, exclude } = options || {};
|
|
31
31
|
if (name.match(/^Ele[A-Z]/) && !((_a = exclude == null ? void 0 : exclude.includes) == null ? void 0 : _a.call(exclude, name))) {
|
|
32
|
-
const packageName = "
|
|
32
|
+
const packageName = "yuang-framework-ui-pc";
|
|
33
33
|
const namePath = name.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
|
|
34
34
|
const stylePath = getStylePath(namePath, packageName, path);
|
|
35
35
|
if (!path || path === "/es/core" || path === "/lib/core") {
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/consistent-type-imports */
|
|
2
2
|
declare module '@vue/runtime-core' {
|
|
3
3
|
export interface GlobalComponents {
|
|
4
|
-
EleAdminLayout: (typeof import('
|
|
5
|
-
EleAlert: (typeof import('
|
|
6
|
-
EleApp: (typeof import('
|
|
7
|
-
EleAvatarGroup: (typeof import('
|
|
8
|
-
EleBacktop: (typeof import('
|
|
9
|
-
EleBarCode: (typeof import('
|
|
10
|
-
EleBasicSelect: (typeof import('
|
|
11
|
-
EleBottomBar: (typeof import('
|
|
12
|
-
EleBreadcrumb: (typeof import('
|
|
13
|
-
EleCard: (typeof import('
|
|
14
|
-
EleCheckCard: (typeof import('
|
|
15
|
-
EleConfigProvider: (typeof import('
|
|
16
|
-
EleCopyable: (typeof import('
|
|
17
|
-
EleCountUp: (typeof import('
|
|
18
|
-
EleCropper: (typeof import('
|
|
19
|
-
EleCropperModal: (typeof import('
|
|
20
|
-
EleDashboard: (typeof import('
|
|
21
|
-
EleDataTable: (typeof import('
|
|
22
|
-
EleDot: (typeof import('
|
|
23
|
-
EleDrawer: (typeof import('
|
|
24
|
-
EleDropdown: (typeof import('
|
|
25
|
-
EleEditTag: (typeof import('
|
|
26
|
-
EleEllipsis: (typeof import('
|
|
27
|
-
EleFileList: (typeof import('
|
|
28
|
-
EleFileListTool: (typeof import('
|
|
29
|
-
EleIconSelect: (typeof import('
|
|
30
|
-
EleImageViewer: (typeof import('
|
|
31
|
-
EleLoading: (typeof import('
|
|
32
|
-
EleMapPicker: (typeof import('
|
|
33
|
-
EleMenus: (typeof import('
|
|
34
|
-
EleModal: (typeof import('
|
|
35
|
-
ElePage: (typeof import('
|
|
36
|
-
ElePagination: (typeof import('
|
|
37
|
-
ElePopconfirm: (typeof import('
|
|
38
|
-
ElePopover: (typeof import('
|
|
39
|
-
ElePrinter: (typeof import('
|
|
40
|
-
EleProLayout: (typeof import('
|
|
41
|
-
EleProTable: (typeof import('
|
|
42
|
-
EleQrCode: (typeof import('
|
|
43
|
-
EleQrCodeSvg: (typeof import('
|
|
44
|
-
EleSegmented: (typeof import('
|
|
45
|
-
EleSplitPanel: (typeof import('
|
|
46
|
-
EleSteps: (typeof import('
|
|
47
|
-
EleTabTool: (typeof import('
|
|
48
|
-
EleTabWrap: (typeof import('
|
|
49
|
-
EleTable: (typeof import('
|
|
50
|
-
EleTableSelect: (typeof import('
|
|
51
|
-
EleTabs: (typeof import('
|
|
52
|
-
EleText: (typeof import('
|
|
53
|
-
EleTool: (typeof import('
|
|
54
|
-
EleToolbar: (typeof import('
|
|
55
|
-
EleTooltip: (typeof import('
|
|
56
|
-
EleTour: (typeof import('
|
|
57
|
-
EleTreeSelect: (typeof import('
|
|
58
|
-
EleUploadList: (typeof import('
|
|
59
|
-
EleVirtualTable: (typeof import('
|
|
60
|
-
EleWatermark: (typeof import('
|
|
61
|
-
EleXgPlayer: (typeof import('
|
|
4
|
+
EleAdminLayout: (typeof import('yuang-framework-ui-pc'))['EleAdminLayout'];
|
|
5
|
+
EleAlert: (typeof import('yuang-framework-ui-pc'))['EleAlert'];
|
|
6
|
+
EleApp: (typeof import('yuang-framework-ui-pc'))['EleApp'];
|
|
7
|
+
EleAvatarGroup: (typeof import('yuang-framework-ui-pc'))['EleAvatarGroup'];
|
|
8
|
+
EleBacktop: (typeof import('yuang-framework-ui-pc'))['EleBacktop'];
|
|
9
|
+
EleBarCode: (typeof import('yuang-framework-ui-pc'))['EleBarCode'];
|
|
10
|
+
EleBasicSelect: (typeof import('yuang-framework-ui-pc'))['EleBasicSelect'];
|
|
11
|
+
EleBottomBar: (typeof import('yuang-framework-ui-pc'))['EleBottomBar'];
|
|
12
|
+
EleBreadcrumb: (typeof import('yuang-framework-ui-pc'))['EleBreadcrumb'];
|
|
13
|
+
EleCard: (typeof import('yuang-framework-ui-pc'))['EleCard'];
|
|
14
|
+
EleCheckCard: (typeof import('yuang-framework-ui-pc'))['EleCheckCard'];
|
|
15
|
+
EleConfigProvider: (typeof import('yuang-framework-ui-pc'))['EleConfigProvider'];
|
|
16
|
+
EleCopyable: (typeof import('yuang-framework-ui-pc'))['EleCopyable'];
|
|
17
|
+
EleCountUp: (typeof import('yuang-framework-ui-pc'))['EleCountUp'];
|
|
18
|
+
EleCropper: (typeof import('yuang-framework-ui-pc'))['EleCropper'];
|
|
19
|
+
EleCropperModal: (typeof import('yuang-framework-ui-pc'))['EleCropperModal'];
|
|
20
|
+
EleDashboard: (typeof import('yuang-framework-ui-pc'))['EleDashboard'];
|
|
21
|
+
EleDataTable: (typeof import('yuang-framework-ui-pc'))['EleDataTable'];
|
|
22
|
+
EleDot: (typeof import('yuang-framework-ui-pc'))['EleDot'];
|
|
23
|
+
EleDrawer: (typeof import('yuang-framework-ui-pc'))['EleDrawer'];
|
|
24
|
+
EleDropdown: (typeof import('yuang-framework-ui-pc'))['EleDropdown'];
|
|
25
|
+
EleEditTag: (typeof import('yuang-framework-ui-pc'))['EleEditTag'];
|
|
26
|
+
EleEllipsis: (typeof import('yuang-framework-ui-pc'))['EleEllipsis'];
|
|
27
|
+
EleFileList: (typeof import('yuang-framework-ui-pc'))['EleFileList'];
|
|
28
|
+
EleFileListTool: (typeof import('yuang-framework-ui-pc'))['EleFileListTool'];
|
|
29
|
+
EleIconSelect: (typeof import('yuang-framework-ui-pc'))['EleIconSelect'];
|
|
30
|
+
EleImageViewer: (typeof import('yuang-framework-ui-pc'))['EleImageViewer'];
|
|
31
|
+
EleLoading: (typeof import('yuang-framework-ui-pc'))['EleLoading'];
|
|
32
|
+
EleMapPicker: (typeof import('yuang-framework-ui-pc'))['EleMapPicker'];
|
|
33
|
+
EleMenus: (typeof import('yuang-framework-ui-pc'))['EleMenus'];
|
|
34
|
+
EleModal: (typeof import('yuang-framework-ui-pc'))['EleModal'];
|
|
35
|
+
ElePage: (typeof import('yuang-framework-ui-pc'))['ElePage'];
|
|
36
|
+
ElePagination: (typeof import('yuang-framework-ui-pc'))['ElePagination'];
|
|
37
|
+
ElePopconfirm: (typeof import('yuang-framework-ui-pc'))['ElePopconfirm'];
|
|
38
|
+
ElePopover: (typeof import('yuang-framework-ui-pc'))['ElePopover'];
|
|
39
|
+
ElePrinter: (typeof import('yuang-framework-ui-pc'))['ElePrinter'];
|
|
40
|
+
EleProLayout: (typeof import('yuang-framework-ui-pc'))['EleProLayout'];
|
|
41
|
+
EleProTable: (typeof import('yuang-framework-ui-pc'))['EleProTable'];
|
|
42
|
+
EleQrCode: (typeof import('yuang-framework-ui-pc'))['EleQrCode'];
|
|
43
|
+
EleQrCodeSvg: (typeof import('yuang-framework-ui-pc'))['EleQrCodeSvg'];
|
|
44
|
+
EleSegmented: (typeof import('yuang-framework-ui-pc'))['EleSegmented'];
|
|
45
|
+
EleSplitPanel: (typeof import('yuang-framework-ui-pc'))['EleSplitPanel'];
|
|
46
|
+
EleSteps: (typeof import('yuang-framework-ui-pc'))['EleSteps'];
|
|
47
|
+
EleTabTool: (typeof import('yuang-framework-ui-pc'))['EleTabTool'];
|
|
48
|
+
EleTabWrap: (typeof import('yuang-framework-ui-pc'))['EleTabWrap'];
|
|
49
|
+
EleTable: (typeof import('yuang-framework-ui-pc'))['EleTable'];
|
|
50
|
+
EleTableSelect: (typeof import('yuang-framework-ui-pc'))['EleTableSelect'];
|
|
51
|
+
EleTabs: (typeof import('yuang-framework-ui-pc'))['EleTabs'];
|
|
52
|
+
EleText: (typeof import('yuang-framework-ui-pc'))['EleText'];
|
|
53
|
+
EleTool: (typeof import('yuang-framework-ui-pc'))['EleTool'];
|
|
54
|
+
EleToolbar: (typeof import('yuang-framework-ui-pc'))['EleToolbar'];
|
|
55
|
+
EleTooltip: (typeof import('yuang-framework-ui-pc'))['EleTooltip'];
|
|
56
|
+
EleTour: (typeof import('yuang-framework-ui-pc'))['EleTour'];
|
|
57
|
+
EleTreeSelect: (typeof import('yuang-framework-ui-pc'))['EleTreeSelect'];
|
|
58
|
+
EleUploadList: (typeof import('yuang-framework-ui-pc'))['EleUploadList'];
|
|
59
|
+
EleVirtualTable: (typeof import('yuang-framework-ui-pc'))['EleVirtualTable'];
|
|
60
|
+
EleWatermark: (typeof import('yuang-framework-ui-pc'))['EleWatermark'];
|
|
61
|
+
EleXgPlayer: (typeof import('yuang-framework-ui-pc'))['EleXgPlayer'];
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
export {};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
<!-- 内嵌缓存 -->
|
|
2
|
-
<template>
|
|
3
|
-
<div class="ele-admin-iframe-wrap">
|
|
4
|
-
<template v-if="!transitionName">
|
|
5
|
-
<template v-for="item in data" :key="item.id">
|
|
6
|
-
<iframe
|
|
7
|
-
v-if="!item.refresh"
|
|
8
|
-
:data-id="item.id"
|
|
9
|
-
:src="item.src"
|
|
10
|
-
v-show="active === item.id"
|
|
11
|
-
class="ele-admin-iframe"
|
|
12
|
-
></iframe>
|
|
13
|
-
</template>
|
|
14
|
-
</template>
|
|
15
|
-
<TransitionGroup
|
|
16
|
-
v-else
|
|
17
|
-
:appear="true"
|
|
18
|
-
:name="transitionName"
|
|
19
|
-
@afterLeave="handleLeave()"
|
|
20
|
-
>
|
|
21
|
-
<template v-for="item in data" :key="item.id">
|
|
22
|
-
<iframe
|
|
23
|
-
v-if="!item.refresh"
|
|
24
|
-
:data-id="item.id"
|
|
25
|
-
:src="item.src"
|
|
26
|
-
v-show="active === item.id"
|
|
27
|
-
class="ele-admin-iframe"
|
|
28
|
-
></iframe>
|
|
29
|
-
</template>
|
|
30
|
-
</TransitionGroup>
|
|
31
|
-
</div>
|
|
32
|
-
</template>
|
|
33
|
-
|
|
34
|
-
<script lang="ts">
|
|
35
|
-
import type { PropType } from 'vue';
|
|
36
|
-
import { defineComponent, ref, computed, watch, nextTick } from 'vue';
|
|
37
|
-
import { useTimer } from '../../utils/hook';
|
|
38
|
-
import type { TabItem, IframeItem } from '../types';
|
|
39
|
-
import { getIframeSrc } from '../util';
|
|
40
|
-
|
|
41
|
-
export default defineComponent({
|
|
42
|
-
name: 'ProIframe',
|
|
43
|
-
props: {
|
|
44
|
-
/** 是否支持内嵌缓存 */
|
|
45
|
-
keepAlive: Boolean,
|
|
46
|
-
/** 内嵌切换动画 */
|
|
47
|
-
transitionName: String,
|
|
48
|
-
/** 内嵌进入动画延迟时间 */
|
|
49
|
-
transitionDelay: Number,
|
|
50
|
-
/** 页签数据 */
|
|
51
|
-
tabData: {
|
|
52
|
-
type: Array as PropType<TabItem[]>,
|
|
53
|
-
required: true
|
|
54
|
-
},
|
|
55
|
-
/** 页签选中 */
|
|
56
|
-
tabActive: String
|
|
57
|
-
},
|
|
58
|
-
setup(props) {
|
|
59
|
-
const [startActiveTimer, stopActiveTimer] = useTimer();
|
|
60
|
-
|
|
61
|
-
/** 内嵌数据 */
|
|
62
|
-
const data = computed<IframeItem[]>(() => {
|
|
63
|
-
const list: IframeItem[] = [];
|
|
64
|
-
props.tabData.forEach((t) => {
|
|
65
|
-
const isAlive = t.meta?.keepAlive !== false;
|
|
66
|
-
if (t.key && t.meta?.iframe && isAlive) {
|
|
67
|
-
const src = getIframeSrc(t.fullPath, t.meta.iframe);
|
|
68
|
-
list.push({ id: t.key, src, refresh: t.refresh });
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return list.sort((a, b) => (a.id === b.id ? 0 : a.id > b.id ? 1 : -1));
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
/** 内嵌选中 */
|
|
75
|
-
const dataActive = computed(() => {
|
|
76
|
-
if (
|
|
77
|
-
!props.tabActive ||
|
|
78
|
-
!data.value.length ||
|
|
79
|
-
!data.value.some((d) => d.id === props.tabActive)
|
|
80
|
-
) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
return props.tabActive;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
/** 当前显示 */
|
|
87
|
-
const active = ref<string | null | undefined>(dataActive.value);
|
|
88
|
-
|
|
89
|
-
/** 离开动画结束事件 */
|
|
90
|
-
const handleLeave = (delay?: number) => {
|
|
91
|
-
if (!dataActive.value) {
|
|
92
|
-
active.value = null;
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (!delay) {
|
|
96
|
-
active.value = dataActive.value;
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
startActiveTimer(() => {
|
|
100
|
-
nextTick(() => {
|
|
101
|
-
active.value = dataActive.value;
|
|
102
|
-
});
|
|
103
|
-
}, delay);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
watch(dataActive, () => {
|
|
107
|
-
stopActiveTimer();
|
|
108
|
-
if (active.value == null) {
|
|
109
|
-
handleLeave(props.transitionName ? props.transitionDelay : void 0);
|
|
110
|
-
} else if (!props.transitionName) {
|
|
111
|
-
handleLeave();
|
|
112
|
-
} else {
|
|
113
|
-
active.value = null;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return { active, data, handleLeave };
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
</script>
|