@jetlinks-web/components 2.0.2 → 2.0.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/es/AMap/Map.js +124 -0
- package/es/AMap/index.js +2 -0
- package/es/AMap/util.js +56 -0
- package/es/BadgeStatus/Badge.js +54 -0
- package/es/BadgeStatus/color.js +21 -0
- package/es/BadgeStatus/index.js +3 -0
- package/es/CardSelect/CardSelect.js +123 -0
- package/es/CardSelect/index.js +2 -0
- package/es/CheckButton/CheckButton.js +121 -0
- package/es/CheckButton/index.js +2 -0
- package/es/ConfigProvider/context.js +12 -0
- package/es/ConfigProvider/index.js +31 -0
- package/es/Echarts/Echarts.js +47 -0
- package/es/Echarts/index.js +2 -0
- package/es/Ellipsis/Ellipsis.js +189 -0
- package/es/Ellipsis/index.js +2 -0
- package/es/Empty/Empty.js +56 -0
- package/es/Empty/image.js +2 -0
- package/es/Empty/index.js +2 -0
- package/es/FullPage/FullPage.js +31 -0
- package/es/FullPage/index.js +2 -0
- package/es/Icon/icon.js +42 -0
- package/{src/Icon/index.ts → es/Icon/index.js} +2 -3
- package/es/MonacoEditor/Monaco.js +238 -0
- package/es/MonacoEditor/index.js +2 -0
- package/es/PermissionButton/index.js +117 -0
- package/es/ProLayout/Basic/BasicLayout.js +259 -0
- package/es/ProLayout/Basic/Header.js +97 -0
- package/es/ProLayout/PageContainer/index.js +324 -0
- package/es/ProLayout/PageContainer/typings.js +1 -0
- package/es/ProLayout/RouteContext.js +22 -0
- package/es/ProLayout/SiderMenu/BaseMenu.js +285 -0
- package/es/ProLayout/SiderMenu/SiderMenu.js +278 -0
- package/es/ProLayout/SiderMenu/index.js +2 -0
- package/es/ProLayout/SiderMenu/typings.js +1 -0
- package/es/ProLayout/TopHeader/index.js +163 -0
- package/es/ProLayout/defaultSettings.js +66 -0
- package/{src/ProLayout/index.ts → es/ProLayout/index.js} +4 -6
- package/{src → es}/ProLayout/style/default.less +4 -4
- package/es/ProLayout/style/index.js +1 -0
- package/es/ProLayout/typings.js +1 -0
- package/es/ProLayout/util.js +61 -0
- package/es/ProTable/index.js +411 -0
- package/es/ProTable/proTableTypes.js +11 -0
- package/es/ProTable/style/index.css +65 -0
- package/es/ProTable/style/index.js +1 -0
- package/es/Scrollbar/Bar.js +114 -0
- package/es/Scrollbar/Scrollbar.js +212 -0
- package/es/Scrollbar/Thumb.js +189 -0
- package/es/Scrollbar/constants.js +1 -0
- package/es/Scrollbar/index.js +2 -0
- package/es/Scrollbar/scrollbarProps.js +100 -0
- package/es/Scrollbar/thumbProps.js +10 -0
- package/es/Scrollbar/util.js +30 -0
- package/es/Search/Advanced/History.js +183 -0
- package/es/Search/Advanced/SaveHistory.js +153 -0
- package/es/Search/Advanced/index.js +520 -0
- package/es/Search/Item.js +497 -0
- package/es/Search/Search.js +249 -0
- package/es/Search/hooks/index.js +1 -0
- package/es/Search/hooks/useSearchItems.js +40 -0
- package/es/Search/index.js +4 -0
- package/es/Search/setting.js +91 -0
- package/es/Search/style/Item.less +33 -0
- package/es/Search/style/Search.less +179 -0
- package/es/Search/style/index.js +2 -0
- package/es/Search/typing.js +1 -0
- package/es/Search/util.js +234 -0
- package/es/ValueItem/ValueItem.js +233 -0
- package/es/ValueItem/index.js +2 -0
- package/es/ValueItem/util.js +16 -0
- package/es/index.js +24 -0
- package/es/style/index.js +3 -0
- package/es/style/variable.css +0 -0
- package/{src → es}/style/variable.less +0 -2
- package/es/style.js +3 -0
- package/lib/AMap/Map.js +124 -0
- package/lib/AMap/index.js +9 -0
- package/lib/AMap/util.js +62 -0
- package/lib/BadgeStatus/Badge.js +54 -0
- package/lib/BadgeStatus/color.js +27 -0
- package/lib/BadgeStatus/index.js +22 -0
- package/lib/CardSelect/CardSelect.js +123 -0
- package/lib/CardSelect/index.js +9 -0
- package/lib/CheckButton/CheckButton.js +121 -0
- package/lib/CheckButton/index.js +9 -0
- package/lib/ConfigProvider/context.js +19 -0
- package/lib/ConfigProvider/index.js +37 -0
- package/lib/Echarts/Echarts.js +47 -0
- package/lib/Echarts/index.js +9 -0
- package/lib/Ellipsis/Ellipsis.js +189 -0
- package/lib/Ellipsis/index.js +9 -0
- package/lib/Empty/Empty.js +56 -0
- package/lib/Empty/image.js +8 -0
- package/lib/Empty/index.js +9 -0
- package/lib/FullPage/FullPage.js +31 -0
- package/lib/FullPage/index.js +9 -0
- package/lib/Icon/icon.js +52 -0
- package/lib/Icon/index.js +9 -0
- package/lib/MonacoEditor/Monaco.js +238 -0
- package/lib/MonacoEditor/index.js +9 -0
- package/lib/PermissionButton/index.js +124 -0
- package/lib/ProLayout/Basic/BasicLayout.js +268 -0
- package/lib/ProLayout/Basic/BasicLayout.less +66 -0
- package/lib/ProLayout/Basic/Header.js +103 -0
- package/lib/ProLayout/Basic/Header.less +8 -0
- package/lib/ProLayout/PageContainer/index.js +327 -0
- package/lib/ProLayout/PageContainer/index.less +103 -0
- package/lib/ProLayout/PageContainer/typings.js +5 -0
- package/lib/ProLayout/RouteContext.js +28 -0
- package/lib/ProLayout/SiderMenu/BaseMenu.js +290 -0
- package/lib/ProLayout/SiderMenu/SiderMenu.js +287 -0
- package/lib/ProLayout/SiderMenu/index.js +20 -0
- package/lib/ProLayout/SiderMenu/index.less +212 -0
- package/lib/ProLayout/SiderMenu/typings.js +5 -0
- package/lib/ProLayout/TopHeader/index.js +168 -0
- package/lib/ProLayout/TopHeader/index.less +174 -0
- package/lib/ProLayout/defaultSettings.js +72 -0
- package/lib/ProLayout/index.js +16 -0
- package/lib/ProLayout/style/default.less +4 -0
- package/lib/ProLayout/style/index.js +3 -0
- package/lib/ProLayout/style/style.less +7 -0
- package/lib/ProLayout/typings.js +5 -0
- package/lib/ProLayout/util.js +72 -0
- package/lib/ProTable/index.js +417 -0
- package/lib/ProTable/proTableTypes.js +17 -0
- package/lib/ProTable/style/index.css +65 -0
- package/lib/ProTable/style/index.js +3 -0
- package/lib/ProTable/style/index.less +92 -0
- package/lib/Scrollbar/Bar.js +114 -0
- package/lib/Scrollbar/Scrollbar.js +212 -0
- package/lib/Scrollbar/Thumb.js +189 -0
- package/lib/Scrollbar/constants.js +7 -0
- package/lib/Scrollbar/index.js +9 -0
- package/{src/Scrollbar/scrollbar.ts → lib/Scrollbar/scrollbarProps.js} +106 -108
- package/lib/Scrollbar/thumbProps.js +16 -0
- package/lib/Scrollbar/util.js +37 -0
- package/lib/Search/Advanced/History.js +183 -0
- package/lib/Search/Advanced/SaveHistory.js +153 -0
- package/lib/Search/Advanced/index.js +520 -0
- package/lib/Search/Item.js +497 -0
- package/lib/Search/Search.js +249 -0
- package/lib/Search/hooks/index.js +16 -0
- package/lib/Search/hooks/useSearchItems.js +47 -0
- package/lib/Search/index.js +16 -0
- package/lib/Search/setting.js +97 -0
- package/lib/Search/style/Item.less +33 -0
- package/lib/Search/style/Search.less +179 -0
- package/lib/Search/style/index.js +4 -0
- package/lib/Search/typing.js +5 -0
- package/lib/Search/util.js +241 -0
- package/lib/ValueItem/ValueItem.js +233 -0
- package/lib/ValueItem/index.js +9 -0
- package/lib/ValueItem/util.js +22 -0
- package/lib/index.js +158 -0
- package/lib/style/components.less +1 -0
- package/lib/style/index.js +4 -0
- package/lib/style/variable.css +0 -0
- package/lib/style/variable.less +2 -0
- package/lib/style.js +5 -0
- package/package.json +122 -13
- package/index.ts +0 -64
- package/src/AMap/Map.vue +0 -110
- package/src/AMap/index.ts +0 -1
- package/src/AMap/util.ts +0 -56
- package/src/BadgeStatus/Badge.vue +0 -41
- package/src/BadgeStatus/color.ts +0 -25
- package/src/BadgeStatus/index.ts +0 -4
- package/src/CardSelect/CardSelect.vue +0 -136
- package/src/CardSelect/index.ts +0 -3
- package/src/CheckButton/CheckButton.vue +0 -146
- package/src/CheckButton/index.md +0 -27
- package/src/CheckButton/index.ts +0 -3
- package/src/ConfigProvider/context.ts +0 -17
- package/src/ConfigProvider/index.tsx +0 -42
- package/src/Echarts/Echarts.vue +0 -43
- package/src/Echarts/index.ts +0 -3
- package/src/Ellipsis/Ellipsis.vue +0 -182
- package/src/Ellipsis/index.ts +0 -3
- package/src/Empty/Empty.vue +0 -43
- package/src/Empty/image.ts +0 -3
- package/src/Empty/index.ts +0 -2
- package/src/FullPage/FullPage.vue +0 -30
- package/src/FullPage/index.ts +0 -3
- package/src/Icon/icon.tsx +0 -40
- package/src/MonacoEditor/Monaco.vue +0 -242
- package/src/MonacoEditor/index.md +0 -26
- package/src/MonacoEditor/index.ts +0 -2
- package/src/PermissionButton/index.tsx +0 -110
- package/src/ProLayout/Basic/BasicLayout.tsx +0 -392
- package/src/ProLayout/Basic/Header.tsx +0 -115
- package/src/ProLayout/PageContainer/index.tsx +0 -441
- package/src/ProLayout/PageContainer/typings.ts +0 -56
- package/src/ProLayout/RouteContext.ts +0 -87
- package/src/ProLayout/SiderMenu/BaseMenu.tsx +0 -296
- package/src/ProLayout/SiderMenu/SiderMenu.tsx +0 -320
- package/src/ProLayout/SiderMenu/index.ts +0 -2
- package/src/ProLayout/SiderMenu/typings.ts +0 -49
- package/src/ProLayout/TopHeader/index.tsx +0 -210
- package/src/ProLayout/defaultSettings.ts +0 -106
- package/src/ProLayout/style/index.ts +0 -1
- package/src/ProLayout/typings.ts +0 -87
- package/src/ProLayout/util.ts +0 -64
- package/src/ProTable/index.md +0 -53
- package/src/ProTable/index.tsx +0 -551
- package/src/ProTable/proTableTypes.ts +0 -70
- package/src/ProTable/style/index.ts +0 -1
- package/src/Scrollbar/Bar.vue +0 -75
- package/src/Scrollbar/Scrollbar.vue +0 -260
- package/src/Scrollbar/Thumb.vue +0 -163
- package/src/Scrollbar/constants.ts +0 -10
- package/src/Scrollbar/index.ts +0 -4
- package/src/Scrollbar/thumb.ts +0 -16
- package/src/Scrollbar/util.ts +0 -38
- package/src/Search/Advanced/History.vue +0 -140
- package/src/Search/Advanced/SaveHistory.vue +0 -108
- package/src/Search/Advanced/index.vue +0 -435
- package/src/Search/Item.vue +0 -525
- package/src/Search/Search.vue +0 -398
- package/src/Search/hooks/index.ts +0 -1
- package/src/Search/hooks/useSearchItems.ts +0 -68
- package/src/Search/index.md +0 -57
- package/src/Search/index.ts +0 -5
- package/src/Search/setting.ts +0 -55
- package/src/Search/typing.ts +0 -76
- package/src/Search/util.ts +0 -263
- package/src/ValueItem/ValueItem.vue +0 -192
- package/src/ValueItem/index.ts +0 -3
- package/src/ValueItem/util.ts +0 -16
- package/src/style/index.ts +0 -3
- /package/{src → es}/ProLayout/Basic/BasicLayout.less +0 -0
- /package/{src → es}/ProLayout/Basic/Header.less +0 -0
- /package/{src → es}/ProLayout/PageContainer/index.less +0 -0
- /package/{src → es}/ProLayout/SiderMenu/index.less +0 -0
- /package/{src → es}/ProLayout/TopHeader/index.less +0 -0
- /package/{src → es}/ProLayout/style/style.less +0 -0
- /package/{src → es}/ProTable/style/index.less +0 -0
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import { defaultSettingProps } from '../defaultSettings';
|
|
2
|
-
import {
|
|
3
|
-
defineComponent,
|
|
4
|
-
getCurrentInstance,
|
|
5
|
-
isVNode,
|
|
6
|
-
resolveComponent,
|
|
7
|
-
watchEffect,
|
|
8
|
-
withCtx,
|
|
9
|
-
} from 'vue';
|
|
10
|
-
import type {
|
|
11
|
-
ExtractPropTypes,
|
|
12
|
-
FunctionalComponent,
|
|
13
|
-
PropType,
|
|
14
|
-
VNodeChild,
|
|
15
|
-
ComponentInternalInstance,
|
|
16
|
-
ConcreteComponent,
|
|
17
|
-
VNode,
|
|
18
|
-
} from 'vue';
|
|
19
|
-
import type {
|
|
20
|
-
SelectEventHandler,
|
|
21
|
-
MenuClickEventHandler,
|
|
22
|
-
SelectInfo,
|
|
23
|
-
MenuInfo,
|
|
24
|
-
} from 'ant-design-vue/es/menu/src/interface';
|
|
25
|
-
import type {
|
|
26
|
-
FormatMessage,
|
|
27
|
-
MenuDataItem,
|
|
28
|
-
WithFalse,
|
|
29
|
-
Theme,
|
|
30
|
-
MenuItemRender,
|
|
31
|
-
SubMenuItemRender,
|
|
32
|
-
} from '../typings';
|
|
33
|
-
import type { MenuMode } from 'ant-design-vue';
|
|
34
|
-
import type { Key } from 'ant-design-vue/es/_util/type';
|
|
35
|
-
import { defaultPrefixCls } from '../RouteContext';
|
|
36
|
-
import { AIcon as IconFont } from '../../../';
|
|
37
|
-
import { regular } from '@jetlinks-web/utils';
|
|
38
|
-
import { Menu } from 'ant-design-vue';
|
|
39
|
-
import { createFromIconfontCN } from '@ant-design/icons-vue';
|
|
40
|
-
|
|
41
|
-
export const baseMenuProps = {
|
|
42
|
-
...defaultSettingProps,
|
|
43
|
-
prefixCls: {
|
|
44
|
-
type: String as PropType<string | undefined>,
|
|
45
|
-
default: () => defaultPrefixCls,
|
|
46
|
-
},
|
|
47
|
-
locale: {
|
|
48
|
-
type: [Function, Boolean] as PropType<WithFalse<FormatMessage>>,
|
|
49
|
-
default: (t: string): string => t,
|
|
50
|
-
},
|
|
51
|
-
menuData: {
|
|
52
|
-
type: Array as PropType<MenuDataItem[]>,
|
|
53
|
-
default: () => [],
|
|
54
|
-
},
|
|
55
|
-
mode: {
|
|
56
|
-
type: String as PropType<MenuMode>,
|
|
57
|
-
default: 'inline',
|
|
58
|
-
},
|
|
59
|
-
theme: {
|
|
60
|
-
type: String as PropType<Theme>,
|
|
61
|
-
default: 'dark',
|
|
62
|
-
},
|
|
63
|
-
collapsed: {
|
|
64
|
-
type: Boolean as PropType<boolean | undefined>,
|
|
65
|
-
default: () => false,
|
|
66
|
-
},
|
|
67
|
-
openKeys: {
|
|
68
|
-
type: Array as PropType<WithFalse<string[]>>,
|
|
69
|
-
default: () => undefined,
|
|
70
|
-
},
|
|
71
|
-
selectedKeys: {
|
|
72
|
-
type: Array as PropType<WithFalse<string[]>>,
|
|
73
|
-
default: () => undefined,
|
|
74
|
-
},
|
|
75
|
-
menuProps: {
|
|
76
|
-
type: Object as PropType<Record<string, any>>,
|
|
77
|
-
default: () => null,
|
|
78
|
-
},
|
|
79
|
-
menuItemRender: {
|
|
80
|
-
type: [Object, Function, Boolean] as PropType<MenuItemRender>,
|
|
81
|
-
default: () => undefined,
|
|
82
|
-
},
|
|
83
|
-
subMenuItemRender: {
|
|
84
|
-
type: [Object, Function, Boolean] as PropType<SubMenuItemRender>,
|
|
85
|
-
default: () => undefined,
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
onClick: [Function, Object] as PropType<(...args: any) => void>,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export type BaseMenuProps = ExtractPropTypes<typeof baseMenuProps>;
|
|
92
|
-
|
|
93
|
-
type IconFontProps = {
|
|
94
|
-
icon: VNodeChild | string;
|
|
95
|
-
iconUrl: string;
|
|
96
|
-
prefixCls?: string;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
let AntdIconFont = createFromIconfontCN({
|
|
100
|
-
scriptUrl: '',
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const LazyIcon: FunctionalComponent<IconFontProps> = (props) => {
|
|
104
|
-
const {icon, iconUrl, prefixCls = defaultPrefixCls} = props;
|
|
105
|
-
if (!icon) return null;
|
|
106
|
-
if (isVNode(icon)) {
|
|
107
|
-
return icon;
|
|
108
|
-
}
|
|
109
|
-
if (typeof icon === 'string' && icon !== '') {
|
|
110
|
-
if (regular.isUrl(icon) || regular.isImg(icon)) {
|
|
111
|
-
return (
|
|
112
|
-
<img
|
|
113
|
-
src={icon}
|
|
114
|
-
alt="icon"
|
|
115
|
-
class={`${prefixCls}-sider-menu-icon`}
|
|
116
|
-
/>
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
return iconUrl ? (
|
|
120
|
-
<AntdIconFont type={icon}/>
|
|
121
|
-
) : (
|
|
122
|
-
<IconFont type={icon}/>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
class MenuUtil {
|
|
128
|
-
props: BaseMenuProps;
|
|
129
|
-
|
|
130
|
-
ctx: ComponentInternalInstance | null;
|
|
131
|
-
|
|
132
|
-
RouterLink: ConcreteComponent;
|
|
133
|
-
|
|
134
|
-
constructor(props: BaseMenuProps, ctx: ComponentInternalInstance | null) {
|
|
135
|
-
this.props = props;
|
|
136
|
-
this.ctx = ctx;
|
|
137
|
-
this.RouterLink = resolveComponent('router-link') as ConcreteComponent;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
getNavMenuItems = (menusData: MenuDataItem[] = []) => {
|
|
141
|
-
return menusData
|
|
142
|
-
.map((item) => this.getSubMenuOrItem(item))
|
|
143
|
-
.filter((item) => item);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
getSubMenuOrItem = (item: MenuDataItem): VNode => {
|
|
147
|
-
if (
|
|
148
|
-
Array.isArray(item.children) &&
|
|
149
|
-
item.children.length > 0 &&
|
|
150
|
-
!item?.meta?.hideInMenu &&
|
|
151
|
-
!item?.meta?.hideChildrenInMenu
|
|
152
|
-
) {
|
|
153
|
-
if (this.props.subMenuItemRender) {
|
|
154
|
-
const subMenuItemRender = withCtx(
|
|
155
|
-
this.props.subMenuItemRender,
|
|
156
|
-
this.ctx,
|
|
157
|
-
);
|
|
158
|
-
return subMenuItemRender({
|
|
159
|
-
item,
|
|
160
|
-
children: this.getNavMenuItems(item.children),
|
|
161
|
-
}) as VNode;
|
|
162
|
-
}
|
|
163
|
-
const {prefixCls, locale} = this.props;
|
|
164
|
-
const menuTitle =
|
|
165
|
-
(locale && locale(item.meta?.title)) || item.meta?.title;
|
|
166
|
-
const defaultTitle = item.meta?.icon ? (
|
|
167
|
-
<span class={`${prefixCls}-menu-item`}>
|
|
168
|
-
<span class={`${prefixCls}-menu-item-title`}>
|
|
169
|
-
{menuTitle}
|
|
170
|
-
</span>
|
|
171
|
-
</span>
|
|
172
|
-
) : (
|
|
173
|
-
<span class={`${prefixCls}-menu-item`}>{menuTitle}</span>
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
<Menu.SubMenu
|
|
178
|
-
title={defaultTitle}
|
|
179
|
-
key={item.path}
|
|
180
|
-
popupClassName={`${prefixCls}-menu-popup`}
|
|
181
|
-
icon={
|
|
182
|
-
<LazyIcon
|
|
183
|
-
iconUrl={this.props.iconfontUrl}
|
|
184
|
-
icon={item.meta?.icon}
|
|
185
|
-
/>
|
|
186
|
-
}
|
|
187
|
-
>
|
|
188
|
-
{this.getNavMenuItems(item.children)}
|
|
189
|
-
</Menu.SubMenu>
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const menuItemRender =
|
|
194
|
-
this.props.menuItemRender &&
|
|
195
|
-
withCtx(this.props.menuItemRender, this.ctx);
|
|
196
|
-
|
|
197
|
-
const [title, icon] = this.getMenuItem(item);
|
|
198
|
-
|
|
199
|
-
return (
|
|
200
|
-
(menuItemRender &&
|
|
201
|
-
(menuItemRender({item, title, icon}) as VNode)) || (
|
|
202
|
-
<Menu.Item
|
|
203
|
-
disabled={item.meta?.disabled}
|
|
204
|
-
danger={item.meta?.danger}
|
|
205
|
-
key={item.path}
|
|
206
|
-
>
|
|
207
|
-
{title}
|
|
208
|
-
</Menu.Item>
|
|
209
|
-
)
|
|
210
|
-
);
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
getMenuItem = (item: MenuDataItem) => {
|
|
214
|
-
const meta = {...item.meta};
|
|
215
|
-
const target = (meta.target || null) as string | null;
|
|
216
|
-
const hasUrl = regular.isUrl(item.path);
|
|
217
|
-
const CustomTag: any = (target && 'a') || this.RouterLink;
|
|
218
|
-
const props = {to: {name: item.name, ...item.meta}};
|
|
219
|
-
const attrs =
|
|
220
|
-
hasUrl || target ? {...item.meta, href: item.path, target} : {};
|
|
221
|
-
|
|
222
|
-
const {prefixCls, locale} = this.props;
|
|
223
|
-
const icon =
|
|
224
|
-
(item.meta?.icon && (
|
|
225
|
-
<LazyIcon
|
|
226
|
-
iconUrl={this.props.iconfontUrl}
|
|
227
|
-
icon={item.meta?.icon}
|
|
228
|
-
/>
|
|
229
|
-
)) ||
|
|
230
|
-
undefined;
|
|
231
|
-
const menuTitle =
|
|
232
|
-
(locale && locale(item.meta?.title)) || item.meta?.title;
|
|
233
|
-
|
|
234
|
-
const defaultTitle = item.meta?.icon ? (
|
|
235
|
-
<CustomTag {...attrs} {...props} class={`${prefixCls}-menu-item`}>
|
|
236
|
-
{icon}
|
|
237
|
-
<span class={`${prefixCls}-menu-item-title`}>{menuTitle}</span>
|
|
238
|
-
</CustomTag>
|
|
239
|
-
) : (
|
|
240
|
-
<CustomTag {...attrs} {...props} class={`${prefixCls}-menu-item`}>
|
|
241
|
-
<span>{menuTitle}</span>
|
|
242
|
-
</CustomTag>
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
return [defaultTitle, icon];
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export default defineComponent({
|
|
250
|
-
name: 'BaseMenu',
|
|
251
|
-
props: baseMenuProps,
|
|
252
|
-
emits: ['update:openKeys', 'update:selectedKeys', 'click'],
|
|
253
|
-
setup(props, {emit}) {
|
|
254
|
-
const ctx = getCurrentInstance();
|
|
255
|
-
const menuUtil = new MenuUtil(props, ctx);
|
|
256
|
-
|
|
257
|
-
watchEffect(() => {
|
|
258
|
-
if (props.iconfontUrl) {
|
|
259
|
-
AntdIconFont = createFromIconfontCN({
|
|
260
|
-
scriptUrl: props.iconfontUrl,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
const handleOpenChange = (openKeys: Key[]): void => {
|
|
266
|
-
emit('update:openKeys', openKeys);
|
|
267
|
-
};
|
|
268
|
-
const handleSelect: SelectEventHandler = (args: SelectInfo): void => {
|
|
269
|
-
// ignore https? link handle selectkeys
|
|
270
|
-
if (regular.isUrl(args.key as string)) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
emit('update:selectedKeys', args.selectedKeys);
|
|
274
|
-
};
|
|
275
|
-
const handleClick: MenuClickEventHandler = (args: MenuInfo) => {
|
|
276
|
-
emit('click', args);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
return () => (
|
|
280
|
-
<Menu
|
|
281
|
-
key="Menu"
|
|
282
|
-
inlineIndent={16}
|
|
283
|
-
mode={props.mode}
|
|
284
|
-
theme={props.theme}
|
|
285
|
-
openKeys={props.openKeys === false ? [] : props.openKeys}
|
|
286
|
-
selectedKeys={props.selectedKeys || []}
|
|
287
|
-
onOpenChange={handleOpenChange}
|
|
288
|
-
onSelect={handleSelect}
|
|
289
|
-
onClick={handleClick}
|
|
290
|
-
{...props.menuProps}
|
|
291
|
-
>
|
|
292
|
-
{menuUtil.getNavMenuItems(props.menuData)}
|
|
293
|
-
</Menu>
|
|
294
|
-
);
|
|
295
|
-
},
|
|
296
|
-
});
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MenuHeaderRender,
|
|
3
|
-
MenuContentRender,
|
|
4
|
-
MenuExtraRender,
|
|
5
|
-
CollapsedButtonRender,
|
|
6
|
-
LogoRender,
|
|
7
|
-
WithFalse,
|
|
8
|
-
} from '../typings';
|
|
9
|
-
import type { SiderProps } from './typings';
|
|
10
|
-
import { LayoutSider as Sider, Menu } from 'ant-design-vue';
|
|
11
|
-
import BaseMenu, { baseMenuProps } from './BaseMenu';
|
|
12
|
-
import { defaultSettingProps } from '../defaultSettings';
|
|
13
|
-
import PropTypes from 'ant-design-vue/es/_util/vue-types';
|
|
14
|
-
import type {
|
|
15
|
-
CSSProperties,
|
|
16
|
-
ExtractPropTypes,
|
|
17
|
-
PropType,
|
|
18
|
-
FunctionalComponent,
|
|
19
|
-
} from 'vue';
|
|
20
|
-
import type { VueNode } from 'ant-design-vue/es/_util/type';
|
|
21
|
-
import { AIcon as IconFont } from '../../../';
|
|
22
|
-
import { useRouteContext } from '../RouteContext';
|
|
23
|
-
import { computed, unref } from 'vue';
|
|
24
|
-
|
|
25
|
-
export type PrivateSiderMenuProps = {
|
|
26
|
-
matchMenuKeys?: string[];
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const siderMenuProps = {
|
|
30
|
-
...defaultSettingProps,
|
|
31
|
-
...baseMenuProps,
|
|
32
|
-
logo: {
|
|
33
|
-
type: [Object, String, Function] as PropType<LogoRender>,
|
|
34
|
-
default: () => undefined,
|
|
35
|
-
},
|
|
36
|
-
logoStyle: {
|
|
37
|
-
type: Object as PropType<CSSProperties>,
|
|
38
|
-
default: () => undefined,
|
|
39
|
-
},
|
|
40
|
-
siderWidth: PropTypes.number.def(208),
|
|
41
|
-
headerHeight: PropTypes.number.def(48),
|
|
42
|
-
collapsedWidth: PropTypes.number.def(48),
|
|
43
|
-
menuHeaderRender: {
|
|
44
|
-
type: [Function, Object, Boolean] as PropType<MenuHeaderRender>,
|
|
45
|
-
default: () => undefined,
|
|
46
|
-
},
|
|
47
|
-
menuContentRender: {
|
|
48
|
-
type: [Function, Object, Boolean] as PropType<MenuContentRender>,
|
|
49
|
-
default: () => undefined,
|
|
50
|
-
},
|
|
51
|
-
menuExtraRender: {
|
|
52
|
-
type: [Function, Object, Boolean] as PropType<MenuExtraRender>,
|
|
53
|
-
default: () => undefined,
|
|
54
|
-
},
|
|
55
|
-
collapsedButtonRender: {
|
|
56
|
-
type: [Function, Object, Boolean] as PropType<CollapsedButtonRender>,
|
|
57
|
-
default: () => undefined,
|
|
58
|
-
},
|
|
59
|
-
breakpoint: {
|
|
60
|
-
type: [Object, Boolean] as PropType<SiderProps['breakpoint'] | false>,
|
|
61
|
-
default: () => false,
|
|
62
|
-
},
|
|
63
|
-
splitMenus: PropTypes.looseBool,
|
|
64
|
-
fixed: PropTypes.looseBool,
|
|
65
|
-
hide: PropTypes.looseBool,
|
|
66
|
-
matchMenuKeys: {
|
|
67
|
-
type: Array as PropType<string[]>,
|
|
68
|
-
default: () => [],
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
// events
|
|
72
|
-
onMenuHeaderClick: PropTypes.func,
|
|
73
|
-
onMenuClick: PropTypes.func,
|
|
74
|
-
onCollapse: {
|
|
75
|
-
type: Function as PropType<(collapsed: boolean) => void>,
|
|
76
|
-
},
|
|
77
|
-
onOpenKeys: {
|
|
78
|
-
type: Function as PropType<(openKeys: WithFalse<string[]>) => void>,
|
|
79
|
-
},
|
|
80
|
-
onSelect: {
|
|
81
|
-
type: Function as PropType<(selectedKeys: WithFalse<string[]>) => void>,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export type SiderMenuProps = Partial<ExtractPropTypes<typeof siderMenuProps>>;
|
|
86
|
-
|
|
87
|
-
export const defaultRenderLogo = (
|
|
88
|
-
logo?: VueNode,
|
|
89
|
-
logoStyle?: CSSProperties,
|
|
90
|
-
): VueNode => {
|
|
91
|
-
if (!logo) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
if (typeof logo === 'string') {
|
|
95
|
-
return <img src={logo} alt="logo" style={logoStyle}/>;
|
|
96
|
-
}
|
|
97
|
-
if (typeof logo === 'function') {
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
return logo();
|
|
100
|
-
}
|
|
101
|
-
return logo;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const defaultRenderLogoAndTitle = (
|
|
105
|
-
props: SiderMenuProps,
|
|
106
|
-
renderKey: string | undefined = 'menuHeaderRender',
|
|
107
|
-
): VueNode | null => {
|
|
108
|
-
const {
|
|
109
|
-
logo = 'http://demo.jetlinks.cn/static/logo.760eb65c.png',
|
|
110
|
-
logoStyle,
|
|
111
|
-
title,
|
|
112
|
-
layout,
|
|
113
|
-
} = props;
|
|
114
|
-
const renderFunction = (props as Record<string, VueNode>)[renderKey || ''];
|
|
115
|
-
if (layout === 'mix' && renderFunction === false) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
const logoDom = defaultRenderLogo(logo, logoStyle);
|
|
119
|
-
const titleDom = <h1>{title}</h1>;
|
|
120
|
-
if (renderKey === 'menuHeaderRender') {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
// call menuHeaderRender
|
|
124
|
-
if (typeof renderFunction === 'function') {
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
return renderFunction(
|
|
127
|
-
logoDom,
|
|
128
|
-
props.collapsed ? null : titleDom,
|
|
129
|
-
props,
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
if (Array.isArray(renderFunction)) {
|
|
133
|
-
return <>{renderFunction}</>;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<a>
|
|
138
|
-
{logoDom}
|
|
139
|
-
{props.collapsed ? null : titleDom}
|
|
140
|
-
</a>
|
|
141
|
-
);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const defaultRenderCollapsedButton = (collapsed?: boolean): VueNode =>
|
|
145
|
-
collapsed ? (
|
|
146
|
-
<IconFont type={'MenuUnfoldOutlined'}/>
|
|
147
|
-
) : (
|
|
148
|
-
<IconFont type={'MenuFoldOutlined'}/>
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
const SiderMenu: FunctionalComponent<SiderMenuProps> = (
|
|
152
|
-
props: SiderMenuProps,
|
|
153
|
-
) => {
|
|
154
|
-
const {
|
|
155
|
-
collapsed,
|
|
156
|
-
siderWidth,
|
|
157
|
-
breakpoint,
|
|
158
|
-
collapsedWidth = 48,
|
|
159
|
-
menuExtraRender = false,
|
|
160
|
-
menuContentRender = false,
|
|
161
|
-
collapsedButtonRender = defaultRenderCollapsedButton,
|
|
162
|
-
theme,
|
|
163
|
-
} = props;
|
|
164
|
-
|
|
165
|
-
const context = useRouteContext();
|
|
166
|
-
const {getPrefixCls} = context;
|
|
167
|
-
const baseClassName = getPrefixCls('sider');
|
|
168
|
-
const hasSplitMenu = computed(
|
|
169
|
-
() => props.layout === 'mix' && props.splitMenus,
|
|
170
|
-
);
|
|
171
|
-
const sSideWidth = computed(() =>
|
|
172
|
-
props.collapsed ? props.collapsedWidth : props.siderWidth,
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
const classNames = computed(() => {
|
|
176
|
-
return {
|
|
177
|
-
[baseClassName]: true,
|
|
178
|
-
[`${baseClassName}-fixed`]: context.fixSiderbar,
|
|
179
|
-
[`${baseClassName}-${theme}`]: true, // theme !== 'dark'
|
|
180
|
-
[`${baseClassName}-layout-${props.layout}`]: props.layout,
|
|
181
|
-
};
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
const handleSelect = ($event: string[]) => {
|
|
185
|
-
if (props.onSelect) {
|
|
186
|
-
if (unref(hasSplitMenu)) {
|
|
187
|
-
props.onSelect([context.selectedKeys[0], ...$event]);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
props.onSelect($event);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const headerDom = defaultRenderLogoAndTitle(props);
|
|
195
|
-
const extraDom = menuExtraRender && menuExtraRender(props);
|
|
196
|
-
|
|
197
|
-
if (hasSplitMenu.value && unref(context.flatMenuData).length === 0) {
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const defaultMenuDom = (
|
|
202
|
-
<BaseMenu
|
|
203
|
-
prefixCls={getPrefixCls()}
|
|
204
|
-
locale={props.locale || context.locale}
|
|
205
|
-
theme={theme}
|
|
206
|
-
mode="inline"
|
|
207
|
-
menuData={
|
|
208
|
-
hasSplitMenu.value ? context.flatMenuData : context.menuData
|
|
209
|
-
}
|
|
210
|
-
collapsed={props.collapsed}
|
|
211
|
-
openKeys={context.openKeys}
|
|
212
|
-
selectedKeys={context.selectedKeys}
|
|
213
|
-
menuItemRender={props.menuItemRender}
|
|
214
|
-
subMenuItemRender={props.subMenuItemRender}
|
|
215
|
-
iconfontUrl={props.iconfontUrl}
|
|
216
|
-
onClick={props.onMenuClick}
|
|
217
|
-
style={{width: '100%'}}
|
|
218
|
-
class={`${baseClassName}-menu`}
|
|
219
|
-
{...{
|
|
220
|
-
'onUpdate:openKeys': ($event: string[]) =>
|
|
221
|
-
props.onOpenKeys && props.onOpenKeys($event),
|
|
222
|
-
'onUpdate:selectedKeys': handleSelect,
|
|
223
|
-
}}
|
|
224
|
-
/>
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
return (
|
|
228
|
-
<>
|
|
229
|
-
{context.fixSiderbar && (
|
|
230
|
-
<div
|
|
231
|
-
style={{
|
|
232
|
-
width: `${sSideWidth.value}px`,
|
|
233
|
-
overflow: 'hidden',
|
|
234
|
-
flex: `0 0 ${sSideWidth.value}px`,
|
|
235
|
-
maxWidth: `${sSideWidth.value}px`,
|
|
236
|
-
minWidth: `${sSideWidth.value}px`,
|
|
237
|
-
transition: `background-color 0.3s, min-width 0.3s, max-width 0.3s cubic-bezier(0.645, 0.045, 0.355, 1)`,
|
|
238
|
-
}}
|
|
239
|
-
/>
|
|
240
|
-
)}
|
|
241
|
-
<Sider
|
|
242
|
-
collapsible
|
|
243
|
-
trigger={null}
|
|
244
|
-
collapsed={collapsed}
|
|
245
|
-
breakpoint={breakpoint || undefined}
|
|
246
|
-
onCollapse={(collapse: boolean) => {
|
|
247
|
-
props.onCollapse?.(collapse);
|
|
248
|
-
}}
|
|
249
|
-
collapsedWidth={collapsedWidth}
|
|
250
|
-
style={{
|
|
251
|
-
overflow: 'hidden',
|
|
252
|
-
paddingTop: `${props.headerHeight}px`,
|
|
253
|
-
}}
|
|
254
|
-
width={siderWidth}
|
|
255
|
-
theme={theme}
|
|
256
|
-
class={classNames.value}
|
|
257
|
-
>
|
|
258
|
-
{headerDom && (
|
|
259
|
-
<div
|
|
260
|
-
class={`${baseClassName}-logo`}
|
|
261
|
-
onClick={
|
|
262
|
-
props.layout !== 'mix'
|
|
263
|
-
? props.onMenuHeaderClick
|
|
264
|
-
: undefined
|
|
265
|
-
}
|
|
266
|
-
id="logo"
|
|
267
|
-
style={props?.logoStyle}
|
|
268
|
-
>
|
|
269
|
-
{headerDom}
|
|
270
|
-
</div>
|
|
271
|
-
)}
|
|
272
|
-
{extraDom && !props.collapsed && (
|
|
273
|
-
<div
|
|
274
|
-
class={{
|
|
275
|
-
[`${baseClassName}-extra`]: true,
|
|
276
|
-
[`${baseClassName}-extra-no-logo`]: !headerDom,
|
|
277
|
-
}}
|
|
278
|
-
>
|
|
279
|
-
{extraDom}
|
|
280
|
-
</div>
|
|
281
|
-
)}
|
|
282
|
-
<div style="flex: 1; overflow: hidden auto;">
|
|
283
|
-
{(menuContentRender &&
|
|
284
|
-
menuContentRender(props, defaultMenuDom)) ||
|
|
285
|
-
defaultMenuDom}
|
|
286
|
-
</div>
|
|
287
|
-
<div class={`${baseClassName}-links`}>
|
|
288
|
-
{collapsedButtonRender !== false ? (
|
|
289
|
-
<Menu
|
|
290
|
-
class={`${baseClassName}-link-menu`}
|
|
291
|
-
inlineIndent={16}
|
|
292
|
-
theme={theme}
|
|
293
|
-
selectedKeys={[]}
|
|
294
|
-
openKeys={[]}
|
|
295
|
-
mode="inline"
|
|
296
|
-
onClick={() => {
|
|
297
|
-
if (props.onCollapse) {
|
|
298
|
-
props.onCollapse(!props.collapsed);
|
|
299
|
-
}
|
|
300
|
-
}}
|
|
301
|
-
>
|
|
302
|
-
<Menu.Item
|
|
303
|
-
key={'collapsed-button'}
|
|
304
|
-
class={`${baseClassName}-collapsed-button`}
|
|
305
|
-
title={false}
|
|
306
|
-
>
|
|
307
|
-
{collapsedButtonRender &&
|
|
308
|
-
typeof collapsedButtonRender === 'function'
|
|
309
|
-
? collapsedButtonRender(collapsed)
|
|
310
|
-
: collapsedButtonRender}
|
|
311
|
-
</Menu.Item>
|
|
312
|
-
</Menu>
|
|
313
|
-
) : null}
|
|
314
|
-
</div>
|
|
315
|
-
</Sider>
|
|
316
|
-
</>
|
|
317
|
-
);
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
export default SiderMenu;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { VNodeChild, CSSProperties, HTMLAttributes } from 'vue';
|
|
2
|
-
import type { Theme } from '../typings';
|
|
3
|
-
|
|
4
|
-
export type {
|
|
5
|
-
MenuMode,
|
|
6
|
-
MenuTheme,
|
|
7
|
-
} from 'ant-design-vue/es/menu/src/interface';
|
|
8
|
-
|
|
9
|
-
export interface MenuInfo {
|
|
10
|
-
key: string | number;
|
|
11
|
-
keyPath: string[] | number[];
|
|
12
|
-
item: VNodeChild;
|
|
13
|
-
domEvent: MouseEvent;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface SelectInfo extends MenuInfo {
|
|
17
|
-
selectedKeys: string[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type OpenEventHandler = (
|
|
21
|
-
keys:
|
|
22
|
-
| string[]
|
|
23
|
-
| {
|
|
24
|
-
key: string;
|
|
25
|
-
item: VNodeChild;
|
|
26
|
-
trigger: string;
|
|
27
|
-
open: boolean;
|
|
28
|
-
},
|
|
29
|
-
) => void;
|
|
30
|
-
|
|
31
|
-
export type SiderTheme = Theme;
|
|
32
|
-
|
|
33
|
-
export type CollapseType = 'clickTrigger' | 'responsive';
|
|
34
|
-
|
|
35
|
-
export interface SiderProps extends HTMLAttributes {
|
|
36
|
-
prefixCls?: string;
|
|
37
|
-
collapsible?: boolean;
|
|
38
|
-
collapsed?: boolean;
|
|
39
|
-
defaultCollapsed?: boolean;
|
|
40
|
-
reverseArrow?: boolean;
|
|
41
|
-
onCollapse?: (collapsed: boolean, type: CollapseType) => void;
|
|
42
|
-
zeroWidthTriggerStyle?: CSSProperties;
|
|
43
|
-
trigger?: VNodeChild | JSX.Element;
|
|
44
|
-
width?: number | string;
|
|
45
|
-
collapsedWidth?: number | string;
|
|
46
|
-
breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
47
|
-
theme?: SiderTheme;
|
|
48
|
-
onBreakpoint?: (broken: boolean) => void;
|
|
49
|
-
}
|