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 + }) + } + +}