Skip to content

Commit

Permalink
Merge pull request #688 from jumpserver/dev
Browse files Browse the repository at this point in the history
v2.26.0-rc2
  • Loading branch information
BaiJiangJie committed Sep 13, 2022
2 parents 8462203 + f65058f commit 043258b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 35 deletions.
17 changes: 3 additions & 14 deletions src/app/pages/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component, HostListener} from '@angular/core';
import {I18nService, ViewService} from '@app/services';
import {Component} from '@angular/core';
import {I18nService} from '@app/services';

@Component({
selector: 'app-root',
Expand All @@ -8,18 +8,7 @@ import {I18nService, ViewService} from '@app/services';
})

export class AppComponent {
constructor(_i18n: I18nService,
public viewSrv: ViewService
) {}
@HostListener('window:keydown', ['$event'])
onKeyPress($event: KeyboardEvent) {
const condition = this.viewSrv.viewList.length > 1 && $event.shiftKey;
if (condition && $event.keyCode === 37) {
this.viewSrv.switchView('left');
}
if (condition && $event.keyCode === 39) {
this.viewSrv.switchView('right');
}
constructor(_i18n: I18nService) {
}
}

20 changes: 0 additions & 20 deletions src/app/services/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,4 @@ export class ViewService {
const index = this.viewList.indexOf(view);
this.viewList.splice(index, 1);
}

switchView(direction: ('left' | 'right')) {
const viewList = this.viewList;
const viewListLength = viewList.length;
for (let i = 0; i < viewListLength; i++) {
const current: View = viewList[i];
if (current.id === this.currentView.id) {
let nextView: View, nextViewLength: number;
const next: number = direction === 'left' ? i - 1 : i + 1;
if (direction === 'left') {
nextViewLength = next < 0 ? viewListLength - 1 : next;
} else {
nextViewLength = next >= viewListLength ? 0 : next;
}
nextView = viewList[nextViewLength];
if (nextView) { this.activeView(nextView); }
break;
}
}
}
}
6 changes: 5 additions & 1 deletion src/app/utils/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export function encryptPassword(password) {
}
const aesKey = (Math.random() + 1).toString(36).substring(2);
// public key 是 base64 存储的
const rsaPublicKeyText = getCookie('jms_public_key')
let rsaPublicKeyText = getCookie('jms_public_key');
if (!rsaPublicKeyText) {
return password;
}
rsaPublicKeyText = rsaPublicKeyText
.replace('"', '')
.replace('"', '');
const rsaPublicKey = atob(rsaPublicKeyText);
Expand Down

0 comments on commit 043258b

Please sign in to comment.