@gx-design-vue/pro-layout 0.1.0-alpha.24 → 0.1.0-alpha.26
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/ProLayout.js +46 -11
- package/dist/components/AppPage/index.d.ts +1 -1
- package/dist/components/Header/index.js +12 -9
- package/dist/components/Sider/index.js +20 -9
- package/dist/context/index.d.ts +1 -0
- package/dist/hooks/useLayoutBase.d.ts +7 -6
- package/dist/hooks/useLayoutBase.js +2 -0
- package/dist/hooks/useTabs.js +24 -13
- package/dist/index.d.ts +2 -2
- package/dist/interface.d.ts +5 -3
- package/dist/pro-layout.esm.js +584 -538
- package/dist/pro-layout.js +3 -3
- package/dist/style/header.js +7 -4
- package/dist/style/logo.js +12 -9
- package/dist/style/sider.js +8 -4
- package/package.json +4 -4
package/dist/ProLayout.js
CHANGED
|
@@ -12,7 +12,7 @@ import style_default from "./style/index.js";
|
|
|
12
12
|
import { normalizeSectionConfig } from "./utils/config.js";
|
|
13
13
|
import { computed, createVNode, defineComponent, mergeDefaults, ref } from "vue";
|
|
14
14
|
import { ThemeContext, useThemeContext } from "@gx-design-vue/context";
|
|
15
|
-
import { GProConfigProvider, useProToken } from "@gx-design-vue/pro-provider";
|
|
15
|
+
import { GProConfigProvider, unit, useProToken } from "@gx-design-vue/pro-provider";
|
|
16
16
|
import { classNames, getSlotsProps } from "@gx-design-vue/pro-utils";
|
|
17
17
|
import { useDark, useMediaQuery, useVModel } from "@vueuse/core";
|
|
18
18
|
import { ConfigProvider, Layout } from "antdv-next";
|
|
@@ -32,14 +32,29 @@ const InnerLayout = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
32
32
|
cssVarCls,
|
|
33
33
|
rootCls
|
|
34
34
|
});
|
|
35
|
+
const isWide = computed(() => props.layout === "wide" && !!props.wideContentWidth);
|
|
36
|
+
const rootStyle = computed(() => ({
|
|
37
|
+
...props.proStyles?.root,
|
|
38
|
+
minWidth: isWide.value ? unit(props.wideContentWidth) : void 0
|
|
39
|
+
}));
|
|
40
|
+
const headerHeight = computed(() => parentCtx?.header?.value?.height);
|
|
41
|
+
const layoutStyle = computed(() => {
|
|
42
|
+
const base = {
|
|
43
|
+
minHeight: "100%",
|
|
44
|
+
flexDirection: props.showSider ? "row" : void 0
|
|
45
|
+
};
|
|
46
|
+
if (isWide.value) {
|
|
47
|
+
base.width = unit(props.wideContentWidth);
|
|
48
|
+
base.margin = "0 auto";
|
|
49
|
+
if (headerHeight.value) base.paddingBlockStart = `calc(${unit(headerHeight.value)} + 20px)`;
|
|
50
|
+
}
|
|
51
|
+
return base;
|
|
52
|
+
});
|
|
35
53
|
return () => createVNode("div", {
|
|
36
54
|
"class": classNames(prefixCls.value, `${prefixCls.value}-${props.layout}`, hashId.value, cssVarCls.value, rootCls.value, props.proClasses?.root),
|
|
37
|
-
"style":
|
|
55
|
+
"style": rootStyle.value,
|
|
38
56
|
"data-layout": props.layout
|
|
39
|
-
}, [proLayoutToken.value?.bgLayout && createVNode("div", { "class": `${prefixCls.value}-bg-list` }, null), createVNode(Layout, { "style": {
|
|
40
|
-
minHeight: "100%",
|
|
41
|
-
flexDirection: props.showSider ? "row" : void 0
|
|
42
|
-
} }, { default: () => [slots.default?.()] })]);
|
|
57
|
+
}, [proLayoutToken.value?.bgLayout && createVNode("div", { "class": `${prefixCls.value}-bg-list` }, null), createVNode(Layout, { "style": layoutStyle.value }, { default: () => [slots.default?.()] })]);
|
|
43
58
|
}, {
|
|
44
59
|
props: {
|
|
45
60
|
layout: {
|
|
@@ -50,6 +65,10 @@ const InnerLayout = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
|
50
65
|
type: Boolean,
|
|
51
66
|
required: true
|
|
52
67
|
},
|
|
68
|
+
wideContentWidth: {
|
|
69
|
+
type: [Number, String],
|
|
70
|
+
required: false
|
|
71
|
+
},
|
|
53
72
|
proClasses: {
|
|
54
73
|
type: Object,
|
|
55
74
|
required: false
|
|
@@ -73,7 +92,9 @@ const GProLayout = /* @__PURE__ */ defineComponent((props, { emit, expose, slots
|
|
|
73
92
|
};
|
|
74
93
|
});
|
|
75
94
|
const layout = computed(() => props.layout ?? "side");
|
|
76
|
-
const
|
|
95
|
+
const isMobileRaw = useMediaQuery("(max-width: 768px)");
|
|
96
|
+
/** wide 模式禁用移动端行为 */
|
|
97
|
+
const isMobile = computed(() => layout.value !== "wide" && isMobileRaw.value);
|
|
77
98
|
const collapsed = useVModel(props, "collapsed", emit, {
|
|
78
99
|
passive: true,
|
|
79
100
|
defaultValue: false
|
|
@@ -120,6 +141,12 @@ const GProLayout = /* @__PURE__ */ defineComponent((props, { emit, expose, slots
|
|
|
120
141
|
...DEFAULT_LAYOUT_CONFIG.pageContainer,
|
|
121
142
|
...props.pageContainer || {}
|
|
122
143
|
}));
|
|
144
|
+
/** wide 模式整体内容宽度:取 contentWidth,无值/0 默认 1300 */
|
|
145
|
+
const wideContentWidth = computed(() => {
|
|
146
|
+
if (layout.value !== "wide") return void 0;
|
|
147
|
+
const contentWidth = pageContainerConfig.value.contentWidth;
|
|
148
|
+
return !contentWidth ? 1300 : contentWidth;
|
|
149
|
+
});
|
|
123
150
|
const tabsConf = computed(() => normalizeSectionConfig(props.tabsConfig, DEFAULT_LAYOUT_CONFIG.tabsConfig));
|
|
124
151
|
const tabsStateConfig = computed(() => tabsConf.value ?? {});
|
|
125
152
|
const collapsedWidth = computed(() => collapseConfig.value?.width ?? DEFAULT_LAYOUT_CONFIG.collapse.width);
|
|
@@ -229,7 +256,8 @@ const GProLayout = /* @__PURE__ */ defineComponent((props, { emit, expose, slots
|
|
|
229
256
|
tabsHeight,
|
|
230
257
|
setTabsHeight: (value) => {
|
|
231
258
|
tabsHeight.value = value;
|
|
232
|
-
}
|
|
259
|
+
},
|
|
260
|
+
wideContentWidth
|
|
233
261
|
});
|
|
234
262
|
expose({ tabs: tabsState.tabsController });
|
|
235
263
|
function resolveLayoutSlots() {
|
|
@@ -253,6 +281,7 @@ const GProLayout = /* @__PURE__ */ defineComponent((props, { emit, expose, slots
|
|
|
253
281
|
}, { default: () => [createVNode(InnerLayout, {
|
|
254
282
|
"layout": layout.value,
|
|
255
283
|
"showSider": showSider.value,
|
|
284
|
+
"wideContentWidth": wideContentWidth.value,
|
|
256
285
|
"proClasses": props.proClasses,
|
|
257
286
|
"proStyles": props.proStyles
|
|
258
287
|
}, { default: () => [showSider.value && siderWidth.value && createVNode(LayoutSider$1, {
|
|
@@ -281,7 +310,7 @@ const GProLayout = /* @__PURE__ */ defineComponent((props, { emit, expose, slots
|
|
|
281
310
|
breadcrumb: slots.breadcrumb,
|
|
282
311
|
collapseIcon: slots.collapseIcon
|
|
283
312
|
}),
|
|
284
|
-
tabsConf.value && createVNode(LayoutTabs, {
|
|
313
|
+
tabsConf.value && layout.value !== "wide" && createVNode(LayoutTabs, {
|
|
285
314
|
"config": tabsConf.value,
|
|
286
315
|
"onReloadPage": () => emit("reloadPage"),
|
|
287
316
|
"onContentFullscreenChange": (val) => {
|
|
@@ -293,14 +322,20 @@ const GProLayout = /* @__PURE__ */ defineComponent((props, { emit, expose, slots
|
|
|
293
322
|
default: () => [slots.default?.()],
|
|
294
323
|
...layoutSlots
|
|
295
324
|
}),
|
|
296
|
-
showFooter.value && createVNode(LayoutFooter$1, {
|
|
325
|
+
!wideContentWidth.value && showFooter.value && createVNode(LayoutFooter$1, {
|
|
297
326
|
"links": footerConfig.value.links,
|
|
298
327
|
"copyright": footerConfig.value.copyright
|
|
299
328
|
}, {
|
|
300
329
|
footer: layoutSlots.footer,
|
|
301
330
|
copyright: layoutSlots.copyright
|
|
302
331
|
})
|
|
303
|
-
])] })
|
|
332
|
+
])] }), wideContentWidth.value && showFooter.value && createVNode(LayoutFooter$1, {
|
|
333
|
+
"links": footerConfig.value.links,
|
|
334
|
+
"copyright": footerConfig.value.copyright
|
|
335
|
+
}, {
|
|
336
|
+
footer: layoutSlots.footer,
|
|
337
|
+
copyright: layoutSlots.copyright
|
|
338
|
+
})] })] })] });
|
|
304
339
|
};
|
|
305
340
|
}, {
|
|
306
341
|
props: /*@__PURE__*/ mergeDefaults({
|
|
@@ -40,8 +40,8 @@ declare const ProAppPage: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
40
40
|
message: PropType<ConfigOptions>;
|
|
41
41
|
notification: PropType<NotificationConfig>;
|
|
42
42
|
}>> & Readonly<{}>, {
|
|
43
|
-
indicator: CustomRender;
|
|
44
43
|
spinning: AppPageSpinning;
|
|
44
|
+
indicator: CustomRender;
|
|
45
45
|
}, SlotsType<{
|
|
46
46
|
default: () => any;
|
|
47
47
|
indicator: () => any;
|
|
@@ -10,20 +10,20 @@ import { useWindowScroll } from "@vueuse/core";
|
|
|
10
10
|
import { LayoutHeader } from "antdv-next";
|
|
11
11
|
//#region src/components/Header/index.tsx
|
|
12
12
|
const Header = /* @__PURE__ */ defineComponent((props, { emit, slots }) => {
|
|
13
|
-
const { header, siderWidth, layout, menuState, prefixCls, collapseConfig, collapsed, isMobile, logoConfig, logoTitle, selectedKeys, openKeys, proClasses, proStyles, breadcrumbRender, breadcrumbConfig } = useLayoutBase(props);
|
|
13
|
+
const { header, siderWidth, wideContentWidth, layout, menuState, prefixCls, collapseConfig, collapsed, isMobile, logoConfig, logoTitle, selectedKeys, openKeys, proClasses, proStyles, breadcrumbRender, breadcrumbConfig } = useLayoutBase(props);
|
|
14
14
|
const headerMenus = computed(() => menuState?.headerMenus.value ?? []);
|
|
15
15
|
const breadcrumbItems = computed(() => menuState?.breadcrumbItems.value ?? []);
|
|
16
16
|
const breadcrumbRoutes = computed(() => menuState?.breadcrumbRoutes.value ?? []);
|
|
17
|
-
const showLogo = computed(() => ["top"].includes(layout.value ?? "") || [
|
|
18
|
-
"side",
|
|
19
|
-
"mix",
|
|
20
|
-
"wide"
|
|
21
|
-
].includes(layout.value ?? "") && !siderWidth.value);
|
|
17
|
+
const showLogo = computed(() => ["top", "wide"].includes(layout.value ?? "") || ["side", "mix"].includes(layout.value ?? "") && !siderWidth.value);
|
|
22
18
|
const headerStyle = computed(() => {
|
|
23
19
|
const style = {};
|
|
24
|
-
if (header.value?.fixed && siderWidth.value && !isMobile.value) style.width = `calc(100% - ${unit(siderWidth.value)})`;
|
|
20
|
+
if (header.value?.fixed && siderWidth.value && !isMobile.value && layout.value !== "wide") style.width = `calc(100% - ${unit(siderWidth.value)})`;
|
|
25
21
|
return style;
|
|
26
22
|
});
|
|
23
|
+
/** wide 模式 header-main 宽度约束 */
|
|
24
|
+
const headerMainStyle = computed(() => {
|
|
25
|
+
if (wideContentWidth?.value) return { width: unit(wideContentWidth.value) };
|
|
26
|
+
});
|
|
27
27
|
const headerHidden = ref(false);
|
|
28
28
|
if (typeof window !== "undefined") {
|
|
29
29
|
const { y: scrollY } = useWindowScroll();
|
|
@@ -75,7 +75,7 @@ const Header = /* @__PURE__ */ defineComponent((props, { emit, slots }) => {
|
|
|
75
75
|
const logoRender = slots.logo || logoConfig.value?.render;
|
|
76
76
|
const collapseRender = slots.collapse || collapseConfig.value?.render;
|
|
77
77
|
const collapseIconRender = slots.collapseIcon || collapseConfig.value?.icon;
|
|
78
|
-
return createVNode(Fragment, null, [header.value?.fixed && createVNode(LayoutHeader, { "style": {
|
|
78
|
+
return createVNode(Fragment, null, [layout.value !== "wide" && header.value?.fixed && createVNode(LayoutHeader, { "style": {
|
|
79
79
|
background: "transparent",
|
|
80
80
|
lineHeight: unit(header.value?.height),
|
|
81
81
|
height: unit(header.value?.height)
|
|
@@ -85,7 +85,10 @@ const Header = /* @__PURE__ */ defineComponent((props, { emit, slots }) => {
|
|
|
85
85
|
...headerStyle.value,
|
|
86
86
|
...proStyles.value.header
|
|
87
87
|
}
|
|
88
|
-
}, { default: () => [createVNode("div", {
|
|
88
|
+
}, { default: () => [createVNode("div", {
|
|
89
|
+
"class": `${prefixCls.value}-header-main`,
|
|
90
|
+
"style": headerMainStyle.value
|
|
91
|
+
}, [
|
|
89
92
|
createVNode("div", { "class": `${prefixCls.value}-header-main-left` }, [
|
|
90
93
|
showLogo.value && logoConfig.value && (typeof logoRender === "function" ? logoRender?.({
|
|
91
94
|
collapsed: collapsed.value,
|
|
@@ -14,6 +14,18 @@ function _isSlot(s) {
|
|
|
14
14
|
}
|
|
15
15
|
const LayoutSider = /* @__PURE__ */ defineComponent((props, { emit, slots }) => {
|
|
16
16
|
const { sider, header, layout, menuState, prefixCls, cssVarCls, rootCls, collapseConfig, collapsed, isMobile, logoConfig, logoTitle, selectedKeys, openKeys, proClasses, proStyles, siderWidth, collapsedWidth } = useLayoutBase(props);
|
|
17
|
+
/** wide 模式 sider sticky 定位样式 */
|
|
18
|
+
const wideSiderStyle = computed(() => {
|
|
19
|
+
if (layout.value !== "wide") return void 0;
|
|
20
|
+
const headerHeight = unit(header.value?.height);
|
|
21
|
+
return {
|
|
22
|
+
top: `calc(${headerHeight} + 20px)`,
|
|
23
|
+
height: `calc(100vh - ${headerHeight} - 20px)`,
|
|
24
|
+
zIndex: 100
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
/** wide 模式下 sider 使用 sticky 而非 fixed */
|
|
28
|
+
const isWide = computed(() => layout.value === "wide");
|
|
17
29
|
/** GScrollbar 组件引用,用于获取滚动容器 DOM */
|
|
18
30
|
const scrollbarRef = shallowRef();
|
|
19
31
|
/** 滚动阴影状态:上下边缘是否可继续滚动 */
|
|
@@ -36,7 +48,7 @@ const LayoutSider = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
36
48
|
useResizeObserver(scrollbarWrapEl, () => updateScrollShadow());
|
|
37
49
|
useResizeObserver(scrollbarViewEl, () => updateScrollShadow());
|
|
38
50
|
const siderMenus = computed(() => menuState?.siderMenus.value ?? []);
|
|
39
|
-
const siderClassNames = computed(() => classNames(`${prefixCls.value}-sider`, proClasses.value.sider, { [`${prefixCls.value}-sider-fixed`]: sider.value?.fixed }));
|
|
51
|
+
const siderClassNames = computed(() => classNames(`${prefixCls.value}-sider`, proClasses.value.sider, { [`${prefixCls.value}-sider-fixed`]: !isWide.value && sider.value?.fixed }));
|
|
40
52
|
const siderChildrenClassNames = computed(() => classNames(`${prefixCls.value}-sider-children`, proClasses.value.siderChildren));
|
|
41
53
|
const siderHeaderClassNames = computed(() => classNames(`${prefixCls.value}-sider-header`, proClasses.value.siderHeader));
|
|
42
54
|
const siderFooterClassNames = computed(() => classNames(`${prefixCls.value}-sider-footer`, proClasses.value.siderFooter));
|
|
@@ -63,11 +75,7 @@ const LayoutSider = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
63
75
|
const collapseRender = slots.collapse || collapseConfig.value?.render;
|
|
64
76
|
const collapseIconRender = slots.collapseIcon || collapseConfig.value?.icon;
|
|
65
77
|
return createVNode(Fragment, null, [
|
|
66
|
-
[
|
|
67
|
-
"side",
|
|
68
|
-
"mix",
|
|
69
|
-
"wide"
|
|
70
|
-
].includes(layout.value ?? "") && logoConfig.value && createVNode("div", {
|
|
78
|
+
["side", "mix"].includes(layout.value ?? "") && logoConfig.value && createVNode("div", {
|
|
71
79
|
"class": siderHeaderClassNames.value,
|
|
72
80
|
"style": {
|
|
73
81
|
...proStyles.value.siderHeader,
|
|
@@ -108,7 +116,7 @@ const LayoutSider = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
108
116
|
collapsed: collapsed.value,
|
|
109
117
|
isMobile: isMobile.value
|
|
110
118
|
})]),
|
|
111
|
-
collapseConfig.value && collapseConfig.value.placement === "sider" && (collapseRender?.({ collapsed: collapsed.value }) ?? createVNode(LayoutCollapseButton, {
|
|
119
|
+
layout.value !== "wide" && collapseConfig.value && collapseConfig.value.placement === "sider" && (collapseRender?.({ collapsed: collapsed.value }) ?? createVNode(LayoutCollapseButton, {
|
|
112
120
|
"collapsed": collapsed.value,
|
|
113
121
|
"onClick": handleToggleCollapsed
|
|
114
122
|
}, { icon: collapseIconRender }))
|
|
@@ -147,7 +155,7 @@ const LayoutSider = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
147
155
|
"onClose": () => emit("update:collapsed", true)
|
|
148
156
|
}, _isSlot(_slot = renderSiderChildren()) ? _slot : { default: () => [_slot] });
|
|
149
157
|
}
|
|
150
|
-
return createVNode(Fragment, null, [sider.value?.fixed && createVNode("div", { "style": {
|
|
158
|
+
return createVNode(Fragment, null, [!isWide.value && sider.value?.fixed && createVNode("div", { "style": {
|
|
151
159
|
width: `${unit(siderWidth.value)}`,
|
|
152
160
|
overflow: "hidden",
|
|
153
161
|
flex: `0 0 ${unit(siderWidth.value)}`,
|
|
@@ -161,7 +169,10 @@ const LayoutSider = /* @__PURE__ */ defineComponent((props, { emit, slots }) =>
|
|
|
161
169
|
"collapsedWidth": collapsedWidth.value,
|
|
162
170
|
"breakpoint": breakpoint ?? void 0,
|
|
163
171
|
"class": siderClassNames.value,
|
|
164
|
-
"style":
|
|
172
|
+
"style": {
|
|
173
|
+
...proStyles.value.sider,
|
|
174
|
+
...wideSiderStyle.value
|
|
175
|
+
},
|
|
165
176
|
"onCollapse": handleSiderCollapse,
|
|
166
177
|
"onBreakpoint": handleBreakpoint
|
|
167
178
|
}, _isSlot(_slot2 = renderSiderChildren()) ? _slot2 : { default: () => [_slot2] })]);
|
package/dist/context/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ interface LayoutContextProps {
|
|
|
47
47
|
/** 导航到指定菜单名 */
|
|
48
48
|
navigate: (name: string) => void;
|
|
49
49
|
tabsState?: UseTabsStateReturn;
|
|
50
|
+
wideContentWidth: ComputedRef<number | string | undefined>;
|
|
50
51
|
}
|
|
51
52
|
declare const useProvideLayoutContext: (ctx: LayoutContextProps) => LayoutContextProps, useInjectLayoutContext: () => LayoutContextProps;
|
|
52
53
|
//#endregion
|
|
@@ -38,38 +38,39 @@ declare function useLayoutBase(props?: {
|
|
|
38
38
|
selectedKeys: import("vue").ComputedRef<string[]>;
|
|
39
39
|
openKeys: import("vue").ComputedRef<string[]>;
|
|
40
40
|
proClasses: import("vue").ComputedRef<{
|
|
41
|
+
root?: string;
|
|
41
42
|
header?: string;
|
|
42
43
|
sider?: string;
|
|
43
|
-
breadcrumb?: string;
|
|
44
|
-
logo?: string;
|
|
45
|
-
root?: string;
|
|
46
44
|
siderChildren?: string;
|
|
47
45
|
siderHeader?: string;
|
|
48
46
|
siderFooter?: string;
|
|
47
|
+
logo?: string;
|
|
49
48
|
logoImage?: string;
|
|
50
49
|
content?: string;
|
|
51
50
|
footer?: string;
|
|
52
51
|
menu?: string;
|
|
53
52
|
tabs?: string;
|
|
53
|
+
breadcrumb?: string;
|
|
54
54
|
}>;
|
|
55
55
|
proStyles: import("vue").ComputedRef<{
|
|
56
|
+
root?: import("vue").CSSProperties;
|
|
56
57
|
header?: import("vue").CSSProperties;
|
|
57
58
|
sider?: import("vue").CSSProperties;
|
|
58
|
-
breadcrumb?: import("vue").CSSProperties;
|
|
59
|
-
logo?: import("vue").CSSProperties;
|
|
60
|
-
root?: import("vue").CSSProperties;
|
|
61
59
|
siderChildren?: import("vue").CSSProperties;
|
|
62
60
|
siderHeader?: import("vue").CSSProperties;
|
|
63
61
|
siderFooter?: import("vue").CSSProperties;
|
|
62
|
+
logo?: import("vue").CSSProperties;
|
|
64
63
|
logoImage?: import("vue").CSSProperties;
|
|
65
64
|
content?: import("vue").CSSProperties;
|
|
66
65
|
footer?: import("vue").CSSProperties;
|
|
67
66
|
menu?: import("vue").CSSProperties;
|
|
68
67
|
tabs?: import("vue").CSSProperties;
|
|
68
|
+
breadcrumb?: import("vue").CSSProperties;
|
|
69
69
|
}>;
|
|
70
70
|
breadcrumbRender: import("vue").Ref<(props: LayoutBreadcrumbSlotProps) => any, (props: LayoutBreadcrumbSlotProps) => any>;
|
|
71
71
|
breadcrumbConfig: import("vue").ComputedRef<LayoutBreadcrumbConfig>;
|
|
72
72
|
pageContainerConfig: import("vue").ComputedRef<LayoutPageContainerConfig>;
|
|
73
|
+
wideContentWidth: import("vue").ComputedRef<string | number>;
|
|
73
74
|
hasFooterToolbar: import("vue").ComputedRef<boolean>;
|
|
74
75
|
navigate: (name: string) => void;
|
|
75
76
|
setHasFooterToolbar: (value: boolean) => void;
|
|
@@ -24,6 +24,7 @@ function useLayoutBase(props) {
|
|
|
24
24
|
const breadcrumbRender = layoutContext?.breadcrumbRender;
|
|
25
25
|
const breadcrumbConfig = layoutContext?.breadcrumbConfig;
|
|
26
26
|
const pageContainerConfig = layoutContext?.pageContainerConfig;
|
|
27
|
+
const wideContentWidth = layoutContext?.wideContentWidth;
|
|
27
28
|
const collapseConfig = layoutContext?.collapseConfig;
|
|
28
29
|
const contentFullscreen = layoutContext?.contentFullscreen;
|
|
29
30
|
const renderRouterView = layoutContext?.renderRouterView;
|
|
@@ -77,6 +78,7 @@ function useLayoutBase(props) {
|
|
|
77
78
|
breadcrumbRender,
|
|
78
79
|
breadcrumbConfig,
|
|
79
80
|
pageContainerConfig,
|
|
81
|
+
wideContentWidth,
|
|
80
82
|
hasFooterToolbar,
|
|
81
83
|
navigate,
|
|
82
84
|
setHasFooterToolbar
|
package/dist/hooks/useTabs.js
CHANGED
|
@@ -135,15 +135,18 @@ function useTabsState(options) {
|
|
|
135
135
|
if (route.params) extra.params = route.params;
|
|
136
136
|
return extra;
|
|
137
137
|
}
|
|
138
|
-
function changeTabsList(
|
|
139
|
-
const targetArray = checkIsFixed(record) ? "fixed" : "normal";
|
|
138
|
+
function changeTabsList(name, operation) {
|
|
140
139
|
const { type, addType, params } = operation;
|
|
140
|
+
let targetArray = "normal";
|
|
141
|
+
const existing = dataSource.value.find((item) => getTabName(item) === name);
|
|
142
|
+
if (type === "add") targetArray = checkIsFixed(params) ? "fixed" : "normal";
|
|
143
|
+
else if (existing) targetArray = checkIsFixed(existing) ? "fixed" : "normal";
|
|
141
144
|
if (type === "add" && addType) menuDataState[targetArray][addType](normalizeTabRoute(params));
|
|
142
145
|
else if (type === "merge") menuDataState[targetArray] = menuDataState[targetArray].map((item) => {
|
|
143
|
-
if (getTabName(item) ===
|
|
146
|
+
if (getTabName(item) === name) return mergeTabRoute(item, params);
|
|
144
147
|
return item;
|
|
145
148
|
});
|
|
146
|
-
else if (type === "remove") menuDataState[targetArray] = menuDataState[targetArray].filter((item) => getTabName(item) !==
|
|
149
|
+
else if (type === "remove") menuDataState[targetArray] = menuDataState[targetArray].filter((item) => getTabName(item) !== name);
|
|
147
150
|
}
|
|
148
151
|
function handleAddTabs(record) {
|
|
149
152
|
const { hidden } = record?.meta?.tabState ?? {};
|
|
@@ -157,12 +160,12 @@ function useTabsState(options) {
|
|
|
157
160
|
return;
|
|
158
161
|
}
|
|
159
162
|
if (checkIsFixed(existing) !== fixed) {
|
|
160
|
-
changeTabsList(existing, {
|
|
163
|
+
changeTabsList(getTabName(existing), {
|
|
161
164
|
type: "remove",
|
|
162
165
|
params: existing
|
|
163
166
|
});
|
|
164
167
|
menuDataState[fixed ? "fixed" : "normal"].push(mergeTabRoute(existing, tabData));
|
|
165
|
-
} else changeTabsList(
|
|
168
|
+
} else changeTabsList(name, {
|
|
166
169
|
type: "merge",
|
|
167
170
|
params: tabData
|
|
168
171
|
});
|
|
@@ -179,7 +182,7 @@ function useTabsState(options) {
|
|
|
179
182
|
function handleTabRemove(name) {
|
|
180
183
|
const record = getCurrentRoute(name);
|
|
181
184
|
if (!record) return;
|
|
182
|
-
changeTabsList(
|
|
185
|
+
changeTabsList(name, {
|
|
183
186
|
type: "remove",
|
|
184
187
|
params: record
|
|
185
188
|
});
|
|
@@ -347,11 +350,18 @@ function useTabsState(options) {
|
|
|
347
350
|
run();
|
|
348
351
|
},
|
|
349
352
|
toggleFullscreen: () => handleContextMenuAction("fullScreen", activeKey.value),
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
dispatch: changeTabsList,
|
|
354
|
+
updateMeta: (name, meta) => {
|
|
355
|
+
const existing = getCurrentRoute(name);
|
|
356
|
+
if (!existing) return;
|
|
357
|
+
changeTabsList(name, {
|
|
358
|
+
type: "merge",
|
|
359
|
+
params: { meta: {
|
|
360
|
+
...existing.meta,
|
|
361
|
+
...meta
|
|
362
|
+
} }
|
|
363
|
+
});
|
|
364
|
+
}
|
|
355
365
|
}
|
|
356
366
|
};
|
|
357
367
|
}
|
|
@@ -375,7 +385,8 @@ const fallbackController = {
|
|
|
375
385
|
toggleFixed: () => {},
|
|
376
386
|
reload: () => {},
|
|
377
387
|
toggleFullscreen: () => {},
|
|
378
|
-
|
|
388
|
+
dispatch: () => {},
|
|
389
|
+
updateMeta: () => {}
|
|
379
390
|
};
|
|
380
391
|
/**
|
|
381
392
|
* 命令式控制多标签(清空 / 关闭 / 增删改)。
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { PRO_MENU_SLOT_KEYS, ProMenuEmits, ProMenuEmitsProps, ProMenuProps, ProM
|
|
|
7
7
|
import { LayoutSiderEmits, LayoutSiderEmitsProps, LayoutSiderProps, LayoutSiderSlots } from "./components/Sider/interface.js";
|
|
8
8
|
import { InnerTabItem, InnerTabsEmits, InnerTabsEmitsProps, InnerTabsProps, InnerTabsSlots, LayoutTabsEmits, LayoutTabsEmitsProps, LayoutTabsProps, LayoutTabsSlots, TabGroup } from "./components/Tabs/interface.js";
|
|
9
9
|
import { LayoutContentEmits, LayoutContentEmitsProps, LayoutContentProps, LayoutContentSlots } from "./components/WrapContent/interface.js";
|
|
10
|
-
import { APP_PAGE_SLOT_KEYS, AppPageSlotKey, AppPageSpinning, BreadcrumbItemType, CardProps, DeepPartial, EmptyEmits, FOOTER_TOOLBAR_SLOT_KEYS, FooterToolbarClassNamesType, FooterToolbarSemanticName, FooterToolbarSlotKey, FooterToolbarStylesType, GFooterToolbarProps, GFooterToolbarSlots, GPageContainerEmits, GPageContainerEmitsProps, GPageContainerProps, GPageContainerSlots, GPageTransitionProps, GPageTransitionSlots, GProAppPageProps, GProAppPageSlots, GProLayoutEmits, GProLayoutEmitsProps, GProLayoutProps, GProLayoutRef, GProLayoutSlots, LAYOUT_SLOT_KEYS, LayoutBreadcrumbConfig, LayoutBreadcrumbSlotProps, LayoutClassNamesType, LayoutCollapseConfig, LayoutFooterConfig, LayoutFooterLink, LayoutHeaderConfig, LayoutHeaderSlotProps, LayoutLogoConfig, LayoutMenuConfig, LayoutMenuItemSlotProps, LayoutMenuRoute, LayoutPageContainerConfig, LayoutSelectInfo, LayoutSemanticName, LayoutSiderConfig, LayoutSiderSlotProps, LayoutStylesType, LayoutTabsConfig, LayoutTabsController,
|
|
10
|
+
import { APP_PAGE_SLOT_KEYS, AppPageSlotKey, AppPageSpinning, BreadcrumbItemType, CardProps, DeepPartial, EmptyEmits, FOOTER_TOOLBAR_SLOT_KEYS, FooterToolbarClassNamesType, FooterToolbarSemanticName, FooterToolbarSlotKey, FooterToolbarStylesType, GFooterToolbarProps, GFooterToolbarSlots, GPageContainerEmits, GPageContainerEmitsProps, GPageContainerProps, GPageContainerSlots, GPageTransitionProps, GPageTransitionSlots, GProAppPageProps, GProAppPageSlots, GProLayoutEmits, GProLayoutEmitsProps, GProLayoutProps, GProLayoutRef, GProLayoutSlots, LAYOUT_SLOT_KEYS, LayoutBreadcrumbConfig, LayoutBreadcrumbSlotProps, LayoutClassNamesType, LayoutCollapseConfig, LayoutFooterConfig, LayoutFooterLink, LayoutHeaderConfig, LayoutHeaderSlotProps, LayoutLogoConfig, LayoutMenuConfig, LayoutMenuItemSlotProps, LayoutMenuRoute, LayoutPageContainerConfig, LayoutSelectInfo, LayoutSemanticName, LayoutSiderConfig, LayoutSiderSlotProps, LayoutStylesType, LayoutTabsConfig, LayoutTabsController, LayoutTabsOperation, MenuClassNamesType, MenuClickInfo, MenuProps, MenuRenderItem, MenuSelectInfo, MenuSemanticName, MenuStylesType, Meta, PAGE_CONTAINER_SLOT_KEYS, PageContainerClassNamesType, PageContainerLoading, PageContainerSemanticName, PageContainerSlotKey, PageContainerStylesType, SiderProps, SpinProps, Tab, TabsMeta, TabsProps, WatermarkProps } from "./interface.js";
|
|
11
11
|
import GProLayout from "./ProLayout.js";
|
|
12
12
|
import { ProAppPageContext, useAppPageContext } from "./components/AppPage/context.js";
|
|
13
13
|
import ProAppPage from "./components/AppPage/index.js";
|
|
@@ -20,4 +20,4 @@ import { MenuLookupEntry, MenuMetaPatch, MenuModel, MenuRoutePatch, MenuTreeMuta
|
|
|
20
20
|
import { LayoutMenuState, UseLayoutMenuOptions, UseLayoutMenuReturn, useMenu } from "./hooks/useMenu.js";
|
|
21
21
|
import { useTabs } from "./hooks/useTabs.js";
|
|
22
22
|
import { LayoutContextProps, useInjectLayoutContext } from "./context/index.js";
|
|
23
|
-
export { APP_PAGE_SLOT_KEYS, AppPageSlotKey, AppPageSpinning, type BreadcrumbItemType, type CardProps, DeepPartial, EmptyEmits, FOOTER_TOOLBAR_SLOT_KEYS, FooterToolbarClassNamesType, FooterToolbarSemanticName, FooterToolbarSlotKey, FooterToolbarStylesType, GFooterToolbar, GFooterToolbarProps, GFooterToolbarSlots, InnerTabs as GInnerTabs, GPageContainerEmits, GPageContainerEmitsProps, GPageContainerProps, GPageContainerSlots, GPageTransition, GPageTransitionProps, GPageTransitionSlots, ProAppPage as GProAppPage, GProAppPageProps, GProAppPageSlots, GProLayout, GProLayoutEmits, GProLayoutEmitsProps, GProLayoutProps, GProLayoutRef, GProLayoutSlots, ProPageContainer as GProPageContainer, InnerTabItem, InnerTabsEmits, InnerTabsEmitsProps, InnerTabsProps, InnerTabsSlots, LAYOUT_SLOT_KEYS, LayoutBreadcrumbConfig, LayoutBreadcrumbProps, LayoutBreadcrumbSlotProps, LayoutBreadcrumbSlots, LayoutClassNamesType, LayoutCollapseButtonEmits, LayoutCollapseButtonEmitsProps, LayoutCollapseButtonProps, LayoutCollapseButtonSlots, LayoutCollapseConfig, LayoutContentEmits, LayoutContentEmitsProps, LayoutContentProps, LayoutContentSlots, type LayoutContextProps, LayoutFooterConfig, LayoutFooterLink, LayoutFooterProps, LayoutFooterSlots, LayoutHeaderConfig, LayoutHeaderEmits, LayoutHeaderEmitsProps, LayoutHeaderProps, LayoutHeaderSlotProps, LayoutHeaderSlots, LayoutLogoConfig, LayoutLogoEmits, LayoutLogoEmitsProps, LayoutLogoProps, LayoutLogoSlots, LayoutMenuConfig, LayoutMenuItemSlotProps, LayoutMenuRoute, type LayoutMenuState, LayoutPageContainerConfig, LayoutSelectInfo, LayoutSemanticName, LayoutSiderConfig, LayoutSiderEmits, LayoutSiderEmitsProps, LayoutSiderProps, LayoutSiderSlotProps, LayoutSiderSlots, LayoutStylesType, LayoutTabsConfig, LayoutTabsController, LayoutTabsEmits, LayoutTabsEmitsProps, LayoutTabsProps, LayoutTabsSlots,
|
|
23
|
+
export { APP_PAGE_SLOT_KEYS, AppPageSlotKey, AppPageSpinning, type BreadcrumbItemType, type CardProps, DeepPartial, EmptyEmits, FOOTER_TOOLBAR_SLOT_KEYS, FooterToolbarClassNamesType, FooterToolbarSemanticName, FooterToolbarSlotKey, FooterToolbarStylesType, GFooterToolbar, GFooterToolbarProps, GFooterToolbarSlots, InnerTabs as GInnerTabs, GPageContainerEmits, GPageContainerEmitsProps, GPageContainerProps, GPageContainerSlots, GPageTransition, GPageTransitionProps, GPageTransitionSlots, ProAppPage as GProAppPage, GProAppPageProps, GProAppPageSlots, GProLayout, GProLayoutEmits, GProLayoutEmitsProps, GProLayoutProps, GProLayoutRef, GProLayoutSlots, ProPageContainer as GProPageContainer, InnerTabItem, InnerTabsEmits, InnerTabsEmitsProps, InnerTabsProps, InnerTabsSlots, LAYOUT_SLOT_KEYS, LayoutBreadcrumbConfig, LayoutBreadcrumbProps, LayoutBreadcrumbSlotProps, LayoutBreadcrumbSlots, LayoutClassNamesType, LayoutCollapseButtonEmits, LayoutCollapseButtonEmitsProps, LayoutCollapseButtonProps, LayoutCollapseButtonSlots, LayoutCollapseConfig, LayoutContentEmits, LayoutContentEmitsProps, LayoutContentProps, LayoutContentSlots, type LayoutContextProps, LayoutFooterConfig, LayoutFooterLink, LayoutFooterProps, LayoutFooterSlots, LayoutHeaderConfig, LayoutHeaderEmits, LayoutHeaderEmitsProps, LayoutHeaderProps, LayoutHeaderSlotProps, LayoutHeaderSlots, LayoutLogoConfig, LayoutLogoEmits, LayoutLogoEmitsProps, LayoutLogoProps, LayoutLogoSlots, LayoutMenuConfig, LayoutMenuItemSlotProps, LayoutMenuRoute, type LayoutMenuState, LayoutPageContainerConfig, LayoutSelectInfo, LayoutSemanticName, LayoutSiderConfig, LayoutSiderEmits, LayoutSiderEmitsProps, LayoutSiderProps, LayoutSiderSlotProps, LayoutSiderSlots, LayoutStylesType, LayoutTabsConfig, LayoutTabsController, LayoutTabsEmits, LayoutTabsEmitsProps, LayoutTabsOperation, LayoutTabsProps, LayoutTabsSlots, MenuClassNamesType, MenuClickInfo, MenuLookupEntry, MenuMetaPatch, MenuModel, type MenuProps, MenuRenderItem, MenuRoutePatch, MenuSelectInfo, MenuSemanticName, MenuStylesType, MenuTreeMutationOptions, Meta, PAGE_CONTAINER_SLOT_KEYS, PRO_MENU_SLOT_KEYS, PageContainerClassNamesType, PageContainerLoading, PageContainerSemanticName, PageContainerSlotKey, PageContainerStylesType, type ProAppPageContext, ProMenu, ProMenuEmits, ProMenuEmitsProps, ProMenuProps, ProMenuSlots, ResolveRouteResult, type SiderProps, type SpinProps, type Tab, TabGroup, TabsMeta, type TabsProps, type UseLayoutMenuOptions, type UseLayoutMenuReturn, type WatermarkProps, buildBreadcrumbRoutes, buildMenuLookup, cleanMenus, collectMenuNames, getLastPath, insertMenuAtPath, normalizeMenus, partitionFixedMenus, removeMenuAtPath, resolveMatchedChain, resolveRouteTarget, routesToMenus, selectMenuBranch, sortMenusByOrder, toBreadcrumbItems, updateMenuAtPath, updateMenuMetaAtPath, useAppPageContext, useInjectLayoutContext, useMenu, useTabs };
|
package/dist/interface.d.ts
CHANGED
|
@@ -345,7 +345,7 @@ interface GProLayoutSlots {
|
|
|
345
345
|
copyright?: () => any;
|
|
346
346
|
}
|
|
347
347
|
/** tabs 底层操作参数(add/merge/remove) */
|
|
348
|
-
interface
|
|
348
|
+
interface LayoutTabsOperation {
|
|
349
349
|
type: 'add' | 'merge' | 'remove';
|
|
350
350
|
addType?: 'push' | 'unshift';
|
|
351
351
|
params?: Partial<LayoutMenuRoute>;
|
|
@@ -387,7 +387,9 @@ interface LayoutTabsController {
|
|
|
387
387
|
/** 切换内容全屏 */
|
|
388
388
|
toggleFullscreen: () => void;
|
|
389
389
|
/** 底层增删改(add/merge/remove),语义化方法的兜底 */
|
|
390
|
-
|
|
390
|
+
dispatch: (name: string, operation: LayoutTabsOperation) => void;
|
|
391
|
+
/** 更新标签 meta(title/icon/tabState 等) */
|
|
392
|
+
updateMeta: (name: string, meta: Partial<Meta>) => void;
|
|
391
393
|
}
|
|
392
394
|
interface GProLayoutRef {
|
|
393
395
|
tabs: LayoutTabsController;
|
|
@@ -513,4 +515,4 @@ interface GPageTransitionSlots {
|
|
|
513
515
|
default?: () => any;
|
|
514
516
|
}
|
|
515
517
|
//#endregion
|
|
516
|
-
export { APP_PAGE_SLOT_KEYS, AppPageSlotKey, AppPageSpinning, type BreadcrumbItemType, type CardProps, DeepPartial, EmptyEmits, FOOTER_TOOLBAR_SLOT_KEYS, FooterToolbarClassNamesType, FooterToolbarSemanticName, FooterToolbarSlotKey, FooterToolbarStylesType, GFooterToolbarProps, GFooterToolbarSlots, GPageContainerEmits, GPageContainerEmitsProps, GPageContainerProps, GPageContainerSlots, GPageTransitionProps, GPageTransitionSlots, GProAppPageProps, GProAppPageSlots, GProLayoutEmits, GProLayoutEmitsProps, GProLayoutProps, GProLayoutRef, GProLayoutSlots, InnerTabItem, InnerTabsEmits, InnerTabsEmitsProps, InnerTabsProps, InnerTabsSlots, LAYOUT_SLOT_KEYS, LayoutBreadcrumbConfig, LayoutBreadcrumbProps, LayoutBreadcrumbSlotProps, LayoutBreadcrumbSlots, LayoutClassNamesType, LayoutCollapseButtonEmits, LayoutCollapseButtonEmitsProps, LayoutCollapseButtonProps, LayoutCollapseButtonSlots, LayoutCollapseConfig, LayoutContentEmits, LayoutContentEmitsProps, LayoutContentProps, LayoutContentSlots, LayoutFooterConfig, LayoutFooterLink, LayoutFooterProps, LayoutFooterSlots, LayoutHeaderConfig, LayoutHeaderEmits, LayoutHeaderEmitsProps, LayoutHeaderProps, LayoutHeaderSlotProps, LayoutHeaderSlots, LayoutLogoConfig, LayoutLogoEmits, LayoutLogoEmitsProps, LayoutLogoProps, LayoutLogoSlots, LayoutMenuConfig, LayoutMenuItemSlotProps, LayoutMenuRoute, LayoutPageContainerConfig, LayoutSelectInfo, LayoutSemanticName, LayoutSiderConfig, LayoutSiderEmits, LayoutSiderEmitsProps, LayoutSiderProps, LayoutSiderSlotProps, LayoutSiderSlots, LayoutStylesType, LayoutTabsConfig, LayoutTabsController, LayoutTabsEmits, LayoutTabsEmitsProps, LayoutTabsProps, LayoutTabsSlots,
|
|
518
|
+
export { APP_PAGE_SLOT_KEYS, AppPageSlotKey, AppPageSpinning, type BreadcrumbItemType, type CardProps, DeepPartial, EmptyEmits, FOOTER_TOOLBAR_SLOT_KEYS, FooterToolbarClassNamesType, FooterToolbarSemanticName, FooterToolbarSlotKey, FooterToolbarStylesType, GFooterToolbarProps, GFooterToolbarSlots, GPageContainerEmits, GPageContainerEmitsProps, GPageContainerProps, GPageContainerSlots, GPageTransitionProps, GPageTransitionSlots, GProAppPageProps, GProAppPageSlots, GProLayoutEmits, GProLayoutEmitsProps, GProLayoutProps, GProLayoutRef, GProLayoutSlots, InnerTabItem, InnerTabsEmits, InnerTabsEmitsProps, InnerTabsProps, InnerTabsSlots, LAYOUT_SLOT_KEYS, LayoutBreadcrumbConfig, LayoutBreadcrumbProps, LayoutBreadcrumbSlotProps, LayoutBreadcrumbSlots, LayoutClassNamesType, LayoutCollapseButtonEmits, LayoutCollapseButtonEmitsProps, LayoutCollapseButtonProps, LayoutCollapseButtonSlots, LayoutCollapseConfig, LayoutContentEmits, LayoutContentEmitsProps, LayoutContentProps, LayoutContentSlots, LayoutFooterConfig, LayoutFooterLink, LayoutFooterProps, LayoutFooterSlots, LayoutHeaderConfig, LayoutHeaderEmits, LayoutHeaderEmitsProps, LayoutHeaderProps, LayoutHeaderSlotProps, LayoutHeaderSlots, LayoutLogoConfig, LayoutLogoEmits, LayoutLogoEmitsProps, LayoutLogoProps, LayoutLogoSlots, LayoutMenuConfig, LayoutMenuItemSlotProps, LayoutMenuRoute, LayoutPageContainerConfig, LayoutSelectInfo, LayoutSemanticName, LayoutSiderConfig, LayoutSiderEmits, LayoutSiderEmitsProps, LayoutSiderProps, LayoutSiderSlotProps, LayoutSiderSlots, LayoutStylesType, LayoutTabsConfig, LayoutTabsController, LayoutTabsEmits, LayoutTabsEmitsProps, LayoutTabsOperation, LayoutTabsProps, LayoutTabsSlots, MenuClassNamesType, MenuClickInfo, type MenuProps, MenuRenderItem, MenuSelectInfo, MenuSemanticName, MenuStylesType, Meta, PAGE_CONTAINER_SLOT_KEYS, PRO_MENU_SLOT_KEYS, PageContainerClassNamesType, PageContainerLoading, PageContainerSemanticName, PageContainerSlotKey, PageContainerStylesType, ProMenuEmits, ProMenuEmitsProps, ProMenuProps, ProMenuSlots, type SiderProps, type SpinProps, type Tab, TabGroup, TabsMeta, type TabsProps, type WatermarkProps };
|