1+ import { SettingService } from '@app/services' ;
2+ import { resolutionsChoices } from '@app/globals' ;
13import { Component , Input , OnChanges , OnInit } from '@angular/core' ;
24import { ConnectMethod , ConnectOption , GlobalSetting , Protocol , Setting } from '@app/model' ;
3- import { resolutionsChoices } from '@app/globals' ;
4- import { SettingService } from '@app/services' ;
55
66@Component ( {
77 standalone : false ,
@@ -13,20 +13,33 @@ export class ElementAdvancedOptionComponent implements OnChanges, OnInit {
1313 @Input ( ) protocol : Protocol ;
1414 @Input ( ) connectMethod : ConnectMethod ;
1515 @Input ( ) connectOption : any = { } ;
16- public advancedOptions : ConnectOption [ ] = [ ] ;
16+
1717 public isShowAdvancedOption = false ;
18- public setting : Setting ;
19- public globalSetting : GlobalSetting ;
20- private allOptions : ConnectOption [ ] = [ ] ;
2118 private boolChoices = [
2219 { label : 'Yes' , value : true } ,
2320 { label : 'No' , value : false }
2421 ] ;
2522
23+ public setting : Setting ;
24+ public globalSetting : GlobalSetting ;
25+ private allOptions : ConnectOption [ ] = [ ] ;
26+ public advancedOptions : ConnectOption [ ] = [ ] ;
27+
2628 constructor ( public _settingSvc : SettingService ) {
2729 this . setting = _settingSvc . setting ;
2830 this . globalSetting = _settingSvc . globalSetting ;
29- this . allOptions = [
31+ }
32+
33+ ngOnInit ( ) {
34+ this . allOptions = this . buildAllOptions ( ) ;
35+ this . checkOptions ( ) ;
36+ }
37+
38+ buildAllOptions ( ) : ConnectOption [ ] {
39+ const gs = this . _settingSvc . globalSetting ;
40+ const hasX = this . _settingSvc . hasXPack ?.( ) ?? false ;
41+
42+ return [
3043 {
3144 type : 'select' ,
3245 field : 'charset' ,
@@ -109,9 +122,7 @@ export class ElementAdvancedOptionComponent implements OnChanges, OnInit {
109122 field : 'appletConnectMethod' ,
110123 options : [
111124 { label : 'Web' , value : 'web' } ,
112- ...( this . globalSetting . TERMINAL_RAZOR_ENABLED
113- ? [ { label : 'Client' , value : 'client' } ]
114- : [ ] )
125+ ...( gs . TERMINAL_RAZOR_ENABLED ? [ { label : 'Client' , value : 'client' } ] : [ ] )
115126 ] ,
116127 label : 'Applet connect method' ,
117128 value : this . setting . graphics . applet_connection_method ,
@@ -132,31 +143,36 @@ export class ElementAdvancedOptionComponent implements OnChanges, OnInit {
132143 label : 'Virtualapp connect method' ,
133144 value : this . setting . graphics . applet_connection_method ,
134145 hidden : ( ) => {
135- if ( ! this . _settingSvc . hasXPack ( ) ) {
136- return true ;
137- }
146+ if ( ! hasX ) return true ;
138147 return ! this . connectMethod || this . connectMethod . component !== 'panda' ;
139148 }
140149 } ,
141150 {
142151 type : 'select' ,
143152 field : 'reusable' ,
144153 options : this . boolChoices ,
145- label : 'RDP file reusable' ,
154+ label : ' RDP file reusable' ,
146155 value : false ,
147156 hidden : ( ) => {
148- if ( ! this . connectMethod ) {
149- return true ;
150- }
151- if ( ! this . _settingSvc . globalSetting . CONNECTION_TOKEN_REUSABLE ) {
152- return true ;
153- }
154- if ( this . connectMethod . component === 'razor' ) {
155- return false ;
156- }
157+ if ( ! this . connectMethod ) return true ;
158+ if ( ! gs . CONNECTION_TOKEN_REUSABLE ) return true ;
159+
160+ // razor 直接显示
161+ if ( this . connectMethod . component === 'razor' ) return false ;
162+
157163 if ( this . connectMethod . component === 'tinker' ) {
158- return this . connectOption . appletConnectMethod !== 'client' ;
164+ const method = (
165+ this . connectOption . appletConnectMethod ??
166+ this . connectOption . virtualappConnectMethod ??
167+ this . setting . graphics . applet_connection_method ??
168+ ''
169+ )
170+ . toString ( )
171+ . toLowerCase ( ) ;
172+
173+ return method !== 'client' ;
159174 }
175+
160176 return true ;
161177 }
162178 } ,
@@ -177,32 +193,37 @@ export class ElementAdvancedOptionComponent implements OnChanges, OnInit {
177193 ] ;
178194 }
179195
180- ngOnInit ( ) {
181- this . checkOptions ( ) ;
182- }
183-
184196 checkOptions ( ) {
185197 if ( ! this . protocol ) {
186198 return ;
187199 }
200+
188201 const onlyUsingDefaultFields = [ 'reusable' ] ;
202+
189203 this . allOptions . forEach ( i => {
190204 if ( this . connectOption [ i . field ] === undefined ) {
191205 this . connectOption [ i . field ] = i . value ;
192206 }
207+
193208 if ( onlyUsingDefaultFields . includes ( i . field ) ) {
194209 i . value = this . connectOption [ i . field ] ;
195210 }
196211 } ) ;
212+
197213 this . advancedOptions = this . allOptions . filter ( i => ! i . hidden ( ) ) ;
198214 this . isShowAdvancedOption = this . advancedOptions . length > 0 ;
215+
216+ console . log ( 'advancedOptions' , this . advancedOptions ) ;
217+ console . log ( 'isShowAdvancedOption' , this . isShowAdvancedOption ) ;
199218 }
200219
201220 onChange ( ) {
221+ this . allOptions = this . buildAllOptions ( ) ;
202222 this . checkOptions ( ) ;
203223 }
204224
205225 ngOnChanges ( ) {
226+ this . allOptions = this . buildAllOptions ( ) ;
206227 this . checkOptions ( ) ;
207228 }
208229}
0 commit comments