|
|
|
import { Component, TemplateRef, ViewChild } from '@angular/core';
|
|
|
|
import { HttpClient } from '@angular/common/http'
|
|
|
|
import { Data } from './interface'
|
|
|
|
import { Router, ActivatedRoute } from '@angular/router'
|
|
|
|
import { CacheTokenService } from './service/cache-token.service'//引入服务
|
|
|
|
import { CookieService } from 'ngx-cookie-service';
|
|
|
|
import "reflect-metadata";
|
|
|
|
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
|
|
|
|
|
|
|
declare var abp:any
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html',
|
|
|
|
styleUrls: ['./app.component.scss']
|
|
|
|
})
|
|
|
|
export class AppComponent {
|
|
|
|
|
|
|
|
@ViewChild(TemplateRef, { static: false }) template?: TemplateRef<{}>;
|
|
|
|
|
|
|
|
constructor(private http: HttpClient, private router: Router, public token: CacheTokenService, private cookieService: CookieService, private notificationService: NzNotificationService) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
// var token = this.cookieService.get("token")
|
|
|
|
// var refreshToken = this.cookieService.get("refreshToken");
|
|
|
|
// if(token && refreshToken) {
|
|
|
|
// this.http.post('/api/CompanyAccount/RefreshToken',{token: token,refreshToken: refreshToken}).subscribe((data: Data) => {
|
|
|
|
// sessionStorage.setItem("token",data.token);
|
|
|
|
// this.cookieService.set("token",data.token,null,'/');
|
|
|
|
// this.cookieService.set("refreshToken",data.refreshToken,null,'/');
|
|
|
|
// this.token.startUp()
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
console.log('abp',abp)
|
|
|
|
}
|
|
|
|
receiptOfNotification() {
|
|
|
|
this.notificationService.template(this.template!, { nzPlacement: 'bottomRight', nzClass: 'receiptOfNotification', nzDuration: 0 });
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messages
|
|
|
|
abp() {
|
|
|
|
let _this = this;
|
|
|
|
|
|
|
|
//手动实现hub
|
|
|
|
//this.hubConnection = new signalR.HubConnectionBuilder()
|
|
|
|
// .withUrl('/signalr-violation',
|
|
|
|
// {
|
|
|
|
// accessTokenFactory: ()=>this.token
|
|
|
|
// }
|
|
|
|
// )
|
|
|
|
// .build();
|
|
|
|
////服务器回调方法
|
|
|
|
//this.hubConnection.on('SendViolation', (data) => {
|
|
|
|
// console.log("SendViolation", data);
|
|
|
|
// _this.messages.push("SendViolation:"+JSON.stringify(data));
|
|
|
|
//});
|
|
|
|
//this.hubConnection.start();
|
|
|
|
|
|
|
|
//abp封装的hub
|
|
|
|
abp.event.on('abp.notifications.received', function (userNotification) {
|
|
|
|
_this.messages.push("abp.notifications.received:" + JSON.stringify(userNotification));
|
|
|
|
console.log('abp.notifications.received', userNotification);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|