Browse Source

[完善]云盘系统 header 完善

master
陈鹏飞 5 years ago
parent
commit
a3b5d71855
  1. 12
      src/app/is-login.service.ts
  2. 35
      src/app/navigation/navigation.component.html
  3. 83
      src/app/tabbar/tabbar.component.html
  4. 39
      src/app/tabbar/tabbar.component.scss
  5. 99
      src/app/tabbar/tabbar.component.ts
  6. 20
      src/app/ui/changeuserdata/changeuserdata.component.html
  7. 0
      src/app/ui/changeuserdata/changeuserdata.component.scss
  8. 25
      src/app/ui/changeuserdata/changeuserdata.component.spec.ts
  9. 22
      src/app/ui/changeuserdata/changeuserdata.component.ts
  10. 29
      src/app/ui/login/login.component.html
  11. 45
      src/app/ui/login/login.component.scss
  12. 25
      src/app/ui/login/login.component.spec.ts
  13. 24
      src/app/ui/login/login.component.ts
  14. 4
      src/app/ui/ui.module.ts

12
src/app/is-login.service.ts

@ -0,0 +1,12 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class IsLoginService {
constructor() { }
isLogin:boolean = false; //登录状态
}

35
src/app/navigation/navigation.component.html

@ -1,24 +1,23 @@
<app-tabbar (toggleDarkTheme)="switchTheme($event)" (defaulttheme)="defaulttheme()" (redtheme)="redtheme()"></app-tabbar>
<mat-sidenav-container class="example-container" autosize [class.myapp-dark-theme]="darktheme">
<mat-sidenav #drawer class="example-sidenav" mode="side" opened="true" color="primary" style="overflow-x: hidden;">
<div class="biglogobox">
<img src="../../assets/images/logo.png" alt="">
</div>
<div class="navbox">
<ul>
<li [routerLink]="['/datacollection']" routerLinkActive="router-link-active">全部文件</li>
<mat-sidenav #drawer class="example-sidenav" mode="side" opened="true" color="primary" style="overflow-x: hidden;">
<div class="biglogobox">
<img src="../../assets/images/logo.png" alt="">
</div>
<div class="navbox">
<ul>
<li [routerLink]="['/datacollection']" routerLinkActive="router-link-active">全部文件</li>
</ul>
</div>
</mat-sidenav>
</ul>
</div>
</mat-sidenav>
<!-- <button type="button" mat-button (click)="drawer.toggle()" class="shownav">
<mat-icon>menu</mat-icon>
</button> -->
<!-- <button type="button" mat-button (click)="drawer.toggle()" class="shownav">
<mat-icon>menu</mat-icon>
</button> -->
<div class="example-sidenav-content">
<router-outlet></router-outlet>
</div>
<div class="example-sidenav-content">
<app-tabbar (toggleDarkTheme)="switchTheme($event)" (defaulttheme)="defaulttheme()" (redtheme)="redtheme()"></app-tabbar>
<router-outlet></router-outlet>
</div>
</mat-sidenav-container>

83
src/app/tabbar/tabbar.component.html

