Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 会话过期退出登录 #1042

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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