Commit 5adf0760 by 杨子

增加退出接口

parent 42bdf35e
{ {
"/asset/*": { "/asset/*": {
"target": "http://localhost:8081", "target": "http://192.168.19.171:8082",
"secure": false, "secure": false,
"logLevel": "debug", "logLevel": "debug",
"changeOrigin": true "changeOrigin": true
......
import { Component, OnInit } from "@angular/core"; import { Component, OnInit, Inject } from "@angular/core";
import { Router } from "@angular/router"; import { Router } from "@angular/router";
import { APIService } from "src/app/service/layout/service/api.service";
import { SocialService, ITokenService, DA_SERVICE_TOKEN } from "@delon/auth";
@Component({ @Component({
selector: "app-user", selector: "app-user",
templateUrl: "./user.component.html", templateUrl: "./user.component.html",
...@@ -9,13 +11,22 @@ export class UserComponent implements OnInit { ...@@ -9,13 +11,22 @@ export class UserComponent implements OnInit {
data = []; data = [];
currentArr = []; // 收起 currentArr = []; // 收起
remainArr = []; //更多 remainArr = []; //更多
constructor(private router: Router) {} constructor(
private router: Router,
@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService,
private apiSrv: APIService
) {}
ngOnInit() {} ngOnInit() {}
jumpPassword() { jumpPassword() {
this.router.navigateByUrl("/admin/user/password"); this.router.navigateByUrl("/admin/user/password");
} }
logout() { logout() {
this.router.navigateByUrl("/passport/login"); this.apiSrv.logout().subscribe((r: any) => {
if (r.success == "1") {
this.tokenService.clear();
this.router.navigateByUrl("/passport/login");
}
});
} }
} }
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<a Button [type]="'primary'" [size]="'large'" (onClick)="submit()"> <a Button [type]="'primary'" [size]="'large'" (onClick)="submit()">
登录 登录
</a> </a>
</ListItem> </ListItem>
</List> </List>
</form> </form>
\ No newline at end of file
...@@ -6,6 +6,7 @@ import { HttpClient } from "@angular/common/http"; ...@@ -6,6 +6,7 @@ import { HttpClient } from "@angular/common/http";
import { catchError } from "rxjs/operators"; import { catchError } from "rxjs/operators";
import { of } from "rxjs"; import { of } from "rxjs";
import { StartupService } from "../../service/startup.service"; import { StartupService } from "../../service/startup.service";
import { APIService } from "src/app/service/layout/service/api.service";
@Component({ @Component({
selector: "passport-login", selector: "passport-login",
...@@ -23,7 +24,8 @@ export class UserLoginComponent { ...@@ -23,7 +24,8 @@ export class UserLoginComponent {
private socialService: SocialService, private socialService: SocialService,
@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService, @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService,
private startupSrv: StartupService, private startupSrv: StartupService,
private http: HttpClient private http: HttpClient,
private apiSrv: APIService
) { ) {
this.form = fb.group({ this.form = fb.group({
userName: [null, [Validators.required, Validators.minLength(4)]], userName: [null, [Validators.required, Validators.minLength(4)]],
...@@ -44,7 +46,6 @@ export class UserLoginComponent { ...@@ -44,7 +46,6 @@ export class UserLoginComponent {
// #endregion // #endregion
submit() { submit() {
document.cookie = "";
this.error = ""; this.error = "";
console.log(this.form.value); console.log(this.form.value);
// 默认配置中对所有HTTP请求都会强制 [校验](https://ng-alain.com/auth/getting-started) 用户 Token // 默认配置中对所有HTTP请求都会强制 [校验](https://ng-alain.com/auth/getting-started) 用户 Token
...@@ -79,7 +80,7 @@ export class UserLoginComponent { ...@@ -79,7 +80,7 @@ export class UserLoginComponent {
this.startupSrv.load().then(() => { this.startupSrv.load().then(() => {
let url = this.tokenService.referrer!.url || "/"; let url = this.tokenService.referrer!.url || "/";
if (url.includes("/passport")) url = "/"; if (url.includes("/passport")) url = "/";
this.router.navigateByUrl(url); this.router.navigateByUrl("/admin");
}); });
}, },
error => { error => {
......
<div class="result-example"> <div class="result-example">
<Result [img]="img1" [message]="message1" [title]="'已完成'"> <Result [img]="img1" [message]="message1" [title]=" isSuccess?'成功':'失败'" [buttonText]="'继续盘点'" [buttonType]="'primary'"
(onButtonClick)="onclick()">
<ng-template #img1> <ng-template #img1>
<Icon class="spe" [type]="'check-circle'" [color]="'#1F90E6'"></Icon> <Icon class="spe" [type]="isSuccess?'check-circle':'cross-circle-o'" [color]=" isSuccess?'#1F90E6':'#F13642'">
</Icon>
</ng-template> </ng-template>
<ng-template #message1> <ng-template #message1>
<div></div> <div>{{msg}}</div>
</ng-template> </ng-template>
</Result> </Result>
</div> </div>
\ No newline at end of file
...@@ -8,3 +8,8 @@ ...@@ -8,3 +8,8 @@
height: 60px; height: 60px;
display: block; display: block;
} }
:host /deep/ .am-result .am-result-title {
font-size: 21px !important;
color: #000 !important;
}
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
@Component({ @Component({
selector: 'app-check-result', selector: "app-check-result",
templateUrl: './check-result.component.html', templateUrl: "./check-result.component.html",
styleUrls: ['./check-result.component.scss'], styleUrls: ["./check-result.component.scss"]
}) })
export class CheckResultComponent implements OnInit { export class CheckResultComponent implements OnInit {
isSuccess: boolean;
msg = "";
constructor(private activeRoute: ActivatedRoute, private router: Router) {}
constructor() { } ngOnInit() {
this.isSuccess = this.activeRoute.snapshot.queryParams["isSuccess"];
ngOnInit() {} this.msg = this.activeRoute.snapshot.queryParams["msg"];
}
onclick() {
this.router.navigateByUrl("/admin");
}
} }
...@@ -32,7 +32,7 @@ export class QrScanComponent implements OnInit, OnDestroy { ...@@ -32,7 +32,7 @@ export class QrScanComponent implements OnInit, OnDestroy {
} }
loadingToast(id) { loadingToast(id) {
const toast = Toast.loading("Loading...", 1000, () => { const toast = Toast.loading("Loading...", 1000, () => {
this.router.navigate(["/admin/assets-used/checkPlanAdd", id]); this.router.navigate(["/admin/assets-used/checkPlanAdd", id, ""]);
}); });
} }
ngOnDestroy() { ngOnDestroy() {
......
...@@ -64,6 +64,8 @@ const CheckSave = "asset/a/asset/checkPlan/save/result"; ...@@ -64,6 +64,8 @@ const CheckSave = "asset/a/asset/checkPlan/save/result";
const Upload = "asset/a/sys/file/webupload/upload"; const Upload = "asset/a/sys/file/webupload/upload";
const assetsUrl = "asset/a/asset/checkPlan/infoData"; const assetsUrl = "asset/a/asset/checkPlan/infoData";
const logoutUrl = "asset/a/logout";
@Injectable({ @Injectable({
providedIn: "root" providedIn: "root"
}) })
...@@ -270,4 +272,8 @@ export class APIService { ...@@ -270,4 +272,8 @@ export class APIService {
getAssets(param, id) { getAssets(param, id) {
return this.basePost(assetsUrl + "/?id=" + id, param); return this.basePost(assetsUrl + "/?id=" + id, param);
} }
logout() {
return this.http.get(logoutUrl + "?__ajax=true");
}
} }
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