@ -1,63 +1,30 @@
<mat-toolbar [color]="theme?'primary':'accent'">
<!-- <mat-toolbar> -->
<h1>用户信息采集平台</h1>
<!-- 全屏 -->
<!-- <button mat-button (click)="!isfullscreen?fullscreenToggle():closefullscreen()" class="fullscreen">
<ng-container *ngIf="!isfullscreen; else elseTemplate">
<mat-icon *ngIf="!isfullscreen">fullscreen</mat-icon>
</ng-container>
<ng-template #elseTemplate>
<mat-icon else>fullscreen_exit</mat-icon>
</ng-template>
</button> -->
<!-- 黑夜模式开关 -->
<!-- <mat-slide-toggle (change)='onChange($event.checked)' class="darktheme"></mat-slide-toggle> -->
<mat-toolbar style="background-color: #3b8cff;">
<!-- 锁屏按钮 -->
<!-- <button mat-button class="lockscreen" [routerLink]="['/lockscreen']" routerLinkActive="router-link-active" >
<mat-icon>screen_lock_landscape</mat-icon>
</button> -->
<!-- <mat-toolbar> -->
<p style="color: white;border-bottom: 3px solid #fff;border-radius: 3px; font-size: 16px;">学习演练平台</p>
<!-- 登录信息按钮 -->
<!-- <button mat-icon-button [matMenuTriggerFor]="appMenu" class="login">
<mat-icon>account_circle</mat-icon>
</button>
<mat-menu #appMenu="matMenu">
<button mat-menu-item [routerLink]="['/ui/userdata']" >
<mat-icon>perm_identity</mat-icon>
<span>修改资料</span>
</button>
<button mat-menu-item (click)='changpsw()'>
<mat-icon>verified_user</mat-icon>
<span>修改密码</span>
</button>
<button mat-menu-item (click)='signOut()'>
<mat-icon>power_settings_new</mat-icon>
<span>退出系统</span>
</button>
</mat-menu> -->
<!-- 未登录状态 -->
<button mat-icon-button class="login" *ngIf="!isLogin.isLogin" (click)='login()'>
<mat-icon>account_circle</mat-icon>
</button>
<!-- 设置按钮 -->
<!-- <button mat-icon-button [matMenuTriggerFor]="appSet" class="setting">
<mat-icon>settings</mat-icon>
<!-- 已登录状态 -->
<button mat-icon-button [matMenuTriggerFor]="appMenu" class="login" *ngIf="isLogin.isLogin">
<mat-icon>account_circle</mat-icon>
</button>
<mat-menu #appMenu="matMenu">
<button mat-menu-item (click)='changeUserData()'>
<mat-icon>perm_identity</mat-icon>
<span>修改资料</span>
</button>
<button mat-menu-item (click)='changPassword()'>
<mat-icon>verified_user</mat-icon>
<span>修改密码</span>
</button>
<mat-menu #appSet="matMenu" yPosition="below" xPosition="after">
<button mat-menu-item (click)="defaulttheme.next()">
<mat-icon>palette</mat-icon>
<span>默认主题</span>
</button>
<button mat-menu-item (click)="redtheme.next()">
<mat-icon>whatshot</mat-icon>
<span>亮色主题</span>
</button>
<button mat-menu-item (click)="standard()">
<mat-icon>settings_overscan</mat-icon>
<span>标准模式</span>
</button>
<button mat-menu-item (click)="boxed('boxed')">
<mat-icon>laptop</mat-icon>
<span>盒子模式</span>
</button>
</mat-menu> -->
<button mat-menu-item (click)='signOut()'>
<mat-icon>power_settings_new</mat-icon>
<span>退出系统</span>
</button>
</mat-menu>
</mat-toolbar>

39
src/app/tabbar/tabbar.component.scss

@ -1,41 +1,12 @@
mat-toolbar{
position: relative;
padding-left: 65px;
}
.logo{
height: 64px;
widows: 64px;
position: relative;
padding-left: 65px;
}
h1{
line-height: 64px;
color: white;
}
mat-icon{
color: white;
color: white;
}
.login{
position: absolute;
right:30px;
}
.fullscreen{
position: absolute;
right:60px;
}
.setting{
position: absolute;
right:120px;
}
.lockscreen{
position: absolute;
right:160px;
}
.darktheme{
position: absolute;
right:140px;
display: none;
}
.boxed{
width: 1200px;
position: absolute;
right:60px;
}

99
src/app/tabbar/tabbar.component.ts

@ -1,16 +1,22 @@
import { Component, OnInit,Output,EventEmitter } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from '../http-interceptors/cache-token.service'//引入服务
import { MatDialog } from '@angular/material/dialog';
import {ChangepasswordComponent} from '../ui/changepassword/changepassword.component'
import {ChangeuserdataComponent} from '../ui/changeuserdata/changeuserdata.component'
import {LoginComponent} from '../ui/login/login.component'
import {CacheTokenService} from '../http-interceptors/cache-token.service'//引入服务
import {IsLoginService} from '../is-login.service'//引入服务
@Component({
selector: 'app-tabbar',
templateUrl: './tabbar.component.html',
styleUrls: ['./tabbar.component.scss']
})
export class TabbarComponent implements OnInit {
theme: boolean = true;
@Output()
toggle = new EventEmitter<void>();
@ -20,83 +26,42 @@ export class TabbarComponent implements OnInit {
defaulttheme = new EventEmitter<boolean>();
@Output()
redtheme = new EventEmitter<boolean>();
// @Output()
// boxed = new EventEmitter<boolean>();
onChange(eventValue: boolean){
this.toggleDarkTheme.emit(eventValue);
}
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public dialog: MatDialog) { }
ngOnInit() {
}
boxed(css){
const Element = document.body;
Element.style.width = '1200px'
}
standard(){
const Element = document.body;
Element.style.width = '100%'
}
isfullscreen:boolean = false;
fullscreenToggle(){
const docElmWithBrowsersFullScreenFunctions = document.documentElement as HTMLElement & {
mozRequestFullScreen(): Promise<void>;
webkitRequestFullscreen(): Promise<void>;
msRequestFullscreen(): Promise<void>;
};
if (docElmWithBrowsersFullScreenFunctions.requestFullscreen) {
docElmWithBrowsersFullScreenFunctions.requestFullscreen();
} else if (docElmWithBrowsersFullScreenFunctions.mozRequestFullScreen) { /* Firefox */
docElmWithBrowsersFullScreenFunctions.mozRequestFullScreen();
} else if (docElmWithBrowsersFullScreenFunctions.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
docElmWithBrowsersFullScreenFunctions.webkitRequestFullscreen();
} else if (docElmWithBrowsersFullScreenFunctions.msRequestFullscreen) { /* IE/Edge */
docElmWithBrowsersFullScreenFunctions.msRequestFullscreen();
}
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public dialog: MatDialog,public isLogin:IsLoginService) { }
ngOnInit() {
this.isfullscreen = true;
}
closefullscreen(){
const docWithBrowsersExitFunctions = document as Document & {
mozCancelFullScreen(): Promise<void>;
webkitExitFullscreen(): Promise<void>;
msExitFullscreen(): Promise<void>;
};
if (docWithBrowsersExitFunctions.exitFullscreen) {
docWithBrowsersExitFunctions.exitFullscreen();
} else if (docWithBrowsersExitFunctions.mozCancelFullScreen) { /* Firefox */
docWithBrowsersExitFunctions.mozCancelFullScreen();
} else if (docWithBrowsersExitFunctions.webkitExitFullscreen) { /* Chrome, Safari and Opera */
docWithBrowsersExitFunctions.webkitExitFullscreen();
} else if (docWithBrowsersExitFunctions.msExitFullscreen) { /* IE/Edge */
docWithBrowsersExitFunctions.msExitFullscreen();
}
this.isfullscreen = false;
//登录系统
login () {
let dialogRef = this.dialog.open(LoginComponent);
dialogRef.afterClosed().subscribe( data=>{
console.log(data)
} );
}
//退出系统
signOut = () => {
signOut () {
let out = confirm("您确定要退出吗")
if(out) {
this.http.post('/api/Account/SignOut',{}).subscribe(
data=> {
this.token.delete()
sessionStorage.clear()
window.localStorage.clear()
alert('成功退出')
this.router.navigate(['/login'])
}
)
}
}
//修改密码
changpsw() {
let dialogRef = this.dialog.open(ChangepasswordComponent,
{width:'348px'});
//修改用户资料
changeUserData () {
let dialogRef = this.dialog.open(ChangeuserdataComponent);
dialogRef.afterClosed().subscribe();
}
//修改密码
changPassword() {
let dialogRef = this.dialog.open(ChangepasswordComponent);
dialogRef.afterClosed().subscribe();
}

20
src/app/ui/changeuserdata/changeuserdata.component.html

@ -0,0 +1,20 @@
<div mat-dialog-title>
修改资料
</div>
<div mat-dialog-content>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<mat-form-field>
<input matInput id="password" name="password"
required type="password"
ngModel #password="ngModel" placeholder="请输入原密码">
</mat-form-field>
<div mat-dialog-actions class="btnbox">
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">确定</button>
<button mat-raised-button color="primary" mat-dialog-close>取消</button>
</div>
</form>
</div>

0
src/app/ui/changeuserdata/changeuserdata.component.scss

25
src/app/ui/changeuserdata/changeuserdata.component.spec.ts

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeuserdataComponent } from './changeuserdata.component';
describe('ChangeuserdataComponent', () => {
let component: ChangeuserdataComponent;
let fixture: ComponentFixture<ChangeuserdataComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ChangeuserdataComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ChangeuserdataComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

22
src/app/ui/changeuserdata/changeuserdata.component.ts

@ -0,0 +1,22 @@
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-changeuserdata',
templateUrl: './changeuserdata.component.html',
styleUrls: ['./changeuserdata.component.scss']
})
export class ChangeuserdataComponent implements OnInit {
constructor(private http:HttpClient,) { }
ngOnInit(): void {
}
//修改资料
onSubmit (e) {
console.log(e)
}
}

29
src/app/ui/login/login.component.html

@ -0,0 +1,29 @@
<div>
<div class="header"><img src="../../../assets/images/login.gif"></div>
<div class="content">
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div class="input">
<mat-icon class="icon">account_box</mat-icon>
<mat-form-field>
<input matInput id="name" name="name" required ngModel placeholder="请输入账号">
</mat-form-field>
</div>
<div class="input">
<mat-icon class="icon2">lock</mat-icon>
<mat-form-field>
<input matInput id="password" name="password" type='password' required ngModel placeholder="请输入密码">
</mat-form-field>
</div>
<div *ngIf="errmsg" class="alert-danger">
{{errmsg}}
</div>
<button type="submit" [disabled]="!form.form.valid" class="loginBtn" mat-raised-button color="primary">登录</button>
</form>
</div>
</div>

45
src/app/ui/login/login.component.scss

@ -0,0 +1,45 @@
.header {
margin: 0 auto;
width: 50px;
height: 50px;
border-radius: 50%;
img {
width: 100%;
height: 100%;
}
}
.content {
margin: 20px 0;
text-align: center;
.alert-danger {
text-align: left;
font-size: 14px;
color: red;
}
.loginBtn {
width: 90%;
border-radius: 5px;
margin-top: 10px;
}
}
.input {
margin-left: 22px;
position: relative;
}
.icon {
width: 24px;
color: #666;
font-size: 24px;
position: absolute;
top: 17px;
left: -24px;
}
.icon2 {
width: 24px;
color: #666;
font-size: 24px;
position: absolute;
top: 17px;
left: -24px;
}

25
src/app/ui/login/login.component.spec.ts

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

24
src/app/ui/login/login.component.ts

@ -0,0 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
constructor(private http:HttpClient,) { }
ngOnInit(): void {
}
errmsg:any; //err信息
//登录
onSubmit (e) {
console.log(e)
}
}

4
src/app/ui/ui.module.ts

@ -52,9 +52,11 @@ import {ConfirmpswDirective} from './changepassword/equal-validator.directive'
import { TimePipe } from '../pipes/time.pipe';
import { FileUploadModule } from 'ng2-file-upload'
import { AllFileComponent } from './all-file/all-file.component';
import { ChangeuserdataComponent } from './changeuserdata/changeuserdata.component';
import { LoginComponent } from './login/login.component';
@NgModule({
declarations: [PersonaldataComponent, ChangepasswordComponent,IsnoPipe,ConfirmpswDirective,TimePipe, AllFileComponent],
declarations: [PersonaldataComponent, ChangepasswordComponent,IsnoPipe,ConfirmpswDirective,TimePipe, AllFileComponent, ChangeuserdataComponent, LoginComponent],
imports: [
CommonModule,

Loading…
Cancel
Save