@yueglobal/ui 1.0.1 → 1.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/README.md +149 -146
- package/components/svg-icon/computer.svg +9 -0
- package/components/svg-icon/index.d.ts +1 -0
- package/components/svg-icon/index.js +6 -0
- package/package.json +4 -4
- package/yue-page-header/breadcrumb/index.d.ts +9 -2
- package/yue-page-header/breadcrumb/index.js +65 -19
- package/yue-page-header/breadcrumb/index.less +30 -0
- package/yue-page-header/first-menus/index.d.ts +0 -1
- package/yue-page-header/first-menus/index.js +24 -11
- package/yue-page-header/first-menus/index.less +25 -0
- package/yue-page-header/helper.d.ts +8 -0
- package/yue-page-header/helper.js +67 -1
- package/yue-page-header/index.d.ts +2 -0
- package/yue-page-header/index.js +28 -30
- package/yue-page-header/second-menus/index.d.ts +0 -1
- package/yue-page-header/second-menus/index.js +41 -12
- package/yue-page-header/second-menus/index.less +227 -161
package/README.md
CHANGED
|
@@ -1,146 +1,149 @@
|
|
|
1
|
-
# @yueglobal/ui
|
|
2
|
-
|
|
3
|
-
粤链全球 - React 组件库
|
|
4
|
-
|
|
5
|
-
如需`vue`版本,请前往 [@yueglobal/vue-ui](https://www.npmjs.com/package/@yueglobal/vue-ui)
|
|
6
|
-
|
|
7
|
-
## 安装使用
|
|
8
|
-
|
|
9
|
-
```shell
|
|
10
|
-
yarn add @yueglobal/ui
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import {
|
|
15
|
-
// 页面头部组件
|
|
16
|
-
YuePageHeader,
|
|
17
|
-
// 页面底部组件
|
|
18
|
-
YuePageFooter,
|
|
19
|
-
} from '@yueglobal/ui';
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## YuePageHeader
|
|
23
|
-
|
|
24
|
-
页面头部组件,包含一级和二级导航菜单、面包屑、以及登录/用户信息等功能。
|
|
25
|
-
|
|
26
|
-
### 属性
|
|
27
|
-
|
|
28
|
-
| 属性 | 说明 | 类型 | 默认值
|
|
29
|
-
| ----------------- | ----------------------------------- | ------------------------------------------- |
|
|
30
|
-
| `width` | 内容宽度 | `string` \| `number` | `80%`
|
|
31
|
-
| `backgroundColor` | 头部背景色 | `string` | `#fff`
|
|
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
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
# @yueglobal/ui
|
|
2
|
+
|
|
3
|
+
粤链全球 - React 组件库
|
|
4
|
+
|
|
5
|
+
如需`vue`版本,请前往 [@yueglobal/vue-ui](https://www.npmjs.com/package/@yueglobal/vue-ui)
|
|
6
|
+
|
|
7
|
+
## 安装使用
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
yarn add @yueglobal/ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {
|
|
15
|
+
// 页面头部组件
|
|
16
|
+
YuePageHeader,
|
|
17
|
+
// 页面底部组件
|
|
18
|
+
YuePageFooter,
|
|
19
|
+
} from '@yueglobal/ui';
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## YuePageHeader
|
|
23
|
+
|
|
24
|
+
页面头部组件,包含一级和二级导航菜单、面包屑、以及登录/用户信息等功能。
|
|
25
|
+
|
|
26
|
+
### 属性
|
|
27
|
+
|
|
28
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
29
|
+
| ----------------- | ----------------------------------- | ------------------------------------------- | ---------- |
|
|
30
|
+
| `width` | 内容宽度 | `string` \| `number` | `80%` |
|
|
31
|
+
| `backgroundColor` | 头部背景色 | `string` | `#fff` |
|
|
32
|
+
| `activeLabel` | 当前选中的一级菜单项的标题 | `string` | |
|
|
33
|
+
| `rightContent` | 顶部右侧的登录/用户信息按钮 | `ReactNode` | |
|
|
34
|
+
| `onLocaleChange` | 切换语言时的回调事件 | `({locale: string}) => void` | |
|
|
35
|
+
| | `以下二级导航栏的配置` | | |
|
|
36
|
+
| `menuItems` | 各业务系统的菜单 | `YueMenuItem`[] | |
|
|
37
|
+
| `pageTitle` | 缺值时从一级菜单匹配值 | `string` | |
|
|
38
|
+
| `pageIcon` | 页面图标 | `ReactNode` | |
|
|
39
|
+
| `breadcrumbs` | 自定义面包屑数据 | `YueBreadcrumb`[] | |
|
|
40
|
+
| `routes` | 路由数据,用于自动生成面包屑 | any | |
|
|
41
|
+
| `pathname` | 当前的路由 | `string` | |
|
|
42
|
+
| `subMenuLayout` | 二级导航栏的菜单弹出层布局 | `vertical` \| `horizontal` | `vertical` |
|
|
43
|
+
| `onRouteChange` | 点击菜单/面包屑时触发的路由切换事件 | `({ key: string; label?: string }) => void` | |
|
|
44
|
+
|
|
45
|
+
- 业务子系统:`pageTitle`或`pageIcon`缺省时会根据`url`自动从一级菜单匹配值
|
|
46
|
+
|
|
47
|
+
- 面包屑:若`breadcrumbs`缺省,则会根据`routes`、`pathname`自动生成面包屑的数据
|
|
48
|
+
|
|
49
|
+
- `routes`是`umijs`的路由列表,需按如下方式取值:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { useAppData } from '@umijs/max';
|
|
53
|
+
// .......
|
|
54
|
+
const { routes } = useAppData();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### YueMenuItem
|
|
58
|
+
|
|
59
|
+
| 属性 | 说明 | 类型 | 备注 |
|
|
60
|
+
| ---------- | ---------- | --------------- | ------------------------------ |
|
|
61
|
+
| `key` | 唯一标识 | `string` | `必填`,可传路由地址如 `/home` |
|
|
62
|
+
| `label` | 菜单项文案 | `string` | `必填` |
|
|
63
|
+
| `children` | 子菜单项 | `YueMenuItem`[] | |
|
|
64
|
+
|
|
65
|
+
### YueBreadcrumb
|
|
66
|
+
|
|
67
|
+
| 属性 | 说明 | 类型 | 备注 |
|
|
68
|
+
| ------- | ---------------------- | -------- | ---------------------- |
|
|
69
|
+
| `key` | 唯一标识,用于路由跳转 | `string` | 可传路由地址如 `/home` |
|
|
70
|
+
| `label` | 面包屑项文案 | `string` | |
|
|
71
|
+
|
|
72
|
+
### 使用示例
|
|
73
|
+
|
|
74
|
+
```tsx | pure
|
|
75
|
+
import React from 'react';
|
|
76
|
+
import { YuePageHeader } from '@yueglobal/ui';
|
|
77
|
+
import { useAppData, useLocation, useModel, history } from '@umijs/max';
|
|
78
|
+
|
|
79
|
+
const Index = () => {
|
|
80
|
+
const { routes } = useAppData();
|
|
81
|
+
const { pathname } = useLocation();
|
|
82
|
+
const { initialState } = useModel('@@initialState');
|
|
83
|
+
|
|
84
|
+
const menuItems = [
|
|
85
|
+
{ key: '/home', label: '首页' },
|
|
86
|
+
{
|
|
87
|
+
key: '/exhibition',
|
|
88
|
+
label: '展会',
|
|
89
|
+
children: [
|
|
90
|
+
{ key: '/exhibition/international', label: '国际展会' },
|
|
91
|
+
{ key: '/exhibition/domestic', label: '国内展会' },
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{ key: '/business', label: '商务' },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const onRouteChange = (item: { key: string; label?: string }) => {
|
|
98
|
+
console.log('点击的菜单key: ', item.key);
|
|
99
|
+
// 在这里处理路由跳转逻辑, 比如
|
|
100
|
+
if (item.key.startsWith('/')) {
|
|
101
|
+
history.push(item.key);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const onLocaleChange = ({ locale }: { locale: string }) => {
|
|
106
|
+
console.log('切换语言为:', locale);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<YuePageHeader
|
|
111
|
+
width={1440}
|
|
112
|
+
pageTitle="会展服务"
|
|
113
|
+
menuItems={menuItems}
|
|
114
|
+
pathname={pathname}
|
|
115
|
+
routes={routes}
|
|
116
|
+
rightContent={
|
|
117
|
+
!!initialState?.isLogin ? <div>用户名</div> : <div>登录</div>
|
|
118
|
+
}
|
|
119
|
+
onRouteChange={onRouteChange}
|
|
120
|
+
onLocaleChange={onLocaleChange}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default Index;
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## YuePageFooter
|
|
129
|
+
|
|
130
|
+
页面底部组件,显示版权信息、联系方式和相关链接。
|
|
131
|
+
|
|
132
|
+
### 属性
|
|
133
|
+
|
|
134
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
135
|
+
| ------- | -------- | -------------------- | ------ |
|
|
136
|
+
| `width` | 内容宽度 | `string` \| `number` | `80%` |
|
|
137
|
+
|
|
138
|
+
### 使用示例
|
|
139
|
+
|
|
140
|
+
```tsx | pure
|
|
141
|
+
import React from 'react';
|
|
142
|
+
import { YuePageFooter } from '@yueglobal/ui';
|
|
143
|
+
|
|
144
|
+
const Index = () => {
|
|
145
|
+
return <YuePageFooter width={1440} />;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export default Index;
|
|
149
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
width="1em" height="1em">
|
|
3
|
+
<path
|
|
4
|
+
d="M890.56 110.69666665H133.33333333c-35.2 0-64.10666667 28.8-64.10666666 64.10666668v518.4c0 35.2 28.8 64.10666667 64.10666666 64.10666667h346.56s0.10666667 0 0.10666667 0.10666666v139.84s0 0.10666667-0.10666667 0.10666666H170.66666667c-17.49333333 0-32.21333333 13.65333333-32.74666667 31.14666668-0.42666667 18.02666667 14.08 32.85333333 32 32.85333333H853.33333333c17.49333333 0 32.21333333-13.65333333 32.74666667-31.14666667 0.42666667-18.02666667-14.08-32.85333333-32-32.85333334H544s-0.10666667 0-0.10666667-0.10666666V757.20333333s0-0.10666667 0.10666667-0.10666667h346.56c35.2 0 64.10666667-28.8 64.10666667-64.10666666v-518.4c0-35.09333333-28.90666667-63.89333333-64.10666667-63.89333335z m0.10666667 582.29333335l-0.21333334 0.21333333H133.44l-0.21333333-0.21333333V174.91l0.21333333-0.21333335h757.01333333l0.21333334 0.21333335v518.08z"
|
|
5
|
+
></path>
|
|
6
|
+
<path
|
|
7
|
+
d="M266.45333333 251.49666666h-33.70666666c-11.73333333 0-21.33333333 9.6-21.33333334 21.33333334v33.70666665c0 11.73333333 9.6 21.33333333 21.33333334 21.33333335h33.70666666c11.73333333 0 21.33333333-9.6 21.33333334-21.33333335v-33.70666665c0-11.73333333-9.6-21.33333333-21.33333334-21.33333334zM363.52 251.49666666h-33.70666667c-11.73333333 0-21.33333333 9.6-21.33333333 21.33333334v33.70666665c0 11.73333333 9.6 21.33333333 21.33333333 21.33333335h33.70666667c11.73333333 0 21.33333333-9.6 21.33333333-21.33333335v-33.70666665c0-11.73333333-9.6-21.33333333-21.33333333-21.33333334zM460.69333333 251.49666666h-33.70666666c-11.73333333 0-21.33333333 9.6-21.33333334 21.33333334v33.70666665c0 11.73333333 9.6 21.33333333 21.33333334 21.33333335h33.70666666c11.73333333 0 21.33333333-9.6 21.33333334-21.33333335v-33.70666665c0-11.73333333-9.6-21.33333333-21.33333334-21.33333334z"
|
|
8
|
+
></path>
|
|
9
|
+
</svg>
|
|
@@ -6,6 +6,7 @@ export interface SvgIconProps {
|
|
|
6
6
|
onClick?: (e?: any) => void;
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
}
|
|
9
|
+
export declare const ComputerIcon: FC<SvgIconProps>;
|
|
9
10
|
export declare const DeclarationIcon: FC<SvgIconProps>;
|
|
10
11
|
export declare const ExpoIcon: FC<SvgIconProps>;
|
|
11
12
|
export declare const HwcIcon: FC<SvgIconProps>;
|
|
@@ -9,6 +9,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
9
9
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
10
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
11
|
import React, { memo } from 'react';
|
|
12
|
+
import { ReactComponent as Computer } from "./computer.svg";
|
|
12
13
|
import { ReactComponent as Declaration } from "./declaration.svg";
|
|
13
14
|
import { ReactComponent as Expo } from "./expo.svg";
|
|
14
15
|
import { ReactComponent as Home } from "./home.svg";
|
|
@@ -34,6 +35,11 @@ var SvgIcon = /*#__PURE__*/memo(function (_ref) {
|
|
|
34
35
|
}), children);
|
|
35
36
|
});
|
|
36
37
|
|
|
38
|
+
// 电脑(默认图标)
|
|
39
|
+
export var ComputerIcon = /*#__PURE__*/memo(function (props) {
|
|
40
|
+
return /*#__PURE__*/React.createElement(SvgIcon, props, /*#__PURE__*/React.createElement(Computer, null));
|
|
41
|
+
});
|
|
42
|
+
|
|
37
43
|
// 通关申报
|
|
38
44
|
export var DeclarationIcon = /*#__PURE__*/memo(function (props) {
|
|
39
45
|
return /*#__PURE__*/React.createElement(SvgIcon, props, /*#__PURE__*/React.createElement(Declaration, null));
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yueglobal/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "粤链全球 - react组件库",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"typings": "index.d.ts",
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"react": "^18.0.0"
|
|
10
|
+
},
|
|
8
11
|
"peerDependencies": {
|
|
9
12
|
"antd": ">=4.23.0 || >=5.0.0",
|
|
10
13
|
"react": ">=16.9.0",
|
|
11
14
|
"react-dom": ">=16.9.0"
|
|
12
15
|
},
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
"react": "^18.0.0"
|
|
15
|
-
},
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { YuePageHeaderProps } from '../index';
|
|
3
|
-
|
|
3
|
+
import './index.less';
|
|
4
|
+
type Props = Pick<YuePageHeaderProps, 'breadcrumbs' | 'routes' | 'pathname' | 'onRouteChange'> & {
|
|
5
|
+
moduleData: {
|
|
6
|
+
title?: string;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
key?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
4
11
|
declare const _default: React.NamedExoticComponent<Props>;
|
|
5
12
|
export default _default;
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { Breadcrumb } from 'antd';
|
|
1
|
+
import { Breadcrumb, Typography } from 'antd';
|
|
2
2
|
import React, { memo, useMemo } from 'react';
|
|
3
3
|
import { LocationIcon } from "../../components/svg-icon";
|
|
4
|
-
import { getFullPathNodesByPath, uniqByPath } from "../helper";
|
|
4
|
+
import { getFullPathNodesByPath, mainHost, uniqByPath } from "../helper";
|
|
5
|
+
import "./index.less";
|
|
6
|
+
var Text = Typography.Text;
|
|
5
7
|
var Index = function Index(_ref) {
|
|
6
8
|
var breadcrumbs = _ref.breadcrumbs,
|
|
7
9
|
routes = _ref.routes,
|
|
8
10
|
pathname = _ref.pathname,
|
|
9
|
-
onRouteChange = _ref.onRouteChange
|
|
11
|
+
onRouteChange = _ref.onRouteChange,
|
|
12
|
+
moduleData = _ref.moduleData;
|
|
10
13
|
var breadcrumbItems = useMemo(function () {
|
|
11
14
|
if (breadcrumbs) {
|
|
12
15
|
return breadcrumbs.map(function (item) {
|
|
13
|
-
var _item$key;
|
|
16
|
+
var _item$key, _item$key2;
|
|
14
17
|
return {
|
|
15
|
-
path: (_item$key = item.key) !== null && _item$key !== void 0 && _item$key.startsWith('/') ? item.key : undefined,
|
|
18
|
+
path: (_item$key = item.key) !== null && _item$key !== void 0 && _item$key.startsWith('/') || (_item$key2 = item.key) !== null && _item$key2 !== void 0 && _item$key2.startsWith('http') ? item.key : undefined,
|
|
16
19
|
title: item.label
|
|
17
20
|
};
|
|
18
21
|
});
|
|
@@ -23,14 +26,25 @@ var Index = function Index(_ref) {
|
|
|
23
26
|
return !d.redirect && d.access !== false && !d.isLayout;
|
|
24
27
|
});
|
|
25
28
|
var paths = getFullPathNodesByPath(routeList, pathname);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
// 首页路由坐标
|
|
30
|
+
var homeIndex = paths.findIndex(function (p) {
|
|
31
|
+
var _p$title, _p$name;
|
|
32
|
+
return ((_p$title = p.title) === null || _p$title === void 0 ? void 0 : _p$title.startsWith('首页')) || ((_p$name = p.name) === null || _p$name === void 0 ? void 0 : _p$name.startsWith('首页')) || p.path === '/' || p.path === '/home';
|
|
33
|
+
});
|
|
34
|
+
if (homeIndex === -1) {
|
|
35
|
+
// 没有子项目首页的路由,添加一个
|
|
29
36
|
paths.unshift({
|
|
30
|
-
title: '
|
|
37
|
+
title: (moduleData === null || moduleData === void 0 ? void 0 : moduleData.title) || '应用首页',
|
|
31
38
|
path: '/'
|
|
32
39
|
});
|
|
40
|
+
} else if (moduleData !== null && moduleData !== void 0 && moduleData.title) {
|
|
41
|
+
// 对首页重命名
|
|
42
|
+
paths[homeIndex].title = moduleData.title;
|
|
33
43
|
}
|
|
44
|
+
paths.unshift({
|
|
45
|
+
title: '首页',
|
|
46
|
+
path: mainHost
|
|
47
|
+
});
|
|
34
48
|
if ((_paths = paths) !== null && _paths !== void 0 && _paths.length) {
|
|
35
49
|
paths = uniqByPath(paths);
|
|
36
50
|
if (paths.length > 1) {
|
|
@@ -46,28 +60,60 @@ var Index = function Index(_ref) {
|
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
return undefined;
|
|
49
|
-
}, [breadcrumbs, routes, pathname]);
|
|
63
|
+
}, [breadcrumbs, routes, pathname, moduleData]);
|
|
50
64
|
var itemRender = function itemRender(currentRoute, _, items, paths) {
|
|
51
|
-
var _items;
|
|
65
|
+
var _paths$, _newPaths, _items;
|
|
66
|
+
var newPaths = paths;
|
|
67
|
+
var firstPath = '';
|
|
68
|
+
if (paths !== null && paths !== void 0 && (_paths$ = paths[0]) !== null && _paths$ !== void 0 && _paths$.startsWith('http')) {
|
|
69
|
+
newPaths = paths.slice(1);
|
|
70
|
+
firstPath = paths[0];
|
|
71
|
+
}
|
|
72
|
+
var title = currentRoute.title;
|
|
73
|
+
var tooltip = {
|
|
74
|
+
title: title,
|
|
75
|
+
placement: 'bottomRight'
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// 是第一个(平台首页)
|
|
79
|
+
if (firstPath && !((_newPaths = newPaths) !== null && _newPaths !== void 0 && _newPaths.length)) {
|
|
80
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
81
|
+
href: firstPath
|
|
82
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
83
|
+
ellipsis: {
|
|
84
|
+
tooltip: tooltip
|
|
85
|
+
}
|
|
86
|
+
}, title));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 其他是模块内部路由跳转
|
|
52
90
|
var isLast = (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path) === ((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.path);
|
|
53
|
-
var
|
|
54
|
-
if (!
|
|
55
|
-
|
|
91
|
+
var currentPath = newPaths[newPaths.length - 1];
|
|
92
|
+
if (!currentPath.startsWith('/')) {
|
|
93
|
+
currentPath = '/' + currentPath;
|
|
56
94
|
}
|
|
57
|
-
return isLast ? /*#__PURE__*/React.createElement(
|
|
95
|
+
return isLast ? /*#__PURE__*/React.createElement(Text, {
|
|
96
|
+
ellipsis: {
|
|
97
|
+
tooltip: tooltip
|
|
98
|
+
}
|
|
99
|
+
}, title) : /*#__PURE__*/React.createElement("a", {
|
|
58
100
|
onClick: function onClick() {
|
|
59
101
|
onRouteChange === null || onRouteChange === void 0 || onRouteChange({
|
|
60
|
-
key:
|
|
61
|
-
label:
|
|
102
|
+
key: currentPath,
|
|
103
|
+
label: title
|
|
62
104
|
});
|
|
63
105
|
}
|
|
64
|
-
},
|
|
106
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
107
|
+
ellipsis: {
|
|
108
|
+
tooltip: tooltip
|
|
109
|
+
}
|
|
110
|
+
}, title));
|
|
65
111
|
};
|
|
66
112
|
if (!(breadcrumbItems !== null && breadcrumbItems !== void 0 && breadcrumbItems.length)) {
|
|
67
113
|
return null;
|
|
68
114
|
}
|
|
69
115
|
return /*#__PURE__*/React.createElement("div", {
|
|
70
|
-
className: "yue-flex breadcrumb"
|
|
116
|
+
className: "yue-flex yue-breadcrumb"
|
|
71
117
|
}, /*#__PURE__*/React.createElement(LocationIcon, {
|
|
72
118
|
style: {
|
|
73
119
|
fontSize: 16
|
|
@@ -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,22 +9,22 @@ 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
|
-
moduleData = _ref.moduleData;
|
|
16
|
+
var moduleData = _ref.moduleData;
|
|
18
17
|
var _useState = useState(),
|
|
19
18
|
_useState2 = _slicedToArray(_useState, 2),
|
|
20
19
|
selectedKeys = _useState2[0],
|
|
21
20
|
setSelectedKeys = _useState2[1];
|
|
21
|
+
var menuRef = useRef(null);
|
|
22
22
|
var _useState3 = useState(deepClone(firstMenuList)),
|
|
23
23
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
24
24
|
menuList = _useState4[0],
|
|
25
25
|
setMenuList = _useState4[1];
|
|
26
26
|
useEffect(function () {
|
|
27
|
-
if (
|
|
27
|
+
if (!!(menuList !== null && menuList !== void 0 && menuList.length) && moduleData) {
|
|
28
28
|
var key = moduleData.key;
|
|
29
29
|
if (!key) {
|
|
30
30
|
var _menuList$find;
|
|
@@ -36,7 +36,7 @@ var Index = function Index(_ref) {
|
|
|
36
36
|
setSelectedKeys([key]);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
}, [
|
|
39
|
+
}, [menuList, moduleData]);
|
|
40
40
|
|
|
41
41
|
// 获取新闻资讯的类目
|
|
42
42
|
var fetchNewsData = /*#__PURE__*/function () {
|
|
@@ -68,10 +68,7 @@ var Index = function Index(_ref) {
|
|
|
68
68
|
return _context.abrupt("return", result === null || result === void 0 ? void 0 : result.map(function (d) {
|
|
69
69
|
return {
|
|
70
70
|
key: "".concat(mainHost, "/consultation/content-list?classId=").concat(d.id, "&title=").concat(d.className),
|
|
71
|
-
label: d.className
|
|
72
|
-
icon: /*#__PURE__*/React.createElement("i", {
|
|
73
|
-
className: "yue-icon-dot"
|
|
74
|
-
})
|
|
71
|
+
label: d.className
|
|
75
72
|
};
|
|
76
73
|
}));
|
|
77
74
|
case 8:
|
|
@@ -111,6 +108,18 @@ var Index = function Index(_ref) {
|
|
|
111
108
|
window.location.href = key;
|
|
112
109
|
}
|
|
113
110
|
};
|
|
111
|
+
var onSubMenuOpen = function onSubMenuOpen(key) {
|
|
112
|
+
if (!menuRef.current) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
var index = menuList.findIndex(function (m) {
|
|
116
|
+
return m.key === key;
|
|
117
|
+
});
|
|
118
|
+
if (index === -1) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
setSubMenuPopupStyle(menuRef.current, index);
|
|
122
|
+
};
|
|
114
123
|
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
115
124
|
theme: {
|
|
116
125
|
components: {
|
|
@@ -124,14 +133,18 @@ var Index = function Index(_ref) {
|
|
|
124
133
|
}
|
|
125
134
|
}
|
|
126
135
|
}, /*#__PURE__*/React.createElement(Menu, {
|
|
136
|
+
ref: menuRef,
|
|
127
137
|
items: menuList,
|
|
128
138
|
mode: "horizontal",
|
|
129
139
|
rootClassName: "yue-page-header-first-menu",
|
|
130
140
|
onSelect: onItem,
|
|
131
141
|
onOpenChange: function onOpenChange(val) {
|
|
132
|
-
|
|
142
|
+
if (!!(val !== null && val !== void 0 && val.length)) {
|
|
143
|
+
onSubMenuOpen(val[0]);
|
|
144
|
+
}
|
|
133
145
|
},
|
|
134
146
|
selectedKeys: selectedKeys
|
|
147
|
+
// openKeys={['home']}
|
|
135
148
|
}));
|
|
136
149
|
};
|
|
137
150
|
export default /*#__PURE__*/memo(Index);
|