Commit d22ed590 authored by van.chen's avatar van.chen

init

parent 50b2879d
......@@ -20,12 +20,20 @@
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
{
"glob": "**/*",
"input": "./node_modules/@ant-design/icons-angular/src/inline-svg/",
"output": "/assets/"
},
"src/assets"
],
"styles": [
"src/styles.css"
"src/styles.css",
"node_modules/ng-zorro-antd/ng-zorro-antd.min.css"
],
"scripts": [
"src/assets/js/echarts.min.js"
],
"scripts": [],
"es5BrowserSupport": true
},
"configurations": {
......@@ -80,11 +88,19 @@
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/styles.css"
"src/styles.css",
"node_modules/ng-zorro-antd/ng-zorro-antd.min.css"
],
"scripts": [
"src/assets/js/echarts.min.js"
],
"scripts": [],
"assets": [
"src/favicon.ico",
{
"glob": "**/*",
"input": "./node_modules/@ant-design/icons-angular/src/inline-svg/",
"output": "/assets/"
},
"src/assets"
]
}
......@@ -133,4 +149,4 @@
}
},
"defaultProject": "witiumCloud2"
}
\ No newline at end of file
}
......@@ -129,6 +129,23 @@
"tslib": "^1.9.0"
}
},
"@angular/cdk": {
"version": "7.3.6",
"resolved": "http://registry.npm.taobao.org/@angular/cdk/download/@angular/cdk-7.3.6.tgz",
"integrity": "sha1-TDMMrNEd9K2t5sHNPtWHdF+ZEv0=",
"requires": {
"parse5": "^5.0.0",
"tslib": "^1.7.1"
},
"dependencies": {
"parse5": {
"version": "5.1.0",
"resolved": "http://registry.npm.taobao.org/parse5/download/parse5-5.1.0.tgz",
"integrity": "sha1-xZNByXI/QUxFKXVWTHwApo1YrNI=",
"optional": true
}
}
},
"@angular/cli": {
"version": "7.3.8",
"resolved": "http://registry.npm.taobao.org/@angular/cli/download/@angular/cli-7.3.8.tgz",
......@@ -450,6 +467,14 @@
"tslib": "^1.9.0"
}
},
"@ant-design/icons-angular": {
"version": "2.0.2",
"resolved": "http://registry.npm.taobao.org/@ant-design/icons-angular/download/@ant-design/icons-angular-2.0.2.tgz",
"integrity": "sha1-7oHXwJjrjioE3YLTNwURrybkbRM=",
"requires": {
"ant-design-palettes": "^1.1.3"
}
},
"@babel/code-frame": {
"version": "7.0.0",
"resolved": "http://registry.npm.taobao.org/@babel/code-frame/download/@babel/code-frame-7.0.0.tgz",
......@@ -623,6 +648,22 @@
"webpack-sources": "1.3.0"
}
},
"@ngx-translate/core": {
"version": "11.0.1",
"resolved": "http://registry.npm.taobao.org/@ngx-translate/core/download/@ngx-translate/core-11.0.1.tgz",
"integrity": "sha1-zs761B8GNo9YWdrEj+yPzESFYV8=",
"requires": {
"tslib": "^1.9.0"
}
},
"@ngx-translate/http-loader": {
"version": "4.0.0",
"resolved": "http://registry.npm.taobao.org/@ngx-translate/http-loader/download/@ngx-translate/http-loader-4.0.0.tgz",
"integrity": "sha1-ilVSSK1LfVE0YPzsnaJbBEeWLx0=",
"requires": {
"tslib": "^1.9.0"
}
},
"@schematics/angular": {
"version": "7.3.8",
"resolved": "http://registry.npm.taobao.org/@schematics/angular/download/@schematics/angular-7.3.8.tgz",
......@@ -1030,6 +1071,14 @@
"color-convert": "^1.9.0"
}
},
"ant-design-palettes": {
"version": "1.1.3",
"resolved": "http://registry.npm.taobao.org/ant-design-palettes/download/ant-design-palettes-1.1.3.tgz",
"integrity": "sha1-hBGbGk2GNjrcUqONWH5lM2oKJ90=",
"requires": {
"tinycolor2": "^1.4.1"
}
},
"anymatch": {
"version": "2.0.0",
"resolved": "http://registry.npm.taobao.org/anymatch/download/anymatch-2.0.0.tgz",
......@@ -2503,6 +2552,11 @@
"assert-plus": "^1.0.0"
}
},
"date-fns": {
"version": "1.30.1",
"resolved": "http://registry.npm.taobao.org/date-fns/download/date-fns-1.30.1.tgz",
"integrity": "sha1-LnG/CxGRU9u0zE6I2epaz7UNwFw="
},
"date-format": {
"version": "2.0.0",
"resolved": "http://registry.npm.taobao.org/date-format/download/date-format-2.0.0.tgz",
......@@ -2799,6 +2853,14 @@
"safer-buffer": "^2.1.0"
}
},
"echarts": {
"version": "4.2.1",
"resolved": "http://registry.npm.taobao.org/echarts/download/echarts-4.2.1.tgz",
"integrity": "sha1-mo6jsDNU+G+CTZdiXDNM8Wll7wM=",
"requires": {
"zrender": "4.0.7"
}
},
"ee-first": {
"version": "1.1.1",
"resolved": "http://registry.npm.taobao.org/ee-first/download/ee-first-1.1.1.tgz",
......@@ -6269,6 +6331,25 @@
"integrity": "sha1-udFeTXHGdikIZUtRg+04t1M0CDU=",
"dev": true
},
"ng-zorro-antd": {
"version": "7.2.0",
"resolved": "http://registry.npm.taobao.org/ng-zorro-antd/download/ng-zorro-antd-7.2.0.tgz",
"integrity": "sha1-N0dkjMYfJUhu244wwWKoRKoceZs=",
"requires": {
"@angular/cdk": "^7.0.0",
"@ant-design/icons-angular": "^2.0.2",
"date-fns": "^1.29.0",
"tslib": "^1.9.0"
}
},
"ngx-echarts": {
"version": "4.1.0",
"resolved": "http://registry.npm.taobao.org/ngx-echarts/download/ngx-echarts-4.1.0.tgz",
"integrity": "sha1-J8msGtabs1B9CXEln4nlaMwsrT0=",
"requires": {
"tslib": "^1.9.0"
}
},
"nice-try": {
"version": "1.0.5",
"resolved": "http://registry.npm.taobao.org/nice-try/download/nice-try-1.0.5.tgz",
......@@ -9213,6 +9294,11 @@
"setimmediate": "^1.0.4"
}
},
"tinycolor2": {
"version": "1.4.1",
"resolved": "http://registry.npm.taobao.org/tinycolor2/download/tinycolor2-1.4.1.tgz",
"integrity": "sha1-9PrTM0R7wLB9TcjpIJ2POaisd+g="
},
"tmp": {
"version": "0.0.33",
"resolved": "http://registry.npm.taobao.org/tmp/download/tmp-0.0.33.tgz",
......@@ -10389,6 +10475,11 @@
"version": "0.8.29",
"resolved": "http://registry.npm.taobao.org/zone.js/download/zone.js-0.8.29.tgz",
"integrity": "sha1-jc6Sqg3VU7ULxb+7kK+Zhq2EWhI="
},
"zrender": {
"version": "4.0.7",
"resolved": "http://registry.npm.taobao.org/zrender/download/zrender-4.0.7.tgz",
"integrity": "sha1-Fa6WCCL17+1BCZXTflEH/j3hDm0="
}
}
}
......@@ -19,7 +19,12 @@
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"core-js": "^2.5.4",
"echarts": "^4.2.1",
"ng-zorro-antd": "^7.2.0",
"ngx-echarts": "^4.1.0",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
......
// 引入 angular 动画组件
import { trigger, style, state, transition, animate } from '@angular/animations';
export const fadeDown = trigger('fadeDown', [
transition('void => *', [
style({opacity: 0, transform: 'translateY(-50%)'}),
animate('800ms ease-out', style({transform: 'translateY(0px)', opacity: 1}))
]),
transition('* => void', [
animate('800ms ease-out', style({opacity: 0, transform: 'translateY(0px)'}))
])
]);
// 引入 angular 动画组件
import {trigger, style, state, transition, animate} from '@angular/animations';
export const fadeIn = trigger('fade', [
transition('void => *', [
style({opacity: 0}),
animate('1000ms ease-in', style({opacity: 1}))
]),
transition('* => void', [
animate('1000ms ease-in', style({opacity: 0}))
])
]);
import { trigger, style, state, transition, animate } from '@angular/animations';
// export const Flyout = trigger('Flyout', [state('show', style({
// transform: 'translateX(0)'
// })), state('out', style({
// transform: 'translateX(100%)'
// })), state('in', style({
// transform: 'translateX(-100%)'
// })),
// transition('in=>show', animate('600ms ease-in')),
// transition('show=>out', animate('600ms ease-out')),
// ]);
export const Flyout = trigger('Flyout', [
state('in', style({transform: 'translateX(0)'})),
transition('void => *', [
style({transform: 'translateX(-100%)'}),
animate('600ms ease-in')
]),
transition('* => void', [
animate('600ms ease-out', style({transform: 'translateX(100%)'}))
])
]);
import {trigger, style, state, transition, animate} from '@angular/animations';
export const transitionAll = trigger('open', [
state('in', style({height: '*'})),
transition('* => void', [
style({height: '*'}),
animate(250, style({height: 0}))
])
]);
import { trigger, style, state, transition, animate } from '@angular/animations';
export const zoom = trigger('zoom', [state('inactive', style({
backgroundColor: '#fff',
transform: 'scale(1)'
})), state('active', style({
backgroundColor: 'pink',
transform: 'scale(1.2)'
})),
transition('inactive => active', animate('300ms ease-in')),
transition('active => inactive', animate('300ms ease-out')),
]);
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
</div>
<h2>Here are some links to help you start: </h2>
<ul>
<li>
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
</li>
<li>
<h2><a target="_blank" rel="noopener" href="https://angular.io/cli">CLI Documentation</a></h2>
</li>
<li>
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
</li>
</ul>
<router-outlet></router-outlet>
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'witiumCloud2'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('witiumCloud2');
});
it('should render title in a h1 tag', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to witiumCloud2!');
});
});
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {RoutingModule} from './router.module';
import {NgZorroAntdModule} from 'ng-zorro-antd';
import { AppComponent } from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {HttpClientModule, HttpClient} from '@angular/common/http';
import {NgxEchartsModule} from 'ngx-echarts';
// 主模块注册
import {LayoutModule} from './layout/layout.module';
// 主组件注册
import {AppComponent} from './app.component';
// 国际化相关内容
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
// http
import {HTTP_INTERCEPTORS} from '@angular/common/http';
export function createTranslateHttpLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
// 配置 angular i18n
import {registerLocaleData} from '@angular/common';
import zh from '@angular/common/locales/zh';
registerLocaleData(zh);
// 配置 ng-zorro-antd 国际化
import {NZ_I18N, en_US, zh_CN} from 'ng-zorro-antd';
// 相关的服务
import {AuthInterceptor} from './service/token';
import {HttpService} from './service/http';
import {ApiService} from './service/api';
import {AuthService} from './service/auth';
import {PermissionService} from './service/permission';
import {MenuService} from './service/menu';
import {CheckService} from './service/check';
@NgModule({
declarations: [
AppComponent
AppComponent,
],
imports: [
BrowserModule
BrowserModule,
NgxEchartsModule,
LayoutModule,
BrowserAnimationsModule,
HttpClientModule,
RoutingModule,
BrowserAnimationsModule,
NgZorroAntdModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateHttpLoader),
deps: [HttpClient]
}
})
],
providers: [
{provide: NZ_I18N, useValue: zh_CN},
{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true,
},
HttpService,
ApiService,
AuthService,
PermissionService,
MenuService,
CheckService
],
providers: [],
bootstrap: [AppComponent]
bootstrap: [
AppComponent,
]
})
export class AppModule { }
export class AppModule {
}
<div style="width: 100%;
height: 100%;
background-color: #ee9a30;">
<div style="letter-spacing: 40px;
font-size: 200px;
text-align: center;
padding: 130px 0;
font-weight: 900;
color: #ffffff;">404</div>
<div style="text-align: center;
font-size: 35px;
padding-top: 30px;
color: #ffffff;">{{'sorryNotFound' | translate}}...</div>
</div>
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-404',
templateUrl: './404.component.html'
})
export class NotFoundComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}
<router-outlet></router-outlet>
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-extra',
templateUrl: './extra.component.html',
styleUrls: ['./extra.component.css']
})
export class ExtraComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {TranslateModule} from '@ngx-translate/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {NgZorroAntdModule} from 'ng-zorro-antd';
import {LoginComponent} from './login/login.component';
import {NotFoundComponent} from './404/404.component';
import {ExtraComponent} from './extra.component';
import {RouterModule} from '@angular/router';
@NgModule({
imports: [
FormsModule,
ReactiveFormsModule,
CommonModule,
TranslateModule,
NgZorroAntdModule,
RouterModule.forChild([{
path: '',
component: ExtraComponent,
children: [
{path: '', redirectTo: '/extra/login', pathMatch: 'full'},
{path: 'login', component: LoginComponent}
]
}])
],
declarations: [ExtraComponent, LoginComponent, NotFoundComponent]
})
export class ExtraModule {
}
<div class="mainCon">
<div class="loginPart">
<div class="online">
<div class="label">用户名</div>
<div class="value">
<input nz-input style="width: 100%;" [(ngModel)]="req.userName">
</div>
</div>
<div class="online">
<div class="label">密码</div>
<div class="value">
<input nz-input type="password" style="width: 100%;" [(ngModel)]="req.password">
</div>
</div>
<div class="online">
<button nz-button nzType="primary" nzBlock (click)="login()">登录</button>
</div>
</div>
</div>
.mainCon {
height: 100%;
width: 100%;
display: flex;
justify-content:center;
align-items:Center;
background-color: lightgoldenrodyellow;
.loginPart {
width: 400px;
height: 300px;
margin: auto;
.online {
margin-bottom: 25px;
.label,.value {
display: inline-block;
}
.label {
width: 25%;
}
.value {
width: 75%;
}
}
}
}
import { Component, OnInit } from '@angular/core';
import {
AbstractControl,
FormBuilder,
FormGroup,
Validators
} from '@angular/forms';
import {en_US, NzMessageService, zh_CN, NzI18nService} from 'ng-zorro-antd';
import { ApiService } from '../../service/api';
import {PermissionService} from '../../service/permission';
import {Router} from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
isLoading = false;
req: any = {};
constructor(private api: ApiService, private message: NzMessageService,
private permission: PermissionService, private router: Router,
private translate: TranslateService, private nzI18nService: NzI18nService) {
}
ngOnInit(): void {
}
login() {
this.isLoading = true;
const req = {
userName: this.req.userName,
password: this.req.password
};
this.api.login.dologin([req, (data: any) => {
if (data.constructor === Object) {
if (data.code === 1) {
debugger;
window.sessionStorage.setItem('_AMap_AMap.MapInner', data.message);
this.router.navigate(['app/home']);
// this.getCurUser();
} else {
this.message.error(data.message);
}
}
this.isLoading = false;
}]);
}
// getCurUser() {
// this.isLoading = true;
// this.api.user.getSelfInfo(['', (data: any) => {
// if (data.userName) {
// window.sessionStorage.setItem(encodeURIComponent('_AMap_AMap.IndoorMapFunc'), encodeURIComponent(JSON.stringify(data)));
// this.permission.getAllPermission('login', data);
// } else {
// this.message.error(this.translate.instant('noUserInfo'));
// }
// this.isLoading = false;
// }]);
// }
// toEn() {
// this.translate.use('en');
// this.nzI18nService.setLocale(en_US);
// document.getElementById('loginBtn').style.letterSpacing = '0px';
// localStorage.setItem('witium-default-language', 'en');
// }
//
// toZh() {
// this.translate.use('zh');
// this.nzI18nService.setLocale(zh_CN);
// document.getElementById('loginBtn').style.letterSpacing = '3px';
// localStorage.setItem('witium-default-language', 'zh');
// }
}
<nz-breadcrumb nzSeparator=">" *ngIf="bcShow && bShow">
<nz-breadcrumb-item *ngFor="let step of _title, let i = index">
<span class="breadText" (click)="goTo(i + 1)">{{step | translate}}</span>
</nz-breadcrumb-item>
</nz-breadcrumb>
nz-breadcrumb{
line-height: 1.5;
background: #fff;
padding: 15px 25px;
font-size: 15px;
color: #bfc0c2;
}
.breadText{
font-weight: 400;
cursor: pointer;
}
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-breadcrumb',
templateUrl: './breadcrumb.component.html',
styleUrls: ['./breadcrumb.component.scss']
})
export class BreadcrumbComponent implements OnInit {
bShow = true;
_title = [];
@Input()
get title(): any {
return this._title;
}
set title(_title: any) {
this._title = _title;
this.whenChange();
}
@Input()bcShow;
constructor() { }
ngOnInit() {
}
whenChange() {
if (this._title[0] === 'home') {
this.bShow = false;
} else {
this.bShow = true;
}
}
goTo(index) {
if (index > 1 && this._title[1] !== 'historyData') {
const oldAddr = this._title.join('/');
const addr = this._title.slice(0, index).join('/');
window.location.href = window.location.href.replace(oldAddr, addr);
}
}
}
<div style="text-align: center;height: 50px;line-height: 50px;">Design ©2018 Implement By Witium.</div>
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-footer',
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.scss']
})
export class FooterComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
<nz-layout style="height:100%">
<nz-sider style="background-color: #fff;border-right: 1px solid #e6e6e6;overflow-y: auto;" nzCollapsible [(nzCollapsed)]="isCollapsed" [nzTrigger]="triggerTemplate">
<div class="logo logoBackground bottomLine" [ngClass]="{'width-200': !isCollapsed, 'width-80': isCollapsed}">
<span *ngIf="!isCollapsed">
<div style="height: 54px;"></div>
</span>
<span *ngIf="isCollapsed" style="width: calc(50% - 64px);display: block;">
<i class="iconfont icon-cloud"></i>
</span>
</div>
<app-leftmenu #leftmenu [isCollapsed]="isCollapsed" [selectedItem]="selectedItem"></app-leftmenu>
</nz-sider>
<nz-layout>
<nz-header class="logoBackground bottomLine" style="padding:0;position:fixed; width:100%;z-index: 99;">
<i class="iconfont trigger textStyle1 whenHover" [class.icon-toFold]="!isCollapsed"
[class.icon-toOpen]="isCollapsed" (click)="changeCollapsed()"></i>
<label class="linkToPersonSetting whenHover textStyle1" routerLink="/app/systemSet/personSet">
<i class="iconfont icon-user"></i>
{{'personSet' | translate}}
</label>
<label class="loginOut whenHover textStyle1" (click)="loginOut()">
{{'signOut' | translate}}
</label>
</nz-header>
<nz-content id="layoutCon" style="margin-top:64px;overflow: auto;">
<app-breadcrumb [title]="title" [bcShow]="bcShow"></app-breadcrumb>
<div style="overflow-y: auto;overflow-x: auto;width: 100%;height: 100%">
<router-outlet></router-outlet>
</div>
</nz-content>
<app-footer></app-footer>
</nz-layout>
</nz-layout>
<ng-template #trigger>
<i class="iconfont icon-up"></i>
</ng-template>
<!--<div class="footer"></div>-->
$headerSlideBackground: rgba(255, 255, 255, 1);
:host ::ng-deep .trigger {
font-size: 20px;
line-height: 64px;
padding: 0 24px;
cursor: pointer;
transition: color .3s;
}
:host ::ng-deep .logo {
text-align: center;
}
.logoBackground {
background-color: $headerSlideBackground;
height: 64px;
line-height: 64px;
}
.loginOut {
position: fixed;
right: 40px;
}
.linkToPersonSetting {
position: fixed;
right: 100px;
}
.logo{
z-index: 5;
position: fixed;
padding: 5px;
border-right: 1px solid #e6e6e6;
}
ul {
height: calc(100% - 64px);
overflow-y: auto;
margin-top: 64px;
overflow-x: hidden;
}
.width-200{
width: 200px;
}
.width-80{
width: 80px;
}
import {Component, TemplateRef, ViewChild, OnInit} from '@angular/core';
import {Router, NavigationEnd} from '@angular/router';
import {ApiService} from '../service/api';
import {NzMessageService, zh_CN, en_US, NzI18nService} from 'ng-zorro-antd';
import {LeftmenuComponent} from './leftmenu/leftmenu.component';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'app-layout',
templateUrl: './layout.component.html',
styleUrls: ['./layout.component.scss']
})
export class LayoutComponent implements OnInit {
isCollapsed = false;
triggerTemplate = null;
title;
bcShow = true;
selectedItem;
@ViewChild('trigger') customTrigger: TemplateRef<void>;
@ViewChild('leftmenu') leftmenu: LeftmenuComponent;
constructor(private router: Router, private api: ApiService, private message: NzMessageService,
private translate: TranslateService, private nzI18nService: NzI18nService) {
}
// custom trigger can be TemplateRef
changeTrigger(): void {
this.triggerTemplate = this.customTrigger;
}
changeCollapsed() {
this.leftmenu.collapseChange(!this.isCollapsed);
this.isCollapsed = !this.isCollapsed;
}
ngOnInit() {
let hash = window.location.hash;
if (hash.indexOf('?') > -1) {
hash = hash.slice(0, hash.indexOf('?'));
}
if (hash !== '#/app') {
this.bcShow = true;
this.title = hash.replace(/#\/app\//g, '').split('/');
} else {
this.bcShow = false;
}
this.selectedItem = hash.replace(/#\/app\//g, '')
.replace(/\/detail/g, '/dataMonitoring/')
.replace(/\/oldData/g, '/dataMonitoring/').split('/');
this.router.events
.subscribe((event: NavigationEnd) => {
if (event instanceof NavigationEnd) {
let hashValue = window.location.hash;
if (hashValue.indexOf('?') > -1) {
hashValue = hashValue.slice(0, hashValue.indexOf('?'));
}
if (hashValue !== '#/app') {
this.bcShow = true;
this.title = hashValue.replace(/#\/app\//g, '').split('/');
} else {
this.bcShow = false;
}
this.selectedItem = hashValue.replace(/#\/app\//g, '')
.replace(/\/detail/g, '/dataMonitoring')
.replace(/\/oldData/g, '/dataMonitoring').split('/');
}
});
}
loginOut() {
this.api.login.logout(['', (data: any) => {
const message = data.message ? data.message : this.translate.instant('loginOutSuccess');
this.message.success(message);
window.sessionStorage.clear();
this.router.navigate(['/extra/login']);
}]);
}
}
import {NgModule} from '@angular/core';
import {TranslateModule} from '@ngx-translate/core';
import {NgZorroAntdModule} from 'ng-zorro-antd';
import {FormsModule} from '@angular/forms';
import {CommonModule} from '@angular/common';
import {NZ_MESSAGE_CONFIG} from 'ng-zorro-antd';
import {NgxEchartsModule} from 'ngx-echarts';
import {LayoutComponent} from './layout.component';
import {LeftmenuComponent} from './leftmenu/leftmenu.component';
import {FooterComponent} from './footer/footer.component';
import {BreadcrumbComponent} from './breadcrumb/breadcrumb.component';
import {HomeComponent} from '../main/home/home.component';
import {LayoutRoutingModule} from '../router.module';
@NgModule({
imports: [
TranslateModule,
NgxEchartsModule,
CommonModule,
NgZorroAntdModule,
FormsModule,
LayoutRoutingModule
],
providers: [
{
provide: NZ_MESSAGE_CONFIG,
useValue: {
nzDuration: 3000,
nzMaxStack: 7,
nzPauseOnHover: true,
nzAnimate: true
}
}
],
declarations: [
LayoutComponent,
LeftmenuComponent,
FooterComponent,
BreadcrumbComponent,
HomeComponent
]
})
export class LayoutModule {
}
<div class="menuPart">
<div class="menuFirst" *ngFor="let item of dataArr">
<div class="first-floor textStyle1 whenHover" [title]="item.name | translate" *ngIf="(item.child && item.child.length > 0) || item.type" (click)="selectFirstFloor(item)" [ngClass]="{'isSelectedFirst': isSelected[0] === item.name, 'isSelectedSecond': isSelected[0] === item.name && item.type === 1}">
<i [class]="item.icon" [ngClass]="{'iconLeft': !isCollapsed,'iconLeftCos': isCollapsed}"></i>
<span *ngIf="!isCollapsed">{{item.name | translate}}</span>
<i class="iconfont iconRight" [ngClass]="{'icon-down': !isOpen[item.name] && !item.type && !isCollapsed,'icon-up': isOpen[item.name] && !item.type && !isCollapsed, 'icon-right': isCollapsed && !item.type}"></i>
</div>
<div *ngIf="isOpen[item.name] && !isCollapsed" class="menuSecond whenHover">
<div class="second-floor whenHover textStyle2" [title]="one.name | translate" *ngFor="let one of item.child"
(click)="selectSecondFloor(item.name, one.name)"
[ngClass]="{'isSelectedSecond': isSelected[0] === item.name && isSelected[1] === one.name}">{{one.name | translate}}
</div>
</div>
<div *ngIf="isCollapsed && item.child.length > 0" class="menuSecondCos" [ngClass]="{'isCos': isCollapsed}">
<div class="handleTheLeft">
<div class="second-floor-cos whenHover textStyle2" *ngFor="let one of item.child"
(click)="selectSecondFloor(item.name, one.name)"
[ngClass]="{'isSelectedSecond': isSelected[0] === item.name && isSelected[1] === one.name}">{{one.name | translate}}
</div>
</div>
</div>
</div>
</div>
.menuPart {
margin-top: 64px;
}
.menuFirst,.menuSecond {
padding: 0;
}
.menuFirst {
position: relative;
}
.first-floor {
line-height: 48px;
height: 48px;
color: rgba(0,0,0,.65);
padding-left: 14px;
padding-right: 34px;
position: relative;
cursor: pointer;
width: 100%;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
.second-floor {
line-height: 40px;
height: 40px;
text-indent: 48px;
color: rgba(0,0,0,.65);
cursor: pointer;
width: 100%;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
i.iconLeft {
padding: 0 10px;
}
i.iconRight {
position: absolute;
top: 0;
right: 17px;
font-size: 15px;
font-weight: bolder;
}
.iconLeftCos {
padding: 0 5px;
}
.menuSecondCos {
position: fixed;
left: 80px;
margin-top: -50px;
z-index: 2000;
padding-left: 5px;
}
.second-floor-cos {
line-height: 40px;
height: 40px;
text-indent: 25px;
padding-right: 25px;
cursor: pointer;
}
.menuFirst .menuSecondCos.isCos{
display: none;
}
.menuFirst:hover .menuSecondCos.isCos{
display: block;
}
.handleTheLeft {
min-width: 160px;
background-color: #FFFFFF;
border-radius: 10px;
overflow: hidden;
border: 1px solid #ccc;
}
.isSelectedSecond {
color: #005691 !important;
background-color: #efefef;
}
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { PermissionService } from '../../service/permission';
import { Router } from '@angular/router';
@Component({
selector: 'app-leftmenu',
templateUrl: './leftmenu.component.html',
styleUrls: ['./leftmenu.component.scss']
})
export class LeftmenuComponent implements OnInit, OnDestroy {
constructor(private message: NzMessageService, private permissionS: PermissionService, private router: Router) {
}
selectItem: any;
@Input() isCollapsed;
@Input()
get selectedItem() {
return this.selectItem;
}
set selectedItem(selectItem: any) {
this.selectItem = selectItem;
this.init();
}
dataArr = [{
name: 'home',
icon: 'iconfont icon-home',
type: 1,
child: []
}, {
name: 'dataManage',
icon: 'iconfont icon-data',
type: 0,
// {name: 'actualData'}, {name: 'compare'}
child: []
}, {
name: 'pointAnalyse',
icon: 'iconfont icon-alarmUp',
type: 0,
child: []
}, {
name: 'alarmWarn',
icon: 'iconfont icon-warn',
type: 0,
// {name: 'warnInfo'}, {name: 'alarmInfo'}
child: []
}, {
name: 'deviceManage',
icon: 'iconfont icon-device',
type: 0,
// {name: 'gatewayManage'}, {name: 'collectorManage'}, {name: 'deviceModel'}, {name: 'deviceType'}
child: []
// }, {
// name: 'moduleCenter',
// icon: 'iconfont icon-edit',
// type: 0,
// child: [{name: 'moduleManage'}, {name: 'partManage'}, {name: 'channelTopic'}, {name: 'subjectManage'}]
}, {
name: 'systemSet',
icon: 'iconfont icon-setting',
type: 0,
child: [{name: 'personSet'}, {name: 'roleManage'}, {name: 'areaManage'},
{name: 'departmentManage'}, {name: 'pointManage'}, {name: 'factoryManage'},
{name: 'userManage'}, {name: 'operateSet'}, {name: 'loginLog'}]
// child: []
}];
isOpen = {monitoring: false, deviceManage: false, pileManage: false, moduleCenter: false, systemSet: false};
isSelected = ['', ''];
ngOnInit() {
this.init();
// this.getPermission();
}
init() {
if (this.selectItem && this.selectItem.length > 0) {
this.isOpen[this.selectItem[0]] = true;
this.isSelected = this.selectItem;
}
}
ngOnDestroy() {
}
// getPermission() {
// const arr = [...this.dataArr];
// const obj = this.permissionS.getTiny();
// arr.map((item, index) => {
// if (item.name !== 'home') {
// item.child = obj[item.name].child;
// }
// if (index === arr.length - 1 ) {
// this.dataArr = arr;
// }
// });
// }
selectFirstFloor(item) {
if (item.type) {
this.isOpen = {monitoring: false, deviceManage: false, pileManage: false, moduleCenter: false, systemSet: false};
this.isSelected = [item.name];
this.router.navigate(['app/' + item.name]);
} else if (!this.isCollapsed) {
this.isOpen[item.name] = !this.isOpen[item.name];
}
}
selectSecondFloor(item1, item2) {
const isOpen = {monitoring: false, deviceManage: false, pileManage: false, moduleCenter: false, systemSet: false};
isOpen[item1] = true;
this.isOpen = isOpen;
this.isSelected = [item1, item2];
this.router.navigate(['app/' + item1 + '/' + item2]);
}
collapseChange(e) {
if (!e) {
const isOpen = {monitoring: false, deviceManage: false, pileManage: false, moduleCenter: false, systemSet: false};
isOpen[this.isSelected[0]] = true;
this.isOpen = isOpen;
}
}
}
import {Component, OnInit} from '@angular/core';
import {fadeIn} from '../../animation/fade-in';
import {ApiService} from '../../service/api';
import {NzMessageService} from 'ng-zorro-antd';
import {TranslateService} from '@ngx-translate/core';
import {Router} from '@angular/router';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
animations: [fadeIn]
})
export class HomeComponent implements OnInit {
constructor(private api: ApiService, private message: NzMessageService,
private translate: TranslateService, private router: Router) {
}
ngOnInit() {
this.init();
}
init() {
}
}
import { RouterModule, Routes } from '@angular/router';
import { LayoutComponent } from './layout/layout.component';
import { AuthService } from './service/auth';
import { HomeComponent } from './main/home/home.component';
const AppRoutes: Routes = [
{path: '', redirectTo: '/extra/login', pathMatch: 'full'},
{path: 'app', component: LayoutComponent},
{path: 'extra', loadChildren: './extra/extra.module#ExtraModule'},
{path: '**', redirectTo: '/extra/login', pathMatch: 'full'},
];
export const RoutingModule = RouterModule.forRoot(AppRoutes, {useHash: true});
const routes: Routes = [
{
path: 'app',
component: LayoutComponent,
canActivateChild: [AuthService],
children: [
{path: '', redirectTo: '/extra/login', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
]
}
];
export const LayoutRoutingModule = RouterModule.forChild(routes);
This diff is collapsed.
import {Injectable, OnInit} from '@angular/core';
import {CanActivateChild, Router, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {PermissionService} from './permission';
import {MenuService} from './menu';
@Injectable()
export class AuthService implements CanActivateChild, OnInit {
public login = false;
private permissionR = '';
// 判断是否有 cookie 的标识
isLogin = false;
constructor(private router: Router, private menu: MenuService, private permission: PermissionService) {
}
ngOnInit() {
}
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const layoutCon = document.getElementById('layoutCon');
if (layoutCon) {
layoutCon.scrollTop = 0;
}
return this.checkLogin() && this.permissionCheck(state.url);
// return this.checkLogin();
// return true;
}
// 登录验证,如果有值就返回true.没有就跳转登录
checkLogin() {
if (window.sessionStorage.getItem('_AMap_AMap.MapInner')) {
return true;
}
this.router.navigate(['/extra/login']);
return false;
}
// 路由跳转权限检测
permissionCheck(routerUrl) {
return true;
}
}
import { Injectable } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { isUndefined } from 'util';
import { TranslateService } from '@ngx-translate/core';
@Injectable()
export class CheckService {
constructor( private message: NzMessageService, private translate: TranslateService) {}
formCheck(data, req) {
const fNum = req.field.length;
const fieldStr = '-' + req.field.join('-') + '-';
const field = req.field.filter((item) => data[item] !== null && !isUndefined(data[item])).length;
if (field !== fNum) {
this.message.warning(this.translate.instant('pleaseFillAll'));
return false;
}
const tNum = req.time ? req.time.length : 0;
const time = req.time ? req.time.filter((item) => this.checkTime(fieldStr, data, item)).length : 0;
if (time !== tNum) {
this.message.warning(this.translate.instant('wrongTime'));
return false;
}
const telNum = req.tel ? req.tel.length : 0;
const tel = req.tel ? req.tel.filter((item) => this.checkTel(fieldStr, data, item)).length : 0;
if (tel !== telNum) {
this.message.warning(this.translate.instant('wrongTel'));
return false;
}
const mNum = req.money ? req.money.length : 0;
const money = req.money ? req.money.filter((item) => this.checkMoney(fieldStr, data, item)).length : 0;
if (money !== mNum) {
this.message.warning(this.translate.instant('wrongAmount'));
return false;
}
const nNum = req.num ? req.num.length : 0;
const num = req.num ? req.num.filter((item) => this.checkNum(fieldStr, data, item)).length : 0;
if (num !== nNum) {
this.message.warning(this.translate.instant('wrongNum'));
return false;
}
const f2Num = req.float2 ? req.float2.length : 0;
const float2 = req.float2 ? req.float2.filter((item) => this.checkFloat2(fieldStr, data, item)).length : 0;
if (float2 !== f2Num) {
this.message.warning(this.translate.instant('wrongNum'));
return false;
}
return true;
}
private checkTime(fieldStr, data, time) {
if ((data[time] === '' || isUndefined(data[time]) || data[time] === null) && fieldStr.indexOf('-' + time + '-') > -1) {
return true;
}
if (data[time] && new Date(data[time]).getTime() > 0 && new Date(data[time]).getTime().toString().length === 13) {
return true;
} else {
return false;
}
}
private checkTel(fieldStr, data, tel) {
if ((data[tel] === '' || isUndefined(data[tel]) || data[tel] === null) && fieldStr.indexOf('-' + tel + '-') > -1) {
return true;
}
const reg = new RegExp( '^1\\d{10}$');
if (data[tel].length !== 11 || !reg.test(data[tel])) {
return false;
} else {
return true;
}
}
private checkMoney(fieldStr, data, money) {
if ((data[money] === '' || isUndefined(data[money]) || data[money] === null) && fieldStr.indexOf('-' + money + '-') > -1) {
return true;
}
if (parseFloat(data[money]).toFixed(2) === data[money] && parseInt(data[money], 10).toString().length < 8) {
return true;
} else {
return false;
}
}
private checkNum(fieldStr, data, num) {
if ((data[num] === '' || isUndefined(data[num]) || data[num] === null) && fieldStr.indexOf('-' + num + '-') > -1) {
return true;
}
const reg = new RegExp( '^[0-9]*$');
if (reg.test(data[num])) {
return true;
} else {
return false;
}
}
private checkFloat2(fieldStr, data, float2) {
if ((data[float2] === '' || isUndefined(data[float2]) || data[float2] === null) && fieldStr.indexOf('-' + float2 + '-') > -1) {
return true;
}
if ( parseFloat(data[float2]).toFixed(2).toString() === data[float2]) {
return true;
} else {
return false;
}
}
}
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Subscription } from 'rxjs/index';
import { Router } from '@angular/router';
import { NzMessageService } from 'ng-zorro-antd';
@Injectable()
export class HttpService {
constructor(private http: HttpClient, private router: Router, private message: NzMessageService) {
this.subs = new Array<Subscription>();
}
private subs: Subscription[];
private header = new HttpHeaders().append('Content-Type', 'application/json').append('Access-Control-Allow-Origin', '*');
postParamObj = {
withCredentials: true,
headers: this.header
};
getParamObj = {
withCredentials: true,
};
// 封装统一的 http 请求方法
get(url: string,
next?: (value: Response) => void,
error?: (error: any) => void,
complete?: () => void): void {
if (url.indexOf('?') > -1) {
// 有参数
url += `&dateStamp=` + + new Date().getTime().toString();
} else {
// 无参数
url += `?dateStamp=` + new Date().getTime().toString();
}
this.subs.push(this.http.get(`${url}`, this.getParamObj).subscribe(next, error, complete));
}
post(url: string,
data: any,
next?: (value: Response) => void,
error?: (error: any) => void,
complete?: () => void): void {
if (url.indexOf('?') > -1) {
// 有参数
url += `&dateStamp=` + new Date().getTime().toString();
} else {
// 无参数
url += `?dateStamp=` + new Date().getTime().toString();
}
this.subs.push(this.http.post(url, data, this.postParamObj).subscribe(next, error, complete));
}
// token 失效处理函数
handleToken = (value) => {
if (value && value.code && value.code === 2) {
return false;
} else {
return true;
}
}
// 跳转登录页面
toLoginPage(time) {
window.setTimeout(() => {
this.router.navigate(['/extra/login']);
}, time);
}
// 复制属性
public cloneProp(ob, nOb) {
const car = new nOb();
for (const prop in ob) {
if (ob[prop] || ob[prop] === 0) {
car[prop] = ob[prop];
} else {
car[prop] = '';
}
}
return car;
}
}
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
@Injectable()
export class MenuService {
constructor(private translate: TranslateService) {}
private menu = {
indexManager: '首页',
dataManager: '数据管理',
alarmWarning: '报警预警',
deviceManager: '传感器管理',
systemManager: '系统设置',
index: '首页',
realData: '实时数据',
historyData: '历史数据',
dataComparison: '数据对比',
warning: '预警管理',
alarm: '报警管理',
};
private menuFront = {
indexManager: 'home',
dataManager: 'dataManage',
alarmWarning: 'alarmWarn',
deviceManager: 'deviceManage',
systemManager: 'systemSet',
index: 'home',
realData: 'actualData',
historyData: 'historyData',
dataComparison: 'compare',
warning: 'warnInfo',
alarm: 'alarmInfo',
};
transform(value: any): any {
return this.translate.instant(value);
}
transformFront(value: any): any {
return this.menuFront[value];
}
}
import { Injectable } from '@angular/core';
import { ApiService } from './api';
import { Router } from '@angular/router';
import { MenuService } from './menu';
@Injectable({
providedIn: 'root'
})
export class PermissionService {
private permissionAll = {};
private permissionTiny = {};
private functions = [];
constructor(private api: ApiService, private menu: MenuService, private router: Router) {
}
getAllPermission(type, data) {
// let roleNo = '';
// if (data.roleNo) {
// roleNo = data.roleNo;
// } else {
// this.router.navigate(['/extra/login']);
// return;
// }
// this.permissionAll = [];
// this.api.permission.getPermissionByRoleNo([{roleNo: roleNo}, (resp: any) => {
// if (resp.constructor === Array) {
// this.permissionAll = resp;
// window.sessionStorage.setItem(encodeURIComponent('_AMap_AMap.OuterEnter'), this.transform(JSON.stringify(resp)));
// this.getTinyPermission(type);
// } else {
// this.router.navigate(['/extra/login']);
// }}]);
}
getTinyPermission(type) {
// this.permissionTiny = [];
// const all: any = this.permissionAll;
// const obj: any = {};
// const opers = [];
// if (all.constructor === Array) {
// all.map((item: any, index) => {
// obj[this.menu.transformFront(item.parentSidebarName)] = {};
// obj[this.menu.transformFront(item.parentSidebarName)].child = [];
// // if ( index === 4 ) {
// // obj[this.menu.transformFront(item.parentSidebarName)].child.push({name: 'personSet'});
// // }
// if (item.sidebarVos.constructor === Array && item.sidebarVos.length > 0) {
// item.sidebarVos.map((side: any, sIndex) => {
// let check = false;
// if (side.permissionShowVos.constructor === Array && side.permissionShowVos.length > 0) {
// side.permissionShowVos.map((oper: any, oIndex) => {
// if (oper.checked && (oper.permissionName === 'factoryConfig' ||
// oper.permissionName === 'monitoringPointConfig' || oper.permissionName === 'cuttingMachineSelect' ||
// oper.permissionName === 'machineRoomSelect')) {
// obj[this.menu.transformFront(oper.permissionName)] = {};
// }
// if (oper.checked) {
// check = true;
// opers.push(oper.permissionName);
// }
// if (oIndex === side.permissionShowVos.length - 1 && check) {
// obj[this.menu.transformFront(item.parentSidebarName)].child.push({name: this.menu.transformFront(side.sidebarName)});
// }
// if (oIndex === side.permissionShowVos.length - 1 && sIndex === item.sidebarVos.length - 1 && index === all.length - 1) {
// this.permissionTiny = obj;
// this.functions = opers;
// this.out(type);
// }
// });
// } else if (sIndex === item.sidebarVos.length - 1 && index === all.length - 1) {
// this.permissionTiny = obj;
// this.functions = opers;
// this.out(type);
// }
// });
// } else if (index === all.length - 1) {
// this.permissionTiny = obj;
// this.functions = opers;
// this.out(type);
// }
// });
// }
}
out(type) {
const permissionCheckJson = JSON.stringify(this.permissionTiny);
window.sessionStorage.setItem(encodeURIComponent('_AMap_AMap.OuterEnterKey'), this.transform(permissionCheckJson));
const funcCheckJson = JSON.stringify(this.functions);
window.sessionStorage.setItem(encodeURIComponent('_AMap_AMap.InterEnterKey'), this.transform(funcCheckJson));
if (permissionCheckJson.indexOf('home') && type === 'login') {
this.router.navigate(['app/home']);
} else {
this.router.navigate(['extra/login']);
}
}
// 生成一个随机token的key值
createTokenKey(length) {
const chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
let num = '';
for (let i = 0; i < length; i++) {
const id = parseInt((Math.random() * 60).toString(), 10);
num += chars[id];
}
return num;
}
transform(data) {
const str = data;
const key = this.createTokenKey(str.length);
let defaultStr = '';
for (let i = 0, length = str.length; i < length; i++) {
defaultStr += str[i] + key[i];
}
return encodeURIComponent(defaultStr);
}
transback(data) {
const str = decodeURIComponent(data);
let defaultStr = '';
for (let i = 0, length = str.length; i < length; i++) {
if (i % 2 === 0) {
defaultStr += str[i];
}
}
return defaultStr;
}
getFull(): any {
let data = window.sessionStorage.getItem(encodeURIComponent('_AMap_AMap.OuterEnter'));
if (data) {
data = JSON.parse(this.transback(data));
return data;
} else {
this.router.navigate(['extra/login']);
return [];
}
}
getTiny(): any {
let data = window.sessionStorage.getItem(encodeURIComponent('_AMap_AMap.OuterEnterKey'));
if (data) {
data = JSON.parse(this.transback(data));
return data;
} else {
this.router.navigate(['extra/login']);
return [];
}
}
private getFuncs(): any {
let data = window.sessionStorage.getItem(encodeURIComponent('_AMap_AMap.InterEnterKey'));
if (data) {
data = JSON.parse(this.transback(data));
return data;
} else {
this.router.navigate(['extra/login']);
return [];
}
}
testFuncs(funcName) {
if (this.functions.length <= 0) {
this.functions = this.getFuncs();
}
if (JSON.stringify(this.functions).indexOf(funcName) > -1) {
return true;
} else {
return false;
}
}
}
import { Injectable, OnInit } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs/index';
@Injectable()
export class AuthInterceptor implements HttpInterceptor, OnInit {
constructor() {
}
token: string;
ngOnInit() {
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// 这里的拦截了所有的请求,并且加上了token和语言
// const authHeader = '';
// 每次都获取最新的token
this.token = window.sessionStorage.getItem('_AMap_AMap.MapInner') || '';
let lan = localStorage.getItem('witium-default-language') || '';
if (lan === 'zh') {
lan = 'cn';
}
lan = lan || 'cn';
const authReq = req.clone({headers: req.headers.set('AccountToken', this.token).set('AccountLanguage', lan)});
// 额外加上语言识别
// const authLanguage = authReq.clone({headers: authReq.headers.set('AccountLanguage', this.language.authLangauge)})
return next.handle(authReq);
}
}
This diff is collapsed.
{
"---------------a": "---------------a",
"---------------b": "---------------b",
"percent": "百分值",
"change": "变更",
"alarm": "报警",
"alarmInfo": "报警信息",
"alarmWarn": "报警预警",
"edit": "编辑",
"departmentManage": "部门管理",
"---------------c": "---------------c",
"search":"查询",
"operate": "操作",
"operateSet": "操作设置",
"collectorManage": "传感器管理",
"factoryManage":"厂区管理",
"factoryPaint":"厂区配置图",
"---------------d": "---------------d",
"tel": "电话",
"loginName": "登录名",
"loginLog": "登录日志",
"current": "当前",
"---------------e": "---------------e",
"---------------f": "---------------f",
"---------------g": "---------------g",
"more":"更多",
"personSet":"个人设置",
"---------------h": "---------------h",
"---------------i": "---------------i",
"---------------j": "---------------j",
"pointAnalyse": "监测点分析",
"pointManage": "监测点管理",
"pointType": "监测点类型",
"pointPaint":"监测点配置图",
"machineRoom": "机房管理",
"machineRoomDetail": "机房详情",
"end": "结束",
"roleManage": "角色管理",
"---------------k": "---------------k",
"start": "开始",
"---------------l": "---------------l",
"historyData": "历史数据",
"type": "类型",
"---------------m": "---------------m",
"name": "名称",
"moduleManage": "模块管理",
"description": "描述",
"---------------n": "---------------n",
"---------------o": "---------------o",
"---------------p": "---------------p",
"channelTopic": "配置模板管理",
"moduleCenter": "配置中心",
"---------------q": "---------------q",
"remove": "清除",
"confirm": "确认",
"cancel":"取消",
"areaManage":"产线管理",
"cuttingMachine": "切削机管理",
"cuttingMachineDetail": "切削机详情",
"---------------r": "---------------r",
"---------------s": "---------------s",
"deviceManage": "设备管理",
"deviceType": "传感器类型",
"deviceModel": "设备型号",
"delete": "删除",
"time": "时间",
"data": "数据",
"compare": "数据对比",
"dataManage": "数据管理",
"actualData": "实时数据",
"all": "所有",
"home":"首页",
"---------------t": "---------------t",
"loginOut":"退出",
"partManage": "通道模板管理",
"condition": "条件",
"---------------u": "---------------u",
"---------------v": "---------------v",
"---------------w": "---------------w",
"gatewayManage": "网关管理",
"---------------x": "---------------x",
"index": "序号",
"detail":"详情",
"systemSet": "系统设置",
"add": "新增",
"adr": "地址",
"---------------y": "---------------y",
"user": "用户",
"userManage": "后台用户管理",
"warnInfo": "预警信息",
"warnNew": "预警新增",
"warnEdit": "预警编辑",
"---------------z": "---------------z",
"status": "状态",
"subjectManage": "主题模板管理",
"---------------else": "---------------else",
"xdkDetail": "XDK传感器",
"cissDetail": "CISS传感器"
}
This diff is collapsed.
This diff is collapsed.
......@@ -3,7 +3,9 @@
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
production: false,
baseUrl: 'http://172.16.1.23:8092', // 对外访问测试网地址
imgUrl: 'http://172.16.1.23' // 图片地址
};
/*
......
/* You can add global styles to this file, and also import other style files */
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment