mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-28 21:23:01 +00:00
Compare commits
2 commits
1ae1c16132
...
c0821672c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0821672c2 | ||
|
|
791ca3cf8d |
4 changed files with 49 additions and 5 deletions
|
|
@ -47,10 +47,20 @@
|
||||||
</a-select-option>
|
</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label='{{ i18n "pages.xray.outbound.server" }}' v-if="nordModal.servers.length > 0">
|
<a-form-item label='{{ i18n "pages.xray.outbound.city" }}' v-if="nordModal.cities.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 nordModal.servers" :key="s.id" :value="s.id">
|
<a-select-option v-for="s in filteredServers" :key="s.id" :value="s.id">
|
||||||
[[ s.name ]] ({{ i18n "pages.xray.outbound.load" }}: [[ s.load ]]%)
|
[[ s.cityName ]] - [[ 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>
|
||||||
|
|
@ -78,6 +88,8 @@
|
||||||
manualKey: '',
|
manualKey: '',
|
||||||
countries: [],
|
countries: [],
|
||||||
countryId: null,
|
countryId: null,
|
||||||
|
cities: [],
|
||||||
|
cityId: null,
|
||||||
servers: [],
|
servers: [],
|
||||||
serverId: null,
|
serverId: null,
|
||||||
show() {
|
show() {
|
||||||
|
|
@ -129,8 +141,10 @@
|
||||||
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);
|
||||||
},
|
},
|
||||||
|
|
@ -143,11 +157,31 @@
|
||||||
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);
|
||||||
this.servers = (data.servers || []).sort((a, b) => a.load - b.load);
|
const locations = data.locations || [];
|
||||||
|
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');
|
||||||
}
|
}
|
||||||
|
|
@ -248,6 +282,12 @@
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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=10&filters[servers_technologies][id]=35&filters[country_id]=%s", countryId)
|
url := fmt.Sprintf("https://api.nordvpn.com/v2/servers?limit=0&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
|
||||||
|
|
|
||||||
|
|
@ -539,6 +539,8 @@
|
||||||
"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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -536,6 +536,8 @@
|
||||||
"accessToken" = "访问令牌"
|
"accessToken" = "访问令牌"
|
||||||
"country" = "国家"
|
"country" = "国家"
|
||||||
"server" = "服务器"
|
"server" = "服务器"
|
||||||
|
"city" = "城市"
|
||||||
|
"allCities" = "所有城市"
|
||||||
"privateKey" = "私钥"
|
"privateKey" = "私钥"
|
||||||
"load" = "负载"
|
"load" = "负载"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue