Skip to content

Commit

Permalink
fix: 会话过期退出登录
Browse files Browse the repository at this point in the history
  • Loading branch information
feng626 authored and BaiJiangJie committed Dec 29, 2023
1 parent 7f65d2b commit e603e26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/pages/main/main.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, ElementRef, HostListener, OnInit, ViewChild} from '@angular/core';
import {DataStore, User} from '@app/globals';
import {DataStore, DEFAULT_ORG_ID, SYSTEM_ORG_ID, User} from '@app/globals';
import {IOutputData, SplitComponent} from 'angular-split';
import {LogService, SettingService, ViewService} from '@app/services';
import * as _ from 'lodash';
Expand All @@ -19,6 +19,7 @@ export class PageMainComponent implements OnInit {
showIframeHider = false;
showSubMenu: any = false;
menus: Array<object>;
isDirectNavigation: boolean;
settingLayoutSize = {
leftWidth: 20,
rightWidth: 80
Expand Down Expand Up @@ -87,6 +88,9 @@ export class PageMainComponent implements OnInit {

ngOnInit(): void {
console.log('main init');
this._settingSvc.isDirectNavigation$.subscribe((state) => {
this.isDirectNavigation = state;
});
this.menus = [
{
name: 'assets',
Expand Down Expand Up @@ -140,9 +144,10 @@ export class PageMainComponent implements OnInit {

@HostListener('window:beforeunload', ['$event'])
unloadNotification($event: any) {
if (!environment.production) {
if (!environment.production || this.isDirectNavigation) {
return;
}

const notInIframe = window.self === window.top;
const notInReplay = location.pathname.indexOf('/luna/replay') === -1;
const returnValue = !(notInIframe && notInReplay);
Expand Down
1 change: 1 addition & 0 deletions src/app/services/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class AppService {
if (currentTimeStamp >= parseInt(sessionExpireTimestamp, 10)) {
confirm(this._i18n.instant('LoginExpireMsg'));
if (!this.newLoginHasOpen) {
this._settingSvc.isDirectNavigation$.next(true);
window.location.href = document.location.origin + '/core/auth/logout/';
this.newLoginHasOpen = true;
}
Expand Down
1 change: 1 addition & 0 deletions src/app/services/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class SettingService {
public isLoadTreeAsync$ = new BehaviorSubject<boolean>(true);
public appletConnectMethod$ = new BehaviorSubject<string>('');
public keyboardLayout$ = new BehaviorSubject<string>('');
public isDirectNavigation$ = new BehaviorSubject<boolean>(false);


constructor(
Expand Down

0 comments on commit e603e26

Please sign in to comment.