Skip to content

Commit

Permalink
Revert "feat: 增加shift+左/右键盘事件切换tabs"
Browse files Browse the repository at this point in the history
This reverts commit c9c5219.
  • Loading branch information
huailei000 authored and BaiJiangJie committed Sep 13, 2022
1 parent 71f72e5 commit f65058f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 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;
}
}
}
}

0 comments on commit f65058f

Please sign in to comment.