@yueglobal/ui 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -148
- package/{dist/components → components}/svg-icon/declaration.svg +23 -23
- package/{dist/components → components}/svg-icon/expo.svg +23 -23
- package/{dist/components → components}/svg-icon/home.svg +13 -13
- package/{dist/components → components}/svg-icon/hwc.svg +20 -20
- package/{dist/components → components}/svg-icon/insurance.svg +14 -14
- package/{dist/components → components}/svg-icon/law.svg +23 -23
- package/{dist/components → components}/svg-icon/location.svg +9 -9
- package/{dist/components → components}/svg-icon/selection.svg +16 -16
- package/{dist/components → components}/svg-icon/single-window.svg +8 -8
- package/{dist/components → components}/svg-icon/taxation.svg +13 -13
- package/{dist/components → components}/svg-icon/trade-data.svg +18 -18
- package/{dist/components → components}/svg-icon/training.svg +17 -17
- package/package.json +7 -55
- package/{dist/yue-page-footer → yue-page-footer}/index.less +168 -168
- package/yue-page-header/breadcrumb/index.d.ts +12 -0
- package/yue-page-header/breadcrumb/index.js +130 -0
- package/yue-page-header/breadcrumb/index.less +30 -0
- package/yue-page-header/first-menus/index.d.ts +11 -0
- package/{dist/yue-page-header → yue-page-header}/first-menus/index.js +51 -15
- package/{dist/yue-page-header → yue-page-header}/first-menus/index.less +119 -86
- package/{dist/yue-page-header → yue-page-header}/helper.d.ts +9 -0
- package/{dist/yue-page-header → yue-page-header}/helper.js +106 -36
- package/{dist/yue-page-header → yue-page-header}/index.d.ts +1 -0
- package/{dist/yue-page-header → yue-page-header}/index.js +50 -17
- package/{dist/yue-page-header → yue-page-header}/index.less +44 -43
- package/{dist/yue-page-header → yue-page-header}/right-content/index.less +35 -35
- package/yue-page-header/second-menus/index.d.ts +12 -0
- package/{dist/yue-page-header → yue-page-header}/second-menus/index.js +27 -44
- package/{dist/yue-page-header → yue-page-header}/second-menus/index.less +160 -161
- package/dist/yue-page-header/breadcrumb/index.d.ts +0 -5
- package/dist/yue-page-header/breadcrumb/index.js +0 -82
- package/dist/yue-page-header/first-menus/index.d.ts +0 -7
- package/dist/yue-page-header/second-menus/index.d.ts +0 -8
- /package/{dist/assets → assets}/gw-logo.png +0 -0
- /package/{dist/assets → assets}/hs-logo.png +0 -0
- /package/{dist/assets → assets}/hs-wx.png +0 -0
- /package/{dist/assets → assets}/platform-logo.png +0 -0
- /package/{dist/assets → assets}/yldm-applet.png +0 -0
- /package/{dist/assets → assets}/ylqq-title.png +0 -0
- /package/{dist/assets → assets}/yxh-applet.png +0 -0
- /package/{dist/components → components}/svg-icon/index.d.ts +0 -0
- /package/{dist/components → components}/svg-icon/index.js +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/yue-page-footer → yue-page-footer}/data/privacy-policy.d.ts +0 -0
- /package/{dist/yue-page-footer → yue-page-footer}/data/privacy-policy.js +0 -0
- /package/{dist/yue-page-footer → yue-page-footer}/data/terms-of-service.d.ts +0 -0
- /package/{dist/yue-page-footer → yue-page-footer}/data/terms-of-service.js +0 -0
- /package/{dist/yue-page-footer → yue-page-footer}/index.d.ts +0 -0
- /package/{dist/yue-page-footer → yue-page-footer}/index.js +0 -0
- /package/{dist/yue-page-footer → yue-page-footer}/info-modal/index.d.ts +0 -0
- /package/{dist/yue-page-footer → yue-page-footer}/info-modal/index.js +0 -0
- /package/{dist/yue-page-header → yue-page-header}/right-content/index.d.ts +0 -0
- /package/{dist/yue-page-header → yue-page-header}/right-content/index.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.yue-breadcrumb {
|
|
2
|
+
gap: 12px;
|
|
3
|
+
padding-right: 8px;
|
|
4
|
+
flex-shrink: 0;
|
|
5
|
+
|
|
6
|
+
.ant-breadcrumb ol {
|
|
7
|
+
align-items: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ant-breadcrumb-item,
|
|
11
|
+
.ant-breadcrumb-item > a {
|
|
12
|
+
max-width: 70px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ant-breadcrumb-item {
|
|
16
|
+
.ant-typography {
|
|
17
|
+
font-size: 12px;
|
|
18
|
+
color: #fff;
|
|
19
|
+
line-height: 1.57;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
a {
|
|
23
|
+
height: max-content;
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
background-color: transparent;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -9,15 +9,34 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
11
|
import { ConfigProvider, Menu } from 'antd';
|
|
12
|
-
import React, { memo, useEffect, useState } from 'react';
|
|
13
|
-
import { deepClone, firstMenuList, mainHost } from "../helper";
|
|
12
|
+
import React, { memo, useEffect, useRef, useState } from 'react';
|
|
13
|
+
import { deepClone, firstMenuList, mainHost, setSubMenuPopupStyle } from "../helper";
|
|
14
14
|
import "./index.less";
|
|
15
15
|
var Index = function Index(_ref) {
|
|
16
|
-
var
|
|
17
|
-
var _useState = useState(
|
|
16
|
+
var moduleData = _ref.moduleData;
|
|
17
|
+
var _useState = useState(),
|
|
18
18
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
selectedKeys = _useState2[0],
|
|
20
|
+
setSelectedKeys = _useState2[1];
|
|
21
|
+
var menuRef = useRef(null);
|
|
22
|
+
var _useState3 = useState(deepClone(firstMenuList)),
|
|
23
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
24
|
+
menuList = _useState4[0],
|
|
25
|
+
setMenuList = _useState4[1];
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
if (!(selectedKeys !== null && selectedKeys !== void 0 && selectedKeys.length) && !!(menuList !== null && menuList !== void 0 && menuList.length) && moduleData) {
|
|
28
|
+
var key = moduleData.key;
|
|
29
|
+
if (!key) {
|
|
30
|
+
var _menuList$find;
|
|
31
|
+
key = (_menuList$find = menuList.find(function (m) {
|
|
32
|
+
return m.label === moduleData.title;
|
|
33
|
+
})) === null || _menuList$find === void 0 ? void 0 : _menuList$find.key;
|
|
34
|
+
}
|
|
35
|
+
if (key) {
|
|
36
|
+
setSelectedKeys([key]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, [selectedKeys, menuList, moduleData]);
|
|
21
40
|
|
|
22
41
|
// 获取新闻资讯的类目
|
|
23
42
|
var fetchNewsData = /*#__PURE__*/function () {
|
|
@@ -49,10 +68,8 @@ var Index = function Index(_ref) {
|
|
|
49
68
|
return _context.abrupt("return", result === null || result === void 0 ? void 0 : result.map(function (d) {
|
|
50
69
|
return {
|
|
51
70
|
key: "".concat(mainHost, "/consultation/content-list?classId=").concat(d.id, "&title=").concat(d.className),
|
|
52
|
-
label: d.className
|
|
53
|
-
icon:
|
|
54
|
-
className: "yue-icon-dot"
|
|
55
|
-
})
|
|
71
|
+
label: d.className
|
|
72
|
+
// icon: <i className="yue-icon-dot" />,
|
|
56
73
|
};
|
|
57
74
|
}));
|
|
58
75
|
case 8:
|
|
@@ -85,17 +102,31 @@ var Index = function Index(_ref) {
|
|
|
85
102
|
} catch (e) {}
|
|
86
103
|
}, []);
|
|
87
104
|
var onItem = function onItem(_ref3) {
|
|
88
|
-
var key = _ref3.key
|
|
105
|
+
var key = _ref3.key,
|
|
106
|
+
selectedKeys = _ref3.selectedKeys;
|
|
107
|
+
setSelectedKeys(selectedKeys);
|
|
89
108
|
if (key !== null && key !== void 0 && key.startsWith('http')) {
|
|
90
109
|
window.location.href = key;
|
|
91
110
|
}
|
|
92
111
|
};
|
|
112
|
+
var onSubMenuOpen = function onSubMenuOpen(key) {
|
|
113
|
+
if (!menuRef.current) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
var index = menuList.findIndex(function (m) {
|
|
117
|
+
return m.key === key;
|
|
118
|
+
});
|
|
119
|
+
if (index === -1) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
setSubMenuPopupStyle(menuRef.current, index);
|
|
123
|
+
};
|
|
93
124
|
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
94
125
|
theme: {
|
|
95
126
|
components: {
|
|
96
127
|
Menu: {
|
|
97
128
|
activeBarHeight: 5,
|
|
98
|
-
itemPaddingInline:
|
|
129
|
+
itemPaddingInline: 18,
|
|
99
130
|
itemColor: '#000',
|
|
100
131
|
dropdownWidth: '100%',
|
|
101
132
|
horizontalLineHeight: '30px'
|
|
@@ -103,13 +134,18 @@ var Index = function Index(_ref) {
|
|
|
103
134
|
}
|
|
104
135
|
}
|
|
105
136
|
}, /*#__PURE__*/React.createElement(Menu, {
|
|
137
|
+
ref: menuRef,
|
|
106
138
|
items: menuList,
|
|
107
139
|
mode: "horizontal",
|
|
108
140
|
rootClassName: "yue-page-header-first-menu",
|
|
109
|
-
|
|
141
|
+
onSelect: onItem,
|
|
110
142
|
onOpenChange: function onOpenChange(val) {
|
|
111
|
-
|
|
112
|
-
|
|
143
|
+
if (!!(val !== null && val !== void 0 && val.length)) {
|
|
144
|
+
onSubMenuOpen(val[0]);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
selectedKeys: selectedKeys
|
|
148
|
+
// openKeys={['home']}
|
|
113
149
|
}));
|
|
114
150
|
};
|
|
115
151
|
export default /*#__PURE__*/memo(Index);
|
|
@@ -1,86 +1,119 @@
|
|
|
1
|
-
.yue-page-header-first-menu {
|
|
2
|
-
&.ant-menu-root {
|
|
3
|
-
flex: 1;
|
|
4
|
-
background-color: transparent;
|
|
5
|
-
padding-inline: 30px;
|
|
6
|
-
font-size: 20px;
|
|
7
|
-
color: #000;
|
|
8
|
-
height: 100%;
|
|
9
|
-
width: 100%;
|
|
10
|
-
border-bottom: none;
|
|
11
|
-
|
|
12
|
-
& > li {
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
.yue-page-header-first-menu {
|
|
2
|
+
&.ant-menu-root {
|
|
3
|
+
flex: 1;
|
|
4
|
+
background-color: transparent;
|
|
5
|
+
padding-inline: 30px;
|
|
6
|
+
font-size: 20px;
|
|
7
|
+
color: #000;
|
|
8
|
+
height: 100%;
|
|
9
|
+
width: 100%;
|
|
10
|
+
border-bottom: none;
|
|
11
|
+
|
|
12
|
+
& > li {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
//max-width: 180px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ant-menu-title-content {
|
|
20
|
+
//white-space: wrap;
|
|
21
|
+
//line-height: 22px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ant-menu-submenu-title {
|
|
25
|
+
height: 100%;
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ant-menu-item-selected {
|
|
32
|
+
color: #1a4bff;
|
|
33
|
+
|
|
34
|
+
&::after {
|
|
35
|
+
border-bottom-color: #1a4bff;
|
|
36
|
+
border-radius: 3px 3px 0 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ant-menu-submenu-selected:not(.ant-menu-submenu-active) {
|
|
41
|
+
&::after {
|
|
42
|
+
content: none;
|
|
43
|
+
}
|
|
44
|
+
.ant-menu-submenu-title {
|
|
45
|
+
color: #000;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.ant-menu-submenu-popup {
|
|
51
|
+
left: 0 !important;
|
|
52
|
+
padding: 0;
|
|
53
|
+
font-size: 18px;
|
|
54
|
+
background-color: rgba(4, 41, 131, 80%);
|
|
55
|
+
border-radius: 0;
|
|
56
|
+
width: 100%;
|
|
57
|
+
|
|
58
|
+
.ant-menu-sub {
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
flex-wrap: wrap;
|
|
63
|
+
background-color: transparent;
|
|
64
|
+
border-radius: 0;
|
|
65
|
+
box-shadow: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ant-menu-item {
|
|
69
|
+
width: max-content;
|
|
70
|
+
flex: unset;
|
|
71
|
+
color: #fff;
|
|
72
|
+
margin: 0;
|
|
73
|
+
border-radius: 0;
|
|
74
|
+
height: 60px;
|
|
75
|
+
line-height: 30px;
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
padding-inline: 16px;
|
|
79
|
+
flex-shrink: 0;
|
|
80
|
+
|
|
81
|
+
.anticon {
|
|
82
|
+
font-size: 20px;
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:not(:has(.anticon)) {
|
|
87
|
+
position: relative;
|
|
88
|
+
padding-inline: 25px 18px;
|
|
89
|
+
|
|
90
|
+
&::before {
|
|
91
|
+
content: '';
|
|
92
|
+
position: absolute;
|
|
93
|
+
left: 10px;
|
|
94
|
+
top: 50%;
|
|
95
|
+
transform: translateY(-50%);
|
|
96
|
+
width: 4px;
|
|
97
|
+
height: 4px;
|
|
98
|
+
border-radius: 50%;
|
|
99
|
+
background-color: rgba(255, 255, 255, 85%);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.ant-menu-item-active,
|
|
105
|
+
.ant-menu-item-selected {
|
|
106
|
+
color: #fff !important;
|
|
107
|
+
background: linear-gradient(90deg, #17f1a1, #1a4bff);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.yue-icon-dot {
|
|
111
|
+
min-width: auto !important;
|
|
112
|
+
min-height: auto !important;
|
|
113
|
+
width: 5px;
|
|
114
|
+
height: 5px;
|
|
115
|
+
border-radius: 50%;
|
|
116
|
+
background-color: rgba(255, 255, 255, 80%);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MenuRef } from 'antd';
|
|
1
2
|
import { ReactNode } from 'react';
|
|
2
3
|
export interface YueMenuItem {
|
|
3
4
|
key: string;
|
|
@@ -5,6 +6,8 @@ export interface YueMenuItem {
|
|
|
5
6
|
icon?: ReactNode;
|
|
6
7
|
children?: YueMenuItem[];
|
|
7
8
|
request?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
onTitleClick?: any;
|
|
8
11
|
}
|
|
9
12
|
export interface YueBreadcrumb {
|
|
10
13
|
key?: string;
|
|
@@ -69,3 +72,9 @@ export declare function uniqByPath<T extends {
|
|
|
69
72
|
* @returns 拷贝后的新对象或数组
|
|
70
73
|
*/
|
|
71
74
|
export declare function deepClone<T>(obj: T): T;
|
|
75
|
+
/**
|
|
76
|
+
* 设置子菜单弹出层的样式
|
|
77
|
+
* @param menuRef - 菜单实例
|
|
78
|
+
* @param index - 子菜单索引
|
|
79
|
+
*/
|
|
80
|
+
export declare function setSubMenuPopupStyle(menuRef: MenuRef, index: number): false | undefined;
|
|
@@ -11,12 +11,19 @@ import { ExpoIcon, HomeIcon, HwcIcon, InsuranceIcon, LawIcon, SelectionIcon, Tax
|
|
|
11
11
|
// 主网站域名
|
|
12
12
|
export var mainHost = 'https://www.yueglobal.com';
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* 一级菜单(主菜单)
|
|
14
|
+
/**
|
|
15
|
+
* 一级菜单(主菜单)
|
|
16
16
|
*/
|
|
17
17
|
export var firstMenuList = [{
|
|
18
18
|
key: 'home',
|
|
19
19
|
label: '出海服务',
|
|
20
|
+
className: 'is-home',
|
|
21
|
+
onTitleClick: function onTitleClick(_ref) {
|
|
22
|
+
var key = _ref.key;
|
|
23
|
+
if (key === 'home') {
|
|
24
|
+
window.location.href = mainHost;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
20
27
|
children: [{
|
|
21
28
|
key: mainHost,
|
|
22
29
|
label: '首页',
|
|
@@ -57,21 +64,31 @@ export var firstMenuList = [{
|
|
|
57
64
|
}, {
|
|
58
65
|
key: "".concat(mainHost, "/#9"),
|
|
59
66
|
label: '新闻资讯',
|
|
60
|
-
|
|
67
|
+
children: [],
|
|
68
|
+
request: '/api/gwtrade-plat-front/whitelist/cms-content-class/classTree?siteFlag=uce',
|
|
69
|
+
onTitleClick: function onTitleClick(_ref2) {
|
|
70
|
+
var key = _ref2.key;
|
|
71
|
+
if (key !== null && key !== void 0 && key.startsWith('http')) {
|
|
72
|
+
window.location.href = key;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
61
75
|
}, {
|
|
62
76
|
key: "".concat(mainHost, "/#10"),
|
|
63
77
|
label: '国际市场'
|
|
64
78
|
}, {
|
|
65
79
|
key: "".concat(mainHost, "/#11"),
|
|
66
80
|
label: '省内产业'
|
|
81
|
+
}, {
|
|
82
|
+
key: "".concat(mainHost, "/#12"),
|
|
83
|
+
label: '合作机构'
|
|
67
84
|
}, {
|
|
68
85
|
key: "".concat(mainHost, "/aboutus"),
|
|
69
86
|
label: '关于我们'
|
|
70
87
|
}];
|
|
71
88
|
|
|
72
|
-
/**
|
|
73
|
-
* 将树结构转换为一维数组
|
|
74
|
-
* @param data
|
|
89
|
+
/**
|
|
90
|
+
* 将树结构转换为一维数组
|
|
91
|
+
* @param data
|
|
75
92
|
*/
|
|
76
93
|
export function flattenTreeList(data) {
|
|
77
94
|
// 递归函数,将嵌套的菜单数组转换为一维数组
|
|
@@ -97,10 +114,10 @@ export function flattenTreeList(data) {
|
|
|
97
114
|
return flatten(data);
|
|
98
115
|
}
|
|
99
116
|
|
|
100
|
-
/**
|
|
101
|
-
* 将 firstMenuList 转换为一维数组并根据 key 长度排序
|
|
102
|
-
* @param isSort 是否进行排序
|
|
103
|
-
* @returns 排序后的一维数组
|
|
117
|
+
/**
|
|
118
|
+
* 将 firstMenuList 转换为一维数组并根据 key 长度排序
|
|
119
|
+
* @param isSort 是否进行排序
|
|
120
|
+
* @returns 排序后的一维数组
|
|
104
121
|
*/
|
|
105
122
|
export function flattenMenuList(isSort) {
|
|
106
123
|
// 将嵌套的菜单数组转换为一维数组
|
|
@@ -115,10 +132,10 @@ export function flattenMenuList(isSort) {
|
|
|
115
132
|
return flattenedList;
|
|
116
133
|
}
|
|
117
134
|
|
|
118
|
-
/**
|
|
119
|
-
* 加载script域外资源
|
|
120
|
-
* @param src
|
|
121
|
-
* @param async
|
|
135
|
+
/**
|
|
136
|
+
* 加载script域外资源
|
|
137
|
+
* @param src
|
|
138
|
+
* @param async
|
|
122
139
|
*/
|
|
123
140
|
export function loadScript(src, async) {
|
|
124
141
|
return new Promise(function (resolve, reject) {
|
|
@@ -146,10 +163,10 @@ export function loadScript(src, async) {
|
|
|
146
163
|
});
|
|
147
164
|
}
|
|
148
165
|
|
|
149
|
-
/**
|
|
150
|
-
* 检查页面中是否已存在指定文件名的script资源
|
|
151
|
-
* @param filename 要检查的脚本文件名
|
|
152
|
-
* @returns 如果存在返回true,否则返回false
|
|
166
|
+
/**
|
|
167
|
+
* 检查页面中是否已存在指定文件名的script资源
|
|
168
|
+
* @param filename 要检查的脚本文件名
|
|
169
|
+
* @returns 如果存在返回true,否则返回false
|
|
153
170
|
*/
|
|
154
171
|
export function checkExistScript(filename) {
|
|
155
172
|
// 使用filename参数检查script标签是否存在
|
|
@@ -157,11 +174,11 @@ export function checkExistScript(filename) {
|
|
|
157
174
|
return !!script;
|
|
158
175
|
}
|
|
159
176
|
|
|
160
|
-
/**
|
|
161
|
-
* 检查路径是否匹配,支持路由参数匹配
|
|
162
|
-
* @param routePath 路由定义路径,可能包含参数如 /news/:id/detail
|
|
163
|
-
* @param actualPath 实际访问路径,如 /news/123/detail
|
|
164
|
-
* @returns 是否匹配
|
|
177
|
+
/**
|
|
178
|
+
* 检查路径是否匹配,支持路由参数匹配
|
|
179
|
+
* @param routePath 路由定义路径,可能包含参数如 /news/:id/detail
|
|
180
|
+
* @param actualPath 实际访问路径,如 /news/123/detail
|
|
181
|
+
* @returns 是否匹配
|
|
165
182
|
*/
|
|
166
183
|
function isPathMatch(routePath, actualPath) {
|
|
167
184
|
if (routePath === actualPath) {
|
|
@@ -198,11 +215,11 @@ function isPathMatch(routePath, actualPath) {
|
|
|
198
215
|
}
|
|
199
216
|
return true;
|
|
200
217
|
}
|
|
201
|
-
/**
|
|
202
|
-
* 根据path值获取完整的节点路径数组(支持动态路由参数)
|
|
203
|
-
* @param arr - 包含id, parentId, title, path字段的数组
|
|
204
|
-
* @param path - 要查找的完整path值
|
|
205
|
-
* @returns 完整的节点路径数组,如果未找到则返回空数组
|
|
218
|
+
/**
|
|
219
|
+
* 根据path值获取完整的节点路径数组(支持动态路由参数)
|
|
220
|
+
* @param arr - 包含id, parentId, title, path字段的数组
|
|
221
|
+
* @param path - 要查找的完整path值
|
|
222
|
+
* @returns 完整的节点路径数组,如果未找到则返回空数组
|
|
206
223
|
*/
|
|
207
224
|
export function getFullPathNodesByPath(arr, path) {
|
|
208
225
|
if (!path || path === '/') {
|
|
@@ -260,10 +277,10 @@ export function getFullPathNodesByPath(arr, path) {
|
|
|
260
277
|
return result;
|
|
261
278
|
}
|
|
262
279
|
|
|
263
|
-
/**
|
|
264
|
-
* 根据path值对数组进行去重
|
|
265
|
-
* @param arr - 包含path字段的数组
|
|
266
|
-
* @returns 去重后的数组
|
|
280
|
+
/**
|
|
281
|
+
* 根据path值对数组进行去重
|
|
282
|
+
* @param arr - 包含path字段的数组
|
|
283
|
+
* @returns 去重后的数组
|
|
267
284
|
*/
|
|
268
285
|
export function uniqByPath(arr) {
|
|
269
286
|
var seenPaths = new Set();
|
|
@@ -287,10 +304,10 @@ export function uniqByPath(arr) {
|
|
|
287
304
|
return result;
|
|
288
305
|
}
|
|
289
306
|
|
|
290
|
-
/**
|
|
291
|
-
* 深度拷贝对象或数组
|
|
292
|
-
* @param obj - 要深度拷贝的对象或数组
|
|
293
|
-
* @returns 拷贝后的新对象或数组
|
|
307
|
+
/**
|
|
308
|
+
* 深度拷贝对象或数组
|
|
309
|
+
* @param obj - 要深度拷贝的对象或数组
|
|
310
|
+
* @returns 拷贝后的新对象或数组
|
|
294
311
|
*/
|
|
295
312
|
export function deepClone(obj) {
|
|
296
313
|
// 处理 null 和 undefined
|
|
@@ -323,4 +340,57 @@ export function deepClone(obj) {
|
|
|
323
340
|
}
|
|
324
341
|
}
|
|
325
342
|
return clonedObj;
|
|
343
|
+
}
|
|
344
|
+
function _setPopupStyle(uuid, left) {
|
|
345
|
+
var popupUL = window.document.getElementById(uuid);
|
|
346
|
+
if (popupUL) {
|
|
347
|
+
var contentWidth = 0;
|
|
348
|
+
var childLength = popupUL.children.length;
|
|
349
|
+
for (var i = 0; i < childLength; i++) {
|
|
350
|
+
var li = popupUL.children[i];
|
|
351
|
+
contentWidth += li.offsetWidth || 120; // 有时会读取不到值,默认给120px
|
|
352
|
+
}
|
|
353
|
+
var bodyWidth = window.document.body.clientWidth;
|
|
354
|
+
if (left + contentWidth > bodyWidth || contentWidth === 0 && childLength > 4) {
|
|
355
|
+
popupUL.style.paddingLeft = "unset";
|
|
356
|
+
popupUL.style.justifyContent = 'center';
|
|
357
|
+
} else {
|
|
358
|
+
popupUL.style.paddingLeft = "".concat(left - 8, "px");
|
|
359
|
+
popupUL.style.justifyContent = 'unset';
|
|
360
|
+
}
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* 设置子菜单弹出层的样式
|
|
368
|
+
* @param menuRef - 菜单实例
|
|
369
|
+
* @param index - 子菜单索引
|
|
370
|
+
*/
|
|
371
|
+
export function setSubMenuPopupStyle(menuRef, index) {
|
|
372
|
+
var _menuRef$menu;
|
|
373
|
+
var li = menuRef === null || menuRef === void 0 || (_menuRef$menu = menuRef.menu) === null || _menuRef$menu === void 0 || (_menuRef$menu = _menuRef$menu.list) === null || _menuRef$menu === void 0 || (_menuRef$menu = _menuRef$menu.children) === null || _menuRef$menu === void 0 ? void 0 : _menuRef$menu.item(index);
|
|
374
|
+
if (!li) {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
var uuid = li.getAttribute('aria-controls');
|
|
378
|
+
if (!uuid && li.classList.contains('ant-menu-submenu')) {
|
|
379
|
+
var title = li.querySelector('.ant-menu-submenu-title');
|
|
380
|
+
uuid = title === null || title === void 0 ? void 0 : title.getAttribute('aria-controls');
|
|
381
|
+
}
|
|
382
|
+
if (!uuid) {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
var _li$getBoundingClient = li.getBoundingClientRect(),
|
|
386
|
+
left = _li$getBoundingClient.left;
|
|
387
|
+
setTimeout(function () {
|
|
388
|
+
var success = _setPopupStyle(uuid, left);
|
|
389
|
+
if (!success) {
|
|
390
|
+
setTimeout(function () {
|
|
391
|
+
// 重新执行一次
|
|
392
|
+
_setPopupStyle(uuid, left);
|
|
393
|
+
}, 100);
|
|
394
|
+
}
|
|
395
|
+
}, 100, uuid, left);
|
|
326
396
|
}
|
|
@@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { YueBreadcrumb, YueMenuItem } from './helper';
|
|
3
3
|
import './index.less';
|
|
4
4
|
export interface YuePageHeaderProps {
|
|
5
|
+
activeLabel?: string;
|
|
5
6
|
width?: string | number;
|
|
6
7
|
backgroundColor?: string;
|
|
7
8
|
menuItems?: YueMenuItem[];
|