Compare commits

..

No commits in common. "c0821672c2a5a82fe7e715a222292cae4f6ad838" and "1ae1c16132055ebaadf4dd1693ee374e5b249073" have entirely different histories.

4 changed files with 5 additions and 49 deletions

View file

@ -47,20 +47,10 @@
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label='{{ i18n "pages.xray.outbound.city" }}' v-if="nordModal.cities.length > 0"> <a-form-item label='{{ i18n "pages.xray.outbound.server" }}' v-if="nordModal.servers.length > 0">
<a-select v-model="nordModal.cityId" show-search option-filter-prop="label">
<a-select-option :key="0" :value="null" label='{{ i18n "pages.xray.outbound.allCities" }}'>
{{ i18n "pages.xray.outbound.allCities" }}
</a-select-option>
<a-select-option v-for="c in nordModal.cities" :key="c.id" :value="c.id" :label="c.name">
[[ c.name ]]
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label='{{ i18n "pages.xray.outbound.server" }}' v-if="filteredServers.length > 0">
<a-select v-model="nordModal.serverId"> <a-select v-model="nordModal.serverId">
<a-select-option v-for="s in filteredServers" :key="s.id" :value="s.id"> <a-select-option v-for="s in nordModal.servers" :key="s.id" :value="s.id">
[[ s.cityName ]] - [[ s.name ]] ({{ i18n "pages.xray.outbound.load" }}: [[ s.load ]]%) [[ s.name ]] ({{ i18n "pages.xray.outbound.load" }}: [[ s.load ]]%)
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
@ -88,8 +78,6 @@
manualKey: '', manualKey: '',
countries: [], countries: [],
countryId: null, countryId: null,
cities: [],
cityId: null,
servers: [], servers: [],
serverId: null, serverId: null,
show() { show() {
@ -141,10 +129,8 @@
this.token = ''; this.token = '';
this.manualKey = ''; this.manualKey = '';
this.countries = []; this.countries = [];
this.cities = [];
this.servers = []; this.servers = [];
this.countryId = null; this.countryId = null;
this.cityId = null;
} }
this.loading(false); this.loading(false);
}, },
@ -157,31 +143,11 @@
async fetchServers() { async fetchServers() {
this.loading(true); this.loading(true);
this.servers = []; this.servers = [];
this.cities = [];
this.serverId = null; this.serverId = null;
this.cityId = null;
const msg = await HttpUtil.post('/panel/xray/nord/servers', { countryId: this.countryId }); const msg = await HttpUtil.post('/panel/xray/nord/servers', { countryId: this.countryId });
if (msg.success) { if (msg.success) {
const data = JSON.parse(msg.obj); const data = JSON.parse(msg.obj);
const locations = data.locations || []; this.servers = (data.servers || []).sort((a, b) => a.load - b.load);
const locToCity = {};
const citiesMap = new Map();
locations.forEach(loc => {
if (loc.country && loc.country.city) {
citiesMap.set(loc.country.city.id, loc.country.city);
locToCity[loc.id] = loc.country.city;
}
});
this.cities = Array.from(citiesMap.values()).sort((a, b) => a.name.localeCompare(b.name));
this.servers = (data.servers || []).map(s => {
const firstLocId = (s.location_ids || [])[0];
const city = locToCity[firstLocId];
s.cityId = city ? city.id : null;
s.cityName = city ? city.name : 'Unknown';
return s;
}).sort((a, b) => a.load - b.load);
if (this.servers.length === 0) { if (this.servers.length === 0) {
app.$message.warning('No servers found for the selected country'); app.$message.warning('No servers found for the selected country');
} }
@ -282,12 +248,6 @@
get: function () { get: function () {
return app.templateSettings ? app.templateSettings.outbounds.findIndex((o) => o.tag.startsWith("nord-")) : -1; return app.templateSettings ? app.templateSettings.outbounds.findIndex((o) => o.tag.startsWith("nord-")) : -1;
} }
},
filteredServers: function() {
if (!this.nordModal.cityId) {
return this.nordModal.servers;
}
return this.nordModal.servers.filter(s => s.cityId === this.nordModal.cityId);
} }
} }
}); });

View file

@ -28,7 +28,7 @@ func (s *NordService) GetCountries() (string, error) {
} }
func (s *NordService) GetServers(countryId string) (string, error) { func (s *NordService) GetServers(countryId string) (string, error) {
url := fmt.Sprintf("https://api.nordvpn.com/v2/servers?limit=0&filters[servers_technologies][id]=35&filters[country_id]=%s", countryId) url := fmt.Sprintf("https://api.nordvpn.com/v2/servers?limit=10&filters[servers_technologies][id]=35&filters[country_id]=%s", countryId)
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil { if err != nil {
return "", err return "", err

View file

@ -539,8 +539,6 @@
"accessToken" = "Access Token" "accessToken" = "Access Token"
"country" = "Country" "country" = "Country"
"server" = "Server" "server" = "Server"
"city" = "City"
"allCities" = "All Cities"
"privateKey" = "Private Key" "privateKey" = "Private Key"
"load" = "Load" "load" = "Load"

View file

@ -536,8 +536,6 @@
"accessToken" = "访问令牌" "accessToken" = "访问令牌"
"country" = "国家" "country" = "国家"
"server" = "服务器" "server" = "服务器"
"city" = "城市"
"allCities" = "所有城市"
"privateKey" = "私钥" "privateKey" = "私钥"
"load" = "负载" "load" = "负载"