Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: customHeader #585

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rude-cups-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alita/plugins': patch
---

feat: customHeader
2 changes: 2 additions & 0 deletions docs/docs/guides/alita-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const mobileLayout = {
navBar,
documentTitle: '默认标题',
titleList,
customHeader
};
```

Expand All @@ -39,6 +40,7 @@ export const mobileLayout = {
| navBar | NavBarProps | 否 | 定义页面头部导航栏 |
| documentTitle | string | 否 | 定义所有页面的默认标题 |
| titleList | TitleListItem[] | 否 | 定义页面的标题 |
| customHeader | 组件 | 否 | 自定义页面的头部 |


### 定义页面底部导航标签栏
Expand Down
1 change: 1 addition & 0 deletions examples/boilerplate/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const mobileLayout = {
navBar,
tabBar,
titleList,
// customHeader:<div>asdasdassaasd</div>
};

export async function getKeepAlive(keepaliva: any[]) {
Expand Down
2 changes: 1 addition & 1 deletion examples/boilerplate/src/layouts/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

const Layout = ({ children }) => {
return <>{children}</>;
return <div>1232312213{children}</div>;
};

export default Layout;
3 changes: 2 additions & 1 deletion packages/plugins/templates/mobile-layout/layout.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const location = useLocation();
// mobile layout runtime config
const runtime = getPluginManager().applyPlugins({ key: 'mobileLayout',type: 'modify', initialValue: {} });
const { titleList, documentTitle, navBar, tabBar, onPageChange } = runtime;
const { titleList, documentTitle, navBar, tabBar, onPageChange, customHeader=null } = runtime;
useEffect(() => {
setPageNavBar(getPageNavBar());
setTabBarList(getTabBarList());
Expand Down Expand Up @@ -465,6 +465,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
};
return (
<AlitaLayout {...layout}>
{customHeader}
{element}
</AlitaLayout>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/templates/mobile-layout/layout5.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const location = useLocation();
// mobile layout runtime config
const runtime = getPluginManager().applyPlugins({ key: 'mobileLayout',type: 'modify', initialValue: {} });
const { titleList, documentTitle, navBar, tabBar, onPageChange } = runtime;
const { titleList, documentTitle, navBar, tabBar, onPageChange, customHeader=null } = runtime;
useEffect(() => {
setPageNavBar(getPageNavBar());
setTabBarList(getTabBarList());
Expand Down Expand Up @@ -451,6 +451,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
};
return (
<AlitaLayout {...layout}>
{customHeader}
{element}
</AlitaLayout>
);
Expand Down
Loading