From bd5d10c8b7c74fadfa1c1f9f33b636a0b6b0cbbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=B5=B7?= Date: Sat, 25 Apr 2020 17:29:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E7=9A=84he?= =?UTF-8?q?ader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin-header/admin-header.component.html | 46 +++++++++++++++++++ .../admin-header/admin-header.component.less | 44 ++++++++++++++++++ .../admin-header.component.spec.ts | 25 ++++++++++ .../admin-header/admin-header.component.ts | 27 +++++++++++ 4 files changed, 142 insertions(+) create mode 100644 index/src/app/components/admin-header/admin-header.component.html create mode 100644 index/src/app/components/admin-header/admin-header.component.less create mode 100644 index/src/app/components/admin-header/admin-header.component.spec.ts create mode 100644 index/src/app/components/admin-header/admin-header.component.ts diff --git a/index/src/app/components/admin-header/admin-header.component.html b/index/src/app/components/admin-header/admin-header.component.html new file mode 100644 index 0000000..0fb20c9 --- /dev/null +++ b/index/src/app/components/admin-header/admin-header.component.html @@ -0,0 +1,46 @@ +
+ +
+ +
+
+
+ 小海博客 + 记录学习成长历程 +
+ + +
+ + + + + +
+ + +
+ + + + + + + + + + + + +
+ +
diff --git a/index/src/app/components/admin-header/admin-header.component.less b/index/src/app/components/admin-header/admin-header.component.less new file mode 100644 index 0000000..d6794f8 --- /dev/null +++ b/index/src/app/components/admin-header/admin-header.component.less @@ -0,0 +1,44 @@ +header { + height: 70px; + background-color: #ffffff; + opacity: 0.8; + position: fixed; + z-index: 1; + width: 100%; + min-width: 350px; + padding-top: 10px; +} + +header img { + width: 40px; + height: 40px; + border-radius: 50%; + margin: 5px 5px 5px 30px; + float: left; +} + +a { + color: black; +} + +#landr, #loged { + position: absolute; + right: 20px; + top: 20px; +} + + +#blogTitle, #desc { + display: block; + margin-left: 15px; +} + +#blogTitle { + font-weight: bold; + font-size: 20px; +} + +#desc { + font-size: 10px; +} + diff --git a/index/src/app/components/admin-header/admin-header.component.spec.ts b/index/src/app/components/admin-header/admin-header.component.spec.ts new file mode 100644 index 0000000..33284cb --- /dev/null +++ b/index/src/app/components/admin-header/admin-header.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AdminHeaderComponent } from './admin-header.component'; + +describe('AdminHeaderComponent', () => { + let component: AdminHeaderComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AdminHeaderComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AdminHeaderComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/index/src/app/components/admin-header/admin-header.component.ts b/index/src/app/components/admin-header/admin-header.component.ts new file mode 100644 index 0000000..e002d25 --- /dev/null +++ b/index/src/app/components/admin-header/admin-header.component.ts @@ -0,0 +1,27 @@ +import {Component, OnInit} from '@angular/core'; +import {UserService} from '../../services/user.service'; +import {User} from '../../class/User'; + +@Component({ + selector: 'c-admin-header', + templateUrl: './admin-header.component.html', + styleUrls: ['./admin-header.component.less'] +}) +export class AdminHeaderComponent implements OnInit { + + constructor(private userService: UserService) { + } + + user: User + + logout = () => this.userService.logout(); + + ngOnInit(): void { + this.userService.watchUserInfo({ + next: data => this.user = data.result, + error: err => this.user = null, + complete: null + }) + } + +}