Skip to content

Commit bfc77c2

Browse files
committed
Fixed: Fix the issue where Select remembers empty content.
1 parent 87c2edd commit bfc77c2

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

src/app/elements/connect/connect-dialog/advanced-option/advanced-option.component.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,10 @@ export class ElementAdvancedOptionComponent implements OnChanges, OnInit {
156156
hidden: () => {
157157
if (!this.connectMethod) return true;
158158
if (!gs.CONNECTION_TOKEN_REUSABLE) return true;
159-
160-
// razor 直接显示
161159
if (this.connectMethod.component === 'razor') return false;
162160

163161
if (this.connectMethod.component === 'tinker') {
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';
162+
return this.connectOption.appletConnectMethod !== 'client';
174163
}
175164

176165
return true;
@@ -212,6 +201,26 @@ export class ElementAdvancedOptionComponent implements OnChanges, OnInit {
212201

213202
this.advancedOptions = this.allOptions.filter(i => !i.hidden());
214203
this.isShowAdvancedOption = this.advancedOptions.length > 0;
204+
205+
// 如果记住的 select 值已不在可选项中,回退到 web 或默认值
206+
this.advancedOptions
207+
.filter(i => i.type === 'select')
208+
.forEach(i => {
209+
const options = i.options || [];
210+
const values = new Set(options.map(opt => opt.value));
211+
const current = this.connectOption[i.field];
212+
213+
if (!values.has(current)) {
214+
let fallback: any = 'web';
215+
216+
if (!values.has(fallback)) {
217+
fallback = i.value !== undefined ? i.value : options[0] ? options[0].value : undefined;
218+
}
219+
if (fallback !== undefined) {
220+
this.connectOption[i.field] = fallback;
221+
}
222+
}
223+
});
215224
}
216225

217226
onChange() {

0 commit comments

Comments
 (0)