11import { Component , EventEmitter , Input , OnDestroy , OnInit , Output } from '@angular/core' ;
2+ import { ElementConnectDialogComponent } from '@app/elements/connect/connect-dialog/connect-dialog.component' ;
23import { connectEvt } from '@app/globals' ;
4+ import { Account , Asset , ConnectData , ConnectionToken , View } from '@app/model' ;
35import {
46 AlertService ,
57 AppService ,
@@ -10,12 +12,10 @@ import {
1012 SettingService ,
1113 ViewService
1214} from '@app/services' ;
13- import { Account , Asset , ConnectData , ConnectionToken , View } from '@app/model' ;
14- import { launchLocalApp } from '@app/utils/common' ;
15- import { ElementConnectDialogComponent } from '@app/elements/connect/connect-dialog/connect-dialog.component' ;
15+ import { launchLocalApp , LOCAL_CLIENT_REMINDER_STORAGE_KEY } from '@app/utils/common' ;
1616import { NzModalService } from 'ng-zorro-antd/modal' ;
17- import { ElementDownloadDialogComponent } from './download-dialog/download-dialog.component' ;
1817import { firstValueFrom } from 'rxjs' ;
18+ import { ElementDownloadDialogComponent } from './download-dialog/download-dialog.component' ;
1919
2020@Component ( {
2121 standalone : false ,
@@ -153,17 +153,6 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
153153 this . _logger . info ( 'Create connection token failed' ) ;
154154 return ;
155155 }
156-
157- // 分屏连接
158- if ( splitConnect ) {
159- return this . currentWebSubView ( asset , connectInfo , connToken ) ;
160- }
161-
162- // 特殊处理
163- if ( connectMethod . value . endsWith ( '_guide' ) ) {
164- return this . createWebView ( asset , connectInfo , connToken ) ;
165- }
166-
167156 let appletConnectMethod = connectOption ? connectOption [ 'appletConnectMethod' ] : 'web' ;
168157
169158 if ( ! this . _settingSvc . hasXPack ( ) ) {
@@ -174,21 +163,30 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
174163 virtualappConnectMethod = 'web' ;
175164 }
176165
166+ const isGuide = connectMethod . value . endsWith ( '_guide' ) ;
167+ const isClientConnect =
168+ connectMethod . type === 'native' ||
169+ ( connectMethod . type === 'applet' && appletConnectMethod === 'client' ) ||
170+ ( connectMethod . type === 'virtual_app' && virtualappConnectMethod === 'client' ) ;
171+ const openWebView = ( ) =>
172+ splitConnect
173+ ? this . currentWebSubView ( asset , connectInfo , connToken )
174+ : this . createWebView ( asset , connectInfo , connToken ) ;
175+
177176 if ( connectInfo . downloadRDP ) {
178177 return this . _http . downloadRDPFile (
179178 connToken ,
180179 this . _settingSvc . setting ,
181180 connectInfo . connectOption
182181 ) ;
183- } else if ( connectMethod . type === 'native' ) {
184- this . callLocalClient ( connToken ) . then ( ) ;
185- } else if ( connectMethod . type === 'applet' && appletConnectMethod === 'client' ) {
186- this . callLocalClient ( connToken ) . then ( ) ;
187- } else if ( connectMethod . type === 'virtual_app' && virtualappConnectMethod === 'client' ) {
182+ }
183+
184+ if ( isClientConnect && ! isGuide ) {
188185 this . callLocalClient ( connToken ) . then ( ) ;
189- } else {
190- this . createWebView ( asset , connectInfo , connToken ) ;
186+ return ;
191187 }
188+
189+ return openWebView ( ) ;
192190 }
193191
194192 async callLocalClient ( connToken : ConnectionToken ) {
@@ -204,20 +202,24 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
204202
205203 const url = response [ 'url' ] ;
206204
207- launchLocalApp ( url , ( ) => {
208- const downLoadStatus = localStorage . getItem ( 'hasDownLoadApp' ) ;
209-
210- if ( downLoadStatus !== '1' ) {
211- this . _dialog . create ( {
212- nzTitle : this . _i18n . instant ( 'DownloadClient' ) ,
213- nzContent : ElementDownloadDialogComponent ,
214- nzOnOk : cmp => cmp . onConfirm ( ) ,
215- nzOnCancel : cmp => cmp . onCancel ( ) ,
216- nzCancelText : this . _i18n . instant ( 'Cancel' ) ,
217- nzOkText : this . _i18n . instant ( 'Confirm' )
218- } ) ;
219- }
220- } ) ;
205+ const localClientLaunched = await launchLocalApp ( url ) ;
206+
207+ if ( localClientLaunched ) {
208+ return ;
209+ }
210+
211+ const ignoreDownloadReminder = localStorage . getItem ( LOCAL_CLIENT_REMINDER_STORAGE_KEY ) ;
212+
213+ if ( ignoreDownloadReminder !== '1' ) {
214+ this . _dialog . create ( {
215+ nzTitle : this . _i18n . instant ( 'DownloadClient' ) ,
216+ nzContent : ElementDownloadDialogComponent ,
217+ nzOnOk : cmp => cmp . onConfirm ( ) ,
218+ nzOnCancel : cmp => cmp . onCancel ( ) ,
219+ nzCancelText : this . _i18n . instant ( 'Cancel' ) ,
220+ nzOkText : this . _i18n . instant ( 'Confirm' )
221+ } ) ;
222+ }
221223 }
222224
223225 createWebView ( asset : Asset , connectInfo : any , connToken : ConnectionToken ) {
0 commit comments