Skip to content

Commit

Permalink
feat(module: page-header): add several parameters to config
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Apr 16, 2018
1 parent 8067b3a commit b641c68
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/abc/page-header/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ subtitle: 页头
order: 150
cols: 1
module: AdProHeaderModule
config: AdPageHeaderConfig
---

页头用来声明页面的主题,包含了用户所关注的最重要的信息,使用户可以快速理解当前页面是什么以及它的功能。
Expand All @@ -13,6 +14,9 @@ module: AdProHeaderModule
参数 | 说明 | 类型 | 默认值
----|------|-----|------
title | 标题名 | `string` | -
home | 首页文本,若指定空表示不显示 | `string` | `首页`
home_link | 首页链接 | `string` | `/`
home_i18n | 首页链接国际化参数 | `string` | -
autoBreadcrumb | 自动生成导航,以当前路由从主菜单中定位 | `boolean` | `true`
breadcrumb | 导航区域 | `TemplateRef<any>` | -
logo | LOGO区域 | `TemplateRef<any>` | -
Expand Down
19 changes: 14 additions & 5 deletions packages/abc/page-header/page-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit {

@Input() title: string;

@Input() home: string;

@Input() home_link: string;

@Input() home_i18n: string;

/**
* 自动生成导航,以当前路由从主菜单中定位
*/
Expand Down Expand Up @@ -73,11 +79,14 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit {
// endregion

constructor(
private cog: AdPageHeaderConfig,
cog: AdPageHeaderConfig,
private renderer: Renderer2,
private route: Router,
@Optional() private menuSrv: MenuService,
@Optional() @Inject(ALAIN_I18N_TOKEN) private i18nSrv: AlainI18NService) {}
@Optional() @Inject(ALAIN_I18N_TOKEN) private i18nSrv: AlainI18NService
) {
Object.assign(this, cog);
}

genBreadcrumb() {
if (this.breadcrumb || !this.autoBreadcrumb || !this.menuSrv) return;
Expand All @@ -91,10 +100,10 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit {
paths.push({ title, link: item.link && [ item.link ] });
});
// add home
if (this.cog.home) {
if (this.home) {
paths.splice(0, 0, {
title: (this.cog.home_i18n && this.i18nSrv && this.i18nSrv.fanyi(this.cog.home_i18n)) || this.cog.home,
link: [ this.cog.home_link ]
title: (this.home_i18n && this.i18nSrv && this.i18nSrv.fanyi(this.home_i18n)) || this.home,
link: [ this.home_link ]
});
}
this.paths = paths;
Expand Down
7 changes: 7 additions & 0 deletions packages/abc/page-header/page-header.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ export class AdPageHeaderConfig {
* 首页链接
*/
home_link?: string = '/';
/**
* 首页链接国际化参数
*/
home_i18n?: string;
/**
* 自动生成导航,以当前路由从主菜单中定位
*/
autoBreadcrumb?: boolean = true;
}

0 comments on commit b641c68

Please sign in to comment.