11import _ from 'lodash-es' ;
2- import jQuery from 'jquery' ;
32import { View , ViewAction } from '@app/model' ;
43import { fromEvent , Subscription } from 'rxjs' ;
4+ import { I18nService } from '@app/services/i18n' ;
55import { CdkDragDrop , moveItemInArray } from '@angular/cdk/drag-drop' ;
66import {
77 ViewService ,
@@ -60,8 +60,9 @@ export class ElementContentComponent implements OnInit, OnDestroy {
6060
6161 constructor (
6262 public _viewSvc : ViewService ,
63- private _connectTokenSvc : ConnectTokenService ,
63+ private _i18nSvc : I18nService ,
6464 private _settingSvc : SettingService ,
65+ private _connectTokenSvc : ConnectTokenService ,
6566 private _drawerStateService : DrawerStateService
6667 ) { }
6768
@@ -116,9 +117,20 @@ export class ElementContentComponent implements OnInit, OnDestroy {
116117 onNewView ( view ) {
117118 this . scrollEnd ( ) ;
118119 this . toggleMenu . emit ( ) ;
119- setTimeout ( ( ) => {
120- this . _viewSvc . addView ( view ) ;
121- this . setViewActive ( view ) ;
120+
121+ setTimeout ( async ( ) => {
122+ // 如果已经打开了 15 个,那么弹出一个确认框,点击确认重新再一个新的浏览器 tab 下打开 luna 应用
123+ if ( this . viewList . length >= 15 ) {
124+ const msg = await this . _i18nSvc . t ( 'tabLimits' ) ;
125+ const ok = window . confirm ( msg ) ;
126+
127+ if ( ok ) {
128+ window . open ( window . location . href , '_blank' ) ;
129+ }
130+ } else {
131+ this . _viewSvc . addView ( view ) ;
132+ this . setViewActive ( view ) ;
133+ }
122134 } , 100 ) ;
123135 }
124136
@@ -208,16 +220,26 @@ export class ElementContentComponent implements OnInit, OnDestroy {
208220 {
209221 title : 'Clone Connect' ,
210222 icon : 'fa-copy' ,
211- callback : ( ) => {
223+ callback : async ( ) => {
212224 const id = this . rIdx + 1 ;
213225 const oldId = this . viewIds [ this . rIdx ] ;
214226 const oldView = this . viewList . find ( i => i . id === oldId ) ;
215227 const oldConnectToken = oldView . connectToken ;
216- this . _connectTokenSvc . exchange ( oldConnectToken ) . then ( newConnectToken => {
217- const newView = new View ( oldView . asset , oldView . connectData , newConnectToken ) ;
218- this . _viewSvc . addView ( newView ) ;
219- this . setViewActive ( newView ) ;
220- } ) ;
228+
229+ if ( this . viewList . length >= 15 ) {
230+ const msg = await this . _i18nSvc . t ( 'tabLimits' ) ;
231+ const ok = window . confirm ( msg ) ;
232+
233+ if ( ok ) {
234+ window . open ( window . location . href , '_blank' ) ;
235+ }
236+ } else {
237+ this . _connectTokenSvc . exchange ( oldConnectToken ) . then ( newConnectToken => {
238+ const newView = new View ( oldView . asset , oldView . connectData , newConnectToken ) ;
239+ this . _viewSvc . addView ( newView ) ;
240+ this . setViewActive ( newView ) ;
241+ } ) ;
242+ }
221243 }
222244 } ,
223245 {
@@ -227,7 +249,7 @@ export class ElementContentComponent implements OnInit, OnDestroy {
227249 const viewId = this . viewIds [ this . rIdx ] ;
228250 const currentView = this . viewList . find ( i => i . id === viewId ) ;
229251 this . _drawerStateService . sendComponentMessage ( {
230- name : 'DRAWER_RECONNECT' ,
252+ name : 'DRAWER_RECONNECT'
231253 } ) ;
232254 currentView . termComp . reconnect ( ) ;
233255 }
0 commit comments