setting.html 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <style>
  5. @media (min-width: 769px) {
  6. .ant-layout-content {
  7. margin: 24px 16px;
  8. }
  9. }
  10. .ant-col-sm-24 {
  11. margin-top: 10px;
  12. }
  13. .ant-tabs-bar {
  14. margin: 0;
  15. }
  16. .ant-list-item {
  17. display: block;
  18. }
  19. :not(.ant-card-dark)>.ant-tabs-top-bar {
  20. background: white;
  21. }
  22. </style>
  23. <body>
  24. <a-layout id="app" v-cloak>
  25. {{ template "commonSider" . }}
  26. <a-layout id="content-layout" :style="siderDrawer.isDarkTheme ? bgDarkStyle : ''">
  27. <a-layout-content>
  28. <a-spin :spinning="spinning" :delay="500" tip="loading">
  29. <a-space direction="vertical">
  30. <a-space direction="horizontal">
  31. <a-button type="primary" :disabled="saveBtnDisable" @click="updateAllSetting">{{ i18n "pages.setting.save" }}</a-button>
  32. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartPanel">{{ i18n "pages.setting.restartPanel" }}</a-button>
  33. </a-space>
  34. <a-tabs default-active-key="1" :class="siderDrawer.isDarkTheme ? darkClass : ''">
  35. <a-tab-pane key="1" tab='{{ i18n "pages.setting.panelConfig"}}'>
  36. <a-list item-layout="horizontal" :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65);': 'background: white;'">
  37. <setting-list-item type="text" title='{{ i18n "pages.setting.panelListeningIP"}}' desc='{{ i18n "pages.setting.panelListeningIPDesc"}}' v-model="allSetting.webListen"></setting-list-item>
  38. <setting-list-item type="number" title='{{ i18n "pages.setting.panelPort"}}' desc='{{ i18n "pages.setting.panelPortDesc"}}' v-model.number="allSetting.webPort"></setting-list-item>
  39. <setting-list-item type="text" title='{{ i18n "pages.setting.publicKeyPath"}}' desc='{{ i18n "pages.setting.publicKeyPathDesc"}}' v-model="allSetting.webCertFile"></setting-list-item>
  40. <setting-list-item type="text" title='{{ i18n "pages.setting.privateKeyPath"}}' desc='{{ i18n "pages.setting.privateKeyPathDesc"}}' v-model="allSetting.webKeyFile"></setting-list-item>
  41. <setting-list-item type="text" title='{{ i18n "pages.setting.panelUrlPath"}}' desc='{{ i18n "pages.setting.panelUrlPathDesc"}}' v-model="allSetting.webBasePath"></setting-list-item>
  42. <setting-list-item type="number" title='{{ i18n "pages.setting.expireTimeDiff" }}' desc='{{ i18n "pages.setting.expireTimeDiffDesc" }}' v-model="allSetting.expireDiff" :min="0"></setting-list-item>
  43. <setting-list-item type="number" title='{{ i18n "pages.setting.trafficDiff" }}' desc='{{ i18n "pages.setting.trafficDiffDesc" }}' v-model="allSetting.trafficDiff" :min="0"></setting-list-item>
  44. <a-list-item>
  45. <a-row style="padding: 20px">
  46. <a-col :lg="24" :xl="12">
  47. <a-list-item-meta title="Language" />
  48. </a-col>
  49. <a-col :lg="24" :xl="12">
  50. <template>
  51. <a-select
  52. ref="selectLang"
  53. v-model="lang"
  54. @change="setLang(lang)"
  55. :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''"
  56. style="width: 100%"
  57. >
  58. <a-select-option :value="l.value" :label="l.value" v-for="l in supportLangs">
  59. <span role="img" aria-label="l.name" v-text="l.icon"></span>&nbsp;&nbsp;<span v-text="l.name"></span>
  60. </a-select-option>
  61. </a-select>
  62. </template>
  63. </a-col>
  64. </a-row>
  65. </a-list-item>
  66. </a-list>
  67. </a-tab-pane>
  68. <a-tab-pane key="2" tab='{{ i18n "pages.setting.userSetting"}}'>
  69. <a-form :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65); padding: 20px;': 'background: white; padding: 20px;'">
  70. <a-form-item label='{{ i18n "pages.setting.oldUsername"}}'>
  71. <a-input v-model="user.oldUsername" style="max-width: 300px"></a-input>
  72. </a-form-item>
  73. <a-form-item label='{{ i18n "pages.setting.currentPassword"}}'>
  74. <a-input type="password" v-model="user.oldPassword" style="max-width: 300px"></a-input>
  75. </a-form-item>
  76. <a-form-item label='{{ i18n "pages.setting.newUsername"}}'>
  77. <a-input v-model="user.newUsername" style="max-width: 300px"></a-input>
  78. </a-form-item>
  79. <a-form-item label='{{ i18n "pages.setting.newPassword"}}'>
  80. <a-input type="password" v-model="user.newPassword" style="max-width: 300px"></a-input>
  81. </a-form-item>
  82. <a-form-item>
  83. <a-button type="primary" @click="updateUser">{{ i18n "confirm" }}</a-button>
  84. </a-form-item>
  85. </a-form>
  86. </a-tab-pane>
  87. <a-tab-pane key="3" tab='{{ i18n "pages.setting.xrayConfiguration"}}'>
  88. <a-list item-layout="horizontal" :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65);': 'background: white;'">
  89. <a-divider>{{ i18n "pages.setting.actions"}}</a-divider>
  90. <a-space direction="horizontal" style="padding: 0 20px">
  91. <a-button type="primary" @click="resetXrayConfigToDefault">{{ i18n "pages.setting.resetDefaultConfig" }}</a-button>
  92. </a-space>
  93. <a-divider>{{ i18n "pages.setting.basicTemplate"}}</a-divider>
  94. <a-collapse>
  95. <a-collapse-panel header='{{ i18n "pages.setting.generalConfigs"}}'>
  96. <a-row :xs="24" :sm="24" :lg="12">
  97. <h2 style="color: inherit; font-weight: bold; font-size: 18px; padding: 10px 20px; border-bottom: 2px solid;">
  98. <a-icon type="warning" style="color: inherit; font-size: 24px;"></a-icon>
  99. {{ i18n "pages.setting.generalConfigsDesc" }}
  100. </h2>
  101. </a-row>
  102. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigTorrent"}}' desc='{{ i18n "pages.setting.xrayConfigTorrentDesc"}}' v-model="torrentSettings"></setting-list-item>
  103. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigPrivateIp"}}' desc='{{ i18n "pages.setting.xrayConfigPrivateIpDesc"}}' v-model="privateIpSettings"></setting-list-item>
  104. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigAds"}}' desc='{{ i18n "pages.setting.xrayConfigAdsDesc"}}' v-model="AdsSettings"></setting-list-item>
  105. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigPorn"}}' desc='{{ i18n "pages.setting.xrayConfigPornDesc"}}' v-model="PornSettings"></setting-list-item>
  106. </a-collapse-panel>
  107. <a-collapse-panel header='{{ i18n "pages.setting.countryConfigs"}}'>
  108. <a-row :xs="24" :sm="24" :lg="12">
  109. <h2 style="color: inherit; font-weight: bold; font-size: 18px; padding: 10px 20px; border-bottom: 2px solid;">
  110. <a-icon type="warning" style="color: inherit; font-size: 24px;"></a-icon>
  111. {{ i18n "pages.setting.countryConfigsDesc" }}
  112. </h2>
  113. </a-row>
  114. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigIRIp"}}' desc='{{ i18n "pages.setting.xrayConfigIRIpDesc"}}' v-model="IRIpSettings"></setting-list-item>
  115. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigIRDomain"}}' desc='{{ i18n "pages.setting.xrayConfigIRDomainDesc"}}' v-model="IRDomainSettings"></setting-list-item>
  116. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigChinaIp"}}' desc='{{ i18n "pages.setting.xrayConfigChinaIpDesc"}}' v-model="ChinaIpSettings"></setting-list-item>
  117. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigChinaDomain"}}' desc='{{ i18n "pages.setting.xrayConfigChinaDomainDesc"}}' v-model="ChinaDomainSettings"></setting-list-item>
  118. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigRussiaIp"}}' desc='{{ i18n "pages.setting.xrayConfigRussiaIpDesc"}}' v-model="RussiaIpSettings"></setting-list-item>
  119. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigRussiaDomain"}}' desc='{{ i18n "pages.setting.xrayConfigRussiaDomainDesc"}}' v-model="RussiaDomainSettings"></setting-list-item>
  120. </a-collapse-panel>
  121. <a-collapse-panel header='{{ i18n "pages.setting.ipv4Configs"}}'>
  122. <a-row :xs="24" :sm="24" :lg="12">
  123. <h2 style="color: inherit; font-weight: bold; font-size: 18px; padding: 10px 20px; border-bottom: 2px solid;">
  124. <a-icon type="warning" style="color: inherit; font-size: 24px;"></a-icon>
  125. {{ i18n "pages.setting.ipv4ConfigsDesc" }}
  126. </h2>
  127. </a-row>
  128. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigGoogleIPv4"}}' desc='{{ i18n "pages.setting.xrayConfigGoogleIPv4Desc"}}' v-model="GoogleIPv4Settings"></setting-list-item>
  129. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigNetflixIPv4"}}' desc='{{ i18n "pages.setting.xrayConfigNetflixIPv4Desc"}}' v-model="NetflixIPv4Settings"></setting-list-item>
  130. </a-collapse-panel>
  131. <a-collapse-panel header='{{ i18n "pages.setting.warpConfigs"}}'>
  132. <a-row :xs="24" :sm="24" :lg="12">
  133. <h2 style="color: inherit; font-weight: bold; font-size: 18px; padding: 10px 20px; border-bottom: 2px solid;">
  134. <a-icon type="warning" style="color: inherit; font-size: 24px;"></a-icon>
  135. {{ i18n "pages.setting.warpConfigsDesc" }}
  136. </h2>
  137. </a-row>
  138. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigGoogleWARP"}}' desc='{{ i18n "pages.setting.xrayConfigGoogleWARPDesc"}}' v-model="GoogleWARPSettings"></setting-list-item>
  139. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigOpenAIWARP"}}' desc='{{ i18n "pages.setting.xrayConfigOpenAIWARPDesc"}}' v-model="OpenAIWARPSettings"></setting-list-item>
  140. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigNetflixWARP"}}' desc='{{ i18n "pages.setting.xrayConfigNetflixWARPDesc"}}' v-model="NetflixWARPSettings"></setting-list-item>
  141. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigSpotifyWARP"}}' desc='{{ i18n "pages.setting.xrayConfigSpotifyWARPDesc"}}' v-model="SpotifyWARPSettings"></setting-list-item>
  142. </a-collapse-panel>
  143. </a-collapse>
  144. <a-divider>{{ i18n "pages.setting.advancedTemplate"}}</a-divider>
  145. <a-collapse>
  146. <a-collapse-panel header='{{ i18n "pages.setting.xrayConfigInbounds"}}'>
  147. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigInbounds"}}' desc='{{ i18n "pages.setting.xrayConfigInboundsDesc"}}' v-model="inboundSettings"></setting-list-item>
  148. </a-collapse-panel>
  149. <a-collapse-panel header='{{ i18n "pages.setting.xrayConfigOutbounds"}}'>
  150. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigOutbounds"}}' desc='{{ i18n "pages.setting.xrayConfigOutboundsDesc"}}' v-model="outboundSettings"></setting-list-item>
  151. </a-collapse-panel>
  152. <a-collapse-panel header='{{ i18n "pages.setting.xrayConfigRoutings"}}'>
  153. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigRoutings"}}' desc='{{ i18n "pages.setting.xrayConfigRoutingsDesc"}}' v-model="routingRuleSettings"></setting-list-item>
  154. </a-collapse-panel>
  155. </a-collapse>
  156. <a-divider>{{ i18n "pages.setting.completeTemplate"}}</a-divider>
  157. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigTemplate"}}' desc='{{ i18n "pages.setting.xrayConfigTemplateDesc"}}' v-model="allSetting.xrayTemplateConfig"></setting-list-item>
  158. </a-list>
  159. </a-tab-pane>
  160. <a-tab-pane key="4" tab='{{ i18n "pages.setting.TGReminder"}}'>
  161. <a-list item-layout="horizontal" :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65);': 'background: white;'">
  162. <setting-list-item type="switch" title='{{ i18n "pages.setting.telegramBotEnable" }}' desc='{{ i18n "pages.setting.telegramBotEnableDesc" }}' v-model="allSetting.tgBotEnable"></setting-list-item>
  163. <setting-list-item type="text" title='{{ i18n "pages.setting.telegramToken"}}' desc='{{ i18n "pages.setting.telegramTokenDesc"}}' v-model="allSetting.tgBotToken"></setting-list-item>
  164. <setting-list-item type="text" title='{{ i18n "pages.setting.telegramChatId"}}' desc='{{ i18n "pages.setting.telegramChatIdDesc"}}' v-model="allSetting.tgBotChatId"></setting-list-item>
  165. <setting-list-item type="text" title='{{ i18n "pages.setting.telegramNotifyTime"}}' desc='{{ i18n "pages.setting.telegramNotifyTimeDesc"}}' v-model="allSetting.tgRunTime"></setting-list-item>
  166. <setting-list-item type="switch" title='{{ i18n "pages.setting.tgNotifyBackup" }}' desc='{{ i18n "pages.setting.tgNotifyBackupDesc" }}' v-model="allSetting.tgBotBackup"></setting-list-item>
  167. <setting-list-item type="number" title='{{ i18n "pages.setting.tgNotifyCpu" }}' desc='{{ i18n "pages.setting.tgNotifyCpuDesc" }}' v-model="allSetting.tgCpu" :min="0" :max="100"></setting-list-item>
  168. </a-list>
  169. </a-tab-pane>
  170. <a-tab-pane key="5" tab='{{ i18n "pages.setting.otherSetting"}}'>
  171. <a-list item-layout="horizontal" :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65);': 'background: white;'">
  172. <setting-list-item type="text" title='{{ i18n "pages.setting.timeZonee"}}' desc='{{ i18n "pages.setting.timeZoneDesc"}}' v-model="allSetting.timeLocation"></setting-list-item>
  173. </a-list>
  174. </a-tab-pane>
  175. </a-tabs>
  176. </a-space>
  177. </a-spin>
  178. </a-layout-content>
  179. </a-layout>
  180. </a-layout>
  181. {{template "js" .}}
  182. {{template "component/setting"}}
  183. <script>
  184. const app = new Vue({
  185. delimiters: ['[[', ']]'],
  186. el: '#app',
  187. data: {
  188. siderDrawer,
  189. spinning: false,
  190. oldAllSetting: new AllSetting(),
  191. allSetting: new AllSetting(),
  192. saveBtnDisable: true,
  193. user: {},
  194. lang: getLang(),
  195. ipv4Settings: {
  196. tag: "IPv4",
  197. protocol: "freedom",
  198. settings: {
  199. domainStrategy: "UseIPv4"
  200. }
  201. },
  202. warpSettings: {
  203. tag: "WARP",
  204. protocol: "socks",
  205. settings: {
  206. servers: [
  207. {
  208. address: "127.0.0.1",
  209. port: 40000
  210. }
  211. ]
  212. }
  213. },
  214. settingsData: {
  215. protocols: {
  216. bittorrent: ["bittorrent"],
  217. },
  218. ips: {
  219. local: ["geoip:private"],
  220. google: ["geoip:google"],
  221. cn: ["geoip:cn"],
  222. ir: ["geoip:ir"],
  223. ru: ["geoip:ru"],
  224. },
  225. domains: {
  226. ads: [
  227. "geosite:category-ads-all",
  228. "geosite:category-ads",
  229. "geosite:google-ads",
  230. "geosite:spotify-ads"
  231. ],
  232. porn: ["geosite:category-porn"],
  233. openai: ["geosite:openai"],
  234. google: ["geosite:google"],
  235. spotify: ["geosite:spotify"],
  236. netflix: ["geosite:netflix"],
  237. cn: ["geosite:cn"],
  238. ru: ["geosite:category-ru-gov"],
  239. ir: [
  240. "regexp:.*\\.ir$",
  241. "ext:iran.dat:ir",
  242. "ext:iran.dat:other",
  243. "ext:iran.dat:ads",
  244. "geosite:category-ir"
  245. ]
  246. },
  247. }
  248. },
  249. methods: {
  250. loading(spinning = true) {
  251. this.spinning = spinning;
  252. },
  253. async getAllSetting() {
  254. this.loading(true);
  255. const msg = await HttpUtil.post("/xui/setting/all");
  256. this.loading(false);
  257. if (msg.success) {
  258. this.oldAllSetting = new AllSetting(msg.obj);
  259. this.allSetting = new AllSetting(msg.obj);
  260. this.saveBtnDisable = true;
  261. }
  262. },
  263. async updateAllSetting() {
  264. this.loading(true);
  265. const msg = await HttpUtil.post("/xui/setting/update", this.allSetting);
  266. this.loading(false);
  267. if (msg.success) {
  268. await this.getAllSetting();
  269. }
  270. },
  271. async updateUser() {
  272. this.loading(true);
  273. const msg = await HttpUtil.post("/xui/setting/updateUser", this.user);
  274. this.loading(false);
  275. if (msg.success) {
  276. this.user = {};
  277. }
  278. },
  279. async restartPanel() {
  280. await new Promise(resolve => {
  281. this.$confirm({
  282. title: '{{ i18n "pages.setting.restartPanel" }}',
  283. content: '{{ i18n "pages.setting.restartPanelDesc" }}',
  284. okText: '{{ i18n "sure" }}',
  285. cancelText: '{{ i18n "cancel" }}',
  286. onOk: () => resolve(),
  287. });
  288. });
  289. this.loading(true);
  290. const msg = await HttpUtil.post("/xui/setting/restartPanel");
  291. this.loading(false);
  292. if (msg.success) {
  293. this.loading(true);
  294. await PromiseUtil.sleep(5000);
  295. location.reload();
  296. }
  297. },
  298. async resetXrayConfigToDefault() {
  299. this.loading(true);
  300. const msg = await HttpUtil.get("/xui/setting/getDefaultJsonConfig");
  301. this.loading(false);
  302. if (msg.success) {
  303. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  304. this.saveBtnDisable = true;
  305. }
  306. },
  307. checkRequiredOutbounds() {
  308. const newTemplateSettings = this.templateSettings;
  309. const haveIPv4Outbounds = newTemplateSettings.outbounds.some((o) => o?.tag === "IPv4");
  310. const haveIPv4Rules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === "IPv4");
  311. const haveWARPOutbounds = newTemplateSettings.outbounds.some((o) => o?.tag === "WARP");
  312. const haveWARPRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === "WARP");
  313. if (haveWARPRules && !haveWARPOutbounds) {
  314. newTemplateSettings.outbounds.push(this.warpSettings);
  315. }
  316. if (haveIPv4Rules && !haveIPv4Outbounds) {
  317. newTemplateSettings.outbounds.push(this.ipv4Settings);
  318. }
  319. this.templateSettings = newTemplateSettings;
  320. },
  321. templateRuleGetter(routeSettings) {
  322. const { data, property, outboundTag } = routeSettings;
  323. let result = false;
  324. if (this.templateSettings != null) {
  325. this.templateSettings.routing.rules.forEach(
  326. (routingRule) => {
  327. if (
  328. routingRule.hasOwnProperty(property) &&
  329. routingRule.hasOwnProperty("outboundTag") &&
  330. routingRule.outboundTag === outboundTag
  331. ) {
  332. if (data.includes(routingRule[property][0])) {
  333. result = true;
  334. }
  335. }
  336. }
  337. );
  338. }
  339. return result;
  340. },
  341. templateRuleSetter(routeSettings) {
  342. const { newValue, data, property, outboundTag } = routeSettings;
  343. const oldTemplateSettings = this.templateSettings;
  344. const newTemplateSettings = oldTemplateSettings;
  345. if (newValue) {
  346. const propertyRule = {
  347. type: "field",
  348. outboundTag,
  349. [property]: data
  350. };
  351. newTemplateSettings.routing.rules.push(propertyRule);
  352. }
  353. else {
  354. const newRules = [];
  355. newTemplateSettings.routing.rules.forEach(
  356. (routingRule) => {
  357. if (
  358. routingRule.hasOwnProperty(property) &&
  359. routingRule.hasOwnProperty("outboundTag") &&
  360. routingRule.outboundTag === outboundTag
  361. ) {
  362. if (data.includes(routingRule[property][0])) {
  363. return;
  364. }
  365. }
  366. newRules.push(routingRule);
  367. }
  368. );
  369. newTemplateSettings.routing.rules = newRules;
  370. }
  371. this.templateSettings = newTemplateSettings;
  372. this.checkRequiredOutbounds();
  373. }
  374. },
  375. async mounted() {
  376. await this.getAllSetting();
  377. while (true) {
  378. await PromiseUtil.sleep(1000);
  379. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  380. }
  381. },
  382. computed: {
  383. templateSettings: {
  384. get: function () { return this.allSetting.xrayTemplateConfig ? JSON.parse(this.allSetting.xrayTemplateConfig) : null; },
  385. set: function (newValue) { this.allSetting.xrayTemplateConfig = JSON.stringify(newValue, null, 2) },
  386. },
  387. inboundSettings: {
  388. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  389. set: function (newValue) {
  390. newTemplateSettings = this.templateSettings;
  391. newTemplateSettings.inbounds = JSON.parse(newValue)
  392. this.templateSettings = newTemplateSettings
  393. },
  394. },
  395. outboundSettings: {
  396. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  397. set: function (newValue) {
  398. newTemplateSettings = this.templateSettings;
  399. newTemplateSettings.outbounds = JSON.parse(newValue)
  400. this.templateSettings = newTemplateSettings
  401. },
  402. },
  403. routingRuleSettings: {
  404. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  405. set: function (newValue) {
  406. newTemplateSettings = this.templateSettings;
  407. newTemplateSettings.routing.rules = JSON.parse(newValue)
  408. this.templateSettings = newTemplateSettings
  409. },
  410. },
  411. torrentSettings: {
  412. get: function () {
  413. return this.templateRuleGetter({
  414. outboundTag: "blocked",
  415. property: "protocol",
  416. data: this.settingsData.protocols.bittorrent
  417. });
  418. },
  419. set: function (newValue) {
  420. this.templateRuleSetter({
  421. newValue,
  422. outboundTag: "blocked",
  423. property: "protocol",
  424. data: this.settingsData.protocols.bittorrent
  425. });
  426. },
  427. },
  428. privateIpSettings: {
  429. get: function () {
  430. return this.templateRuleGetter({
  431. outboundTag: "blocked",
  432. property: "ip",
  433. data: this.settingsData.ips.local
  434. });
  435. },
  436. set: function (newValue) {
  437. this.templateRuleSetter({
  438. newValue,
  439. outboundTag: "blocked",
  440. property: "ip",
  441. data: this.settingsData.ips.local
  442. });
  443. },
  444. },
  445. AdsSettings: {
  446. get: function () {
  447. return this.templateRuleGetter({
  448. outboundTag: "blocked",
  449. property: "domain",
  450. data: this.settingsData.domains.ads
  451. });
  452. },
  453. set: function (newValue) {
  454. this.templateRuleSetter({
  455. newValue,
  456. outboundTag: "blocked",
  457. property: "domain",
  458. data: this.settingsData.domains.ads
  459. });
  460. },
  461. },
  462. PornSettings: {
  463. get: function () {
  464. return this.templateRuleGetter({
  465. outboundTag: "blocked",
  466. property: "domain",
  467. data: this.settingsData.domains.porn
  468. });
  469. },
  470. set: function (newValue) {
  471. this.templateRuleSetter({
  472. newValue,
  473. outboundTag: "blocked",
  474. property: "domain",
  475. data: this.settingsData.domains.porn
  476. });
  477. },
  478. },
  479. GoogleIPv4Settings: {
  480. get: function () {
  481. return this.templateRuleGetter({
  482. outboundTag: "IPv4",
  483. property: "domain",
  484. data: this.settingsData.domains.google
  485. });
  486. },
  487. set: function (newValue) {
  488. this.templateRuleSetter({
  489. newValue,
  490. outboundTag: "IPv4",
  491. property: "domain",
  492. data: this.settingsData.domains.google
  493. });
  494. },
  495. },
  496. NetflixIPv4Settings: {
  497. get: function () {
  498. return this.templateRuleGetter({
  499. outboundTag: "IPv4",
  500. property: "domain",
  501. data: this.settingsData.domains.netflix
  502. });
  503. },
  504. set: function (newValue) {
  505. this.templateRuleSetter({
  506. newValue,
  507. outboundTag: "IPv4",
  508. property: "domain",
  509. data: this.settingsData.domains.netflix
  510. });
  511. },
  512. },
  513. IRIpSettings: {
  514. get: function () {
  515. return this.templateRuleGetter({
  516. outboundTag: "blocked",
  517. property: "ip",
  518. data: this.settingsData.ips.ir
  519. });
  520. },
  521. set: function (newValue) {
  522. this.templateRuleSetter({
  523. newValue,
  524. outboundTag: "blocked",
  525. property: "ip",
  526. data: this.settingsData.ips.ir
  527. });
  528. },
  529. },
  530. IRDomainSettings: {
  531. get: function () {
  532. return this.templateRuleGetter({
  533. outboundTag: "blocked",
  534. property: "domain",
  535. data: this.settingsData.domains.ir
  536. });
  537. },
  538. set: function (newValue) {
  539. this.templateRuleSetter({
  540. newValue,
  541. outboundTag: "blocked",
  542. property: "domain",
  543. data: this.settingsData.domains.ir
  544. });
  545. },
  546. },
  547. ChinaIpSettings: {
  548. get: function () {
  549. return this.templateRuleGetter({
  550. outboundTag: "blocked",
  551. property: "ip",
  552. data: this.settingsData.ips.cn
  553. });
  554. },
  555. set: function (newValue) {
  556. this.templateRuleSetter({
  557. newValue,
  558. outboundTag: "blocked",
  559. property: "ip",
  560. data: this.settingsData.ips.cn
  561. });
  562. },
  563. },
  564. ChinaDomainSettings: {
  565. get: function () {
  566. return this.templateRuleGetter({
  567. outboundTag: "blocked",
  568. property: "domain",
  569. data: this.settingsData.domains.cn
  570. });
  571. },
  572. set: function (newValue) {
  573. this.templateRuleSetter({
  574. newValue,
  575. outboundTag: "blocked",
  576. property: "domain",
  577. data: this.settingsData.domains.cn
  578. });
  579. },
  580. },
  581. RussiaIpSettings: {
  582. get: function () {
  583. return this.templateRuleGetter({
  584. outboundTag: "blocked",
  585. property: "ip",
  586. data: this.settingsData.ips.ru
  587. });
  588. },
  589. set: function (newValue) {
  590. this.templateRuleSetter({
  591. newValue,
  592. outboundTag: "blocked",
  593. property: "ip",
  594. data: this.settingsData.ips.ru
  595. });
  596. },
  597. },
  598. RussiaDomainSettings: {
  599. get: function () {
  600. return this.templateRuleGetter({
  601. outboundTag: "blocked",
  602. property: "domain",
  603. data: this.settingsData.domains.ru
  604. });
  605. },
  606. set: function (newValue) {
  607. this.templateRuleSetter({
  608. newValue,
  609. outboundTag: "blocked",
  610. property: "domain",
  611. data: this.settingsData.domains.ru
  612. });
  613. },
  614. },
  615. GoogleWARPSettings: {
  616. get: function () {
  617. return this.templateRuleGetter({
  618. outboundTag: "WARP",
  619. property: "domain",
  620. data: this.settingsData.domains.google
  621. });
  622. },
  623. set: function (newValue) {
  624. this.templateRuleSetter({
  625. newValue,
  626. outboundTag: "WARP",
  627. property: "domain",
  628. data: this.settingsData.domains.google
  629. });
  630. },
  631. },
  632. OpenAIWARPSettings: {
  633. get: function () {
  634. return this.templateRuleGetter({
  635. outboundTag: "WARP",
  636. property: "domain",
  637. data: this.settingsData.domains.openai
  638. });
  639. },
  640. set: function (newValue) {
  641. this.templateRuleSetter({
  642. newValue,
  643. outboundTag: "WARP",
  644. property: "domain",
  645. data: this.settingsData.domains.openai
  646. });
  647. },
  648. },
  649. NetflixWARPSettings: {
  650. get: function () {
  651. return this.templateRuleGetter({
  652. outboundTag: "WARP",
  653. property: "domain",
  654. data: this.settingsData.domains.netflix
  655. });
  656. },
  657. set: function (newValue) {
  658. this.templateRuleSetter({
  659. newValue,
  660. outboundTag: "WARP",
  661. property: "domain",
  662. data: this.settingsData.domains.netflix
  663. });
  664. },
  665. },
  666. SpotifyWARPSettings: {
  667. get: function () {
  668. return this.templateRuleGetter({
  669. outboundTag: "WARP",
  670. property: "domain",
  671. data: this.settingsData.domains.spotify
  672. });
  673. },
  674. set: function (newValue) {
  675. this.templateRuleSetter({
  676. newValue,
  677. outboundTag: "WARP",
  678. property: "domain",
  679. data: this.settingsData.domains.spotify
  680. });
  681. },
  682. },
  683. }
  684. });
  685. </script>
  686. </body>
  687. </html>