Skip to content

Commit b4a1d81

Browse files
MHSanaeialireza0
andcommitted
[subJson] better direct options
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
1 parent 46ef506 commit b4a1d81

File tree

1 file changed

+57
-46
lines changed

1 file changed

+57
-46
lines changed

web/html/xui/settings.html

+57-46
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,40 @@
382382
</a-col>
383383
</a-row>
384384
<a-collapse v-if="enableDirect" style="margin-top: 14px;">
385-
<a-collapse-panel header='{{ i18n "pages.xray.directips"}}'>
386-
<a-list-item style="padding: 10px 20px">
387-
<a-checkbox-group v-model="directIPs" :options="IPsOptions"></a-checkbox-group>
385+
<a-collapse-panel header='{{ i18n "pages.settings.direct"}}'>
386+
<a-list-item>
387+
<a-row style="padding: 0 20px">
388+
<a-col :lg="24" :xl="12">
389+
<a-list-item-meta
390+
title='{{ i18n "pages.xray.directips" }}'/>
391+
</a-col>
392+
<a-col :lg="24" :xl="12">
393+
<a-select mode="tags" style="width: 100%"
394+
v-model="directIPs"
395+
:dropdown-class-name="themeSwitcher.currentTheme">
396+
<a-select-option :value="p.value" :label="p.label"
397+
v-for="p in directIPsOptions"> [[ p.label ]]
398+
</a-select-option>
399+
</a-select>
400+
</a-col>
401+
</a-row>
388402
</a-list-item>
389-
</a-collapse-panel>
390-
<a-collapse-panel header='{{ i18n "pages.xray.directdomains"}}'>
391-
<a-list-item style="padding: 10px 20px">
392-
<a-checkbox-group v-model="directDomains" :options="DomainsOptions"></a-checkbox-group>
403+
<a-list-item>
404+
<a-row style="padding: 0 20px">
405+
<a-col :lg="24" :xl="12">
406+
<a-list-item-meta
407+
title='{{ i18n "pages.xray.directdomains" }}'/>
408+
</a-col>
409+
<a-col :lg="24" :xl="12">
410+
<a-select mode="tags" style="width: 100%"
411+
v-model="directDomains"
412+
:dropdown-class-name="themeSwitcher.currentTheme">
413+
<a-select-option :value="p.value" :label="p.label"
414+
v-for="p in diretDomainsOptions"> [[ p.label ]]
415+
</a-select-option>
416+
</a-select>
417+
</a-col>
418+
</a-row>
393419
</a-list-item>
394420
</a-collapse-panel>
395421
</a-collapse>
@@ -477,25 +503,26 @@
477503
]
478504
},
479505
],
480-
IPsOptions: [
481-
{ label: 'Private IP', value: 'private' },
482-
{ label: '🇮🇷 Iran', value: 'ir' },
483-
{ label: '🇨🇳 China', value: 'cn' },
484-
{ label: '🇷🇺 Russia', value: 'ru' },
485-
{ label: '🇻🇳 Vietnam', value: 'vn' },
486-
{ label: '🇪🇸 Spain', value: 'es' },
487-
{ label: '🇮🇩 Indonesia', value: 'id' },
488-
{ label: '🇺🇦 Ukraine', value: 'ua' },
489-
{ label: '🇹🇷 Türkiye', value: 'tr' },
490-
{ label: '🇧🇷 Brazil', value: 'br' },
506+
directIPsOptions: [
507+
{ label: 'Private IP', value: 'geoip:private' },
508+
{ label: '🇮🇷 Iran', value: 'geoip:ir' },
509+
{ label: '🇨🇳 China', value: 'geoip:cn' },
510+
{ label: '🇷🇺 Russia', value: 'geoip:ru' },
511+
{ label: '🇻🇳 Vietnam', value: 'geoip:vn' },
512+
{ label: '🇪🇸 Spain', value: 'geoip:es' },
513+
{ label: '🇮🇩 Indonesia', value: 'geoip:id' },
514+
{ label: '🇺🇦 Ukraine', value: 'geoip:ua' },
515+
{ label: '🇹🇷 Türkiye', value: 'geoip:tr' },
516+
{ label: '🇧🇷 Brazil', value: 'geoip:br' },
491517
],
492-
DomainsOptions: [
493-
{ label: '🇮🇷 Iran', value: 'ir' },
494-
{ label: '🇨🇳 China', value: 'cn' },
495-
{ label: '🇷🇺 Russia', value: 'ru' },
496-
{ label: 'Apple', value: 'apple' },
497-
{ label: 'Meta', value: 'meta' },
498-
{ label: 'Google', value: 'google' },
518+
diretDomainsOptions: [
519+
{ label: 'Private DNS', value: 'geosite:private' },
520+
{ label: '🇮🇷 Iran', value: 'geosite:category-ir' },
521+
{ label: '🇨🇳 China', value: 'geosite:cn' },
522+
{ label: '🇷🇺 Russia', value: 'geosite:category-ru' },
523+
{ label: 'Apple', value: 'geosite:apple' },
524+
{ label: 'Meta', value: 'geosite:meta' },
525+
{ label: 'Google', value: 'geosite:google' },
499526
],
500527
get remarkModel() {
501528
rm = this.allSetting.remarkModel;
@@ -753,7 +780,7 @@
753780
const rules = JSON.parse(this.allSetting.subJsonRules);
754781
if (!Array.isArray(rules)) return [];
755782
const ipRule = rules.find(r => r.ip);
756-
return ipRule?.ip.map(d => d.replace("geoip:", "")) ?? [];
783+
return ipRule?.ip ?? [];
757784
},
758785
set: function (v) {
759786
let rules = JSON.parse(this.allSetting.subJsonRules);
@@ -767,7 +794,7 @@
767794

768795
rules[ruleIndex].ip = [];
769796
v.forEach(d => {
770-
rules[ruleIndex].ip.push("geoip:" + d);
797+
rules[ruleIndex].ip.push(d);
771798
});
772799
}
773800
this.allSetting.subJsonRules = JSON.stringify(rules);
@@ -779,34 +806,18 @@
779806
const rules = JSON.parse(this.allSetting.subJsonRules);
780807
if (!Array.isArray(rules)) return [];
781808
const domainRule = rules.find(r => r.domain);
782-
return domainRule?.domain.map(d => {
783-
if (d.startsWith("geosite:category-")) {
784-
return d.replace("geosite:category-", "");
785-
}
786-
return d.replace("geosite:", "");
787-
})
788-
?? [];
809+
return domainRule?.domain ?? [];
789810
},
790811
set: function (v) {
791812
let rules = JSON.parse(this.allSetting.subJsonRules);
792813
if (!Array.isArray(rules)) return;
793-
794814
if (v.length == 0) {
795815
rules = rules.filter(r => !r.domain);
796816
} else {
797817
let ruleIndex = rules.findIndex(r => r.domain);
798818
if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[0]) - 1;
799819

800-
rules[ruleIndex].domain = [];
801-
v.forEach(d => {
802-
let category = '';
803-
if (["cn", "apple", "meta", "google"].includes(d)) {
804-
category = "";
805-
} else if (["ru", "ir"].includes(d)) {
806-
category = "category-";
807-
}
808-
rules[ruleIndex].domain.push("geosite:" + category + d);
809-
});
820+
rules[ruleIndex].domain = v;
810821
}
811822
this.allSetting.subJsonRules = JSON.stringify(rules);
812823
}
@@ -839,4 +850,4 @@
839850
});
840851
</script>
841852
</body>
842-
</html>
853+
</html>

0 commit comments

Comments
 (0)