@jiangood/open-admin 3.0.3 → 3.0.4
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/package.json +1 -1
- package/src/layouts/admin/index.jsx +10 -0
- package/src/layouts/index.tsx +11 -2
package/package.json
CHANGED
|
@@ -153,6 +153,12 @@ export default class extends React.Component {
|
|
|
153
153
|
PageUtils.open(path, menu.name);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
getActiveTopMenu() {
|
|
157
|
+
const {topMenus, activeTopMenuKey} = this.state;
|
|
158
|
+
if (!activeTopMenuKey || !topMenus) return null;
|
|
159
|
+
return topMenus.find(t => t.key === activeTopMenuKey) || null;
|
|
160
|
+
}
|
|
161
|
+
|
|
156
162
|
renderTopMenu = () => {
|
|
157
163
|
if (this.state.menuLoading) return null;
|
|
158
164
|
const {topMenus, activeTopMenuKey} = this.state;
|
|
@@ -198,6 +204,10 @@ return <Layout className='main-layout'>
|
|
|
198
204
|
<div key={a.code} className='item' style={{cursor: 'pointer', padding: '0 12px', whiteSpace: 'nowrap'}}
|
|
199
205
|
onClick={() => PageUtils.open('/article/' + a.code, a.title)}>{a.title}</div>
|
|
200
206
|
))}
|
|
207
|
+
{this.props.headerExtra?.({
|
|
208
|
+
activeTopMenu: this.getActiveTopMenu(),
|
|
209
|
+
loginInfo: this.props.loginInfo,
|
|
210
|
+
})}
|
|
201
211
|
<HeaderRight/>
|
|
202
212
|
</Header>
|
|
203
213
|
|
package/src/layouts/index.tsx
CHANGED
|
@@ -22,7 +22,16 @@ const configProps = {
|
|
|
22
22
|
theme: getThemeConfig(),
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export interface HeaderExtraContext {
|
|
26
|
+
activeTopMenu: { key: string; label: string } | null;
|
|
27
|
+
loginInfo: { id: string; name: string; account: string };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface LayoutsProps {
|
|
31
|
+
headerExtra?: (context: HeaderExtraContext) => React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class Layouts extends React.Component<LayoutsProps> {
|
|
26
35
|
state = {
|
|
27
36
|
location: history.location,
|
|
28
37
|
siteInfoLoaded: false,
|
|
@@ -119,7 +128,7 @@ export class Layouts extends React.Component {
|
|
|
119
128
|
return (
|
|
120
129
|
<ErrorBoundary minimal>
|
|
121
130
|
<ConfigProvider {...configProps}>
|
|
122
|
-
{showPageFrame ? <PageFrame url={pathname + search}/> : ready ? <AdminLayout/> : (
|
|
131
|
+
{showPageFrame ? <PageFrame url={pathname + search}/> : ready ? <AdminLayout headerExtra={this.props.headerExtra} loginInfo={GlobalData.getLoginInfo()}/> : (
|
|
123
132
|
<PageLoading messages={[
|
|
124
133
|
!siteInfoLoaded && '加载站点信息...',
|
|
125
134
|
!loginChecked && '检查登录中...',
|