Skip to content

Commit 68e3760

Browse files
committed
feat: auto-select best server on country/city change
1 parent c082167 commit 68e3760

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

web/html/modals/nord_modal.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</a-select>
4949
</a-form-item>
5050
<a-form-item label='{{ i18n "pages.xray.outbound.city" }}' v-if="nordModal.cities.length > 0">
51-
<a-select v-model="nordModal.cityId" show-search option-filter-prop="label">
51+
<a-select v-model="nordModal.cityId" @change="onCityChange" show-search option-filter-prop="label">
5252
<a-select-option :key="0" :value="null" label='{{ i18n "pages.xray.outbound.allCities" }}'>
5353
{{ i18n "pages.xray.outbound.allCities" }}
5454
</a-select-option>
@@ -182,6 +182,10 @@
182182
return s;
183183
}).sort((a, b) => a.load - b.load);
184184

185+
if (this.servers.length > 0) {
186+
this.serverId = this.servers[0].id;
187+
}
188+
185189
if (this.servers.length === 0) {
186190
app.$message.warning('No servers found for the selected country');
187191
}
@@ -276,6 +280,13 @@
276280
fetchServers: () => nordModal.fetchServers(),
277281
addOutbound: () => nordModal.addOutbound(),
278282
resetOutbound() { nordModal.resetOutbound(this.nordOutboundIndex) },
283+
onCityChange() {
284+
if (this.filteredServers.length > 0) {
285+
this.nordModal.serverId = this.filteredServers[0].id;
286+
} else {
287+
this.nordModal.serverId = null;
288+
}
289+
}
279290
},
280291
computed: {
281292
nordOutboundIndex: {

0 commit comments

Comments
 (0)