settings.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. {{ template "page/head_start" .}}
  2. {{ template "page/head_end" .}}
  3. {{ template "page/body_start" .}}
  4. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme + ' settings-page'">
  5. <a-sidebar></a-sidebar>
  6. <a-layout id="content-layout">
  7. <a-layout-content>
  8. <a-spin :spinning="loadingStates.spinning" :delay="500" tip='{{ i18n "loading"}}' size="large">
  9. <transition name="list" appear>
  10. <a-alert type="error" v-if="confAlerts.length>0 && loadingStates.fetched" :style="{ marginBottom: '10px' }"
  11. message='{{ i18n "secAlertTitle" }}' color="red" show-icon closable>
  12. <template slot="description">
  13. <b>{{ i18n "secAlertConf" }}</b>
  14. <ul>
  15. <li v-for="a in confAlerts">[[ a ]]</li>
  16. </ul>
  17. </template>
  18. </a-alert>
  19. </transition>
  20. <transition name="list" appear>
  21. <template>
  22. <a-row v-if="!loadingStates.fetched">
  23. <div :style="{ minHeight: 'calc(100vh - 120px)' }"></div>
  24. </a-row>
  25. <a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else>
  26. <a-col>
  27. <a-card hoverable>
  28. <a-row :style="{ display: 'flex', flexWrap: 'wrap', alignItems: 'center' }">
  29. <a-col :xs="24" :sm="10" :style="{ padding: '4px' }">
  30. <a-space direction="horizontal">
  31. <a-button type="primary" :disabled="saveBtnDisable" @click="updateAllSetting">{{ i18n
  32. "pages.settings.save" }}</a-button>
  33. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartPanel">{{ i18n
  34. "pages.settings.restartPanel" }}</a-button>
  35. </a-space>
  36. </a-col>
  37. <a-col :xs="24" :sm="14">
  38. <template>
  39. <div>
  40. <a-back-top :target="() => document.getElementById('content-layout')"
  41. visibility-height="200"></a-back-top>
  42. <a-alert type="warning" :style="{ float: 'right', width: 'fit-content' }"
  43. message='{{ i18n "pages.settings.infoDesc" }}' show-icon>
  44. </a-alert>
  45. </div>
  46. </template>
  47. </a-col>
  48. </a-row>
  49. </a-card>
  50. </a-col>
  51. <a-col>
  52. <a-tabs default-active-key="1">
  53. <a-tab-pane key="1" :style="{ paddingTop: '20px' }">
  54. <template #tab>
  55. <a-icon type="setting"></a-icon>
  56. <span>{{ i18n "pages.settings.panelSettings" }}</span>
  57. </template>
  58. {{ template "settings/panel/general" . }}
  59. </a-tab-pane>
  60. <a-tab-pane key="2" :style="{ paddingTop: '20px' }">
  61. <template #tab>
  62. <a-icon type="safety"></a-icon>
  63. <span>{{ i18n "pages.settings.securitySettings" }}</span>
  64. </template>
  65. {{ template "settings/panel/security" . }}
  66. </a-tab-pane>
  67. <a-tab-pane key="3" :style="{ paddingTop: '20px' }">
  68. <template #tab>
  69. <a-icon type="message"></a-icon>
  70. <span>{{ i18n "pages.settings.TGBotSettings" }}</span>
  71. </template>
  72. {{ template "settings/panel/telegram" . }}
  73. </a-tab-pane>
  74. <a-tab-pane key="4" :style="{ paddingTop: '20px' }">
  75. <template #tab>
  76. <a-icon type="cloud-server"></a-icon>
  77. <span>{{ i18n "pages.settings.subSettings" }}</span>
  78. </template>
  79. {{ template "settings/panel/subscription/general" . }}
  80. </a-tab-pane>
  81. <a-tab-pane key="5" v-if="allSetting.subJsonEnable || allSetting.subClashEnable" :style="{ paddingTop: '20px' }">
  82. <template #tab>
  83. <a-icon type="code"></a-icon>
  84. <span>{{ i18n "pages.settings.subSettings" }} (Formats)</span>
  85. </template>
  86. {{ template "settings/panel/subscription/json" . }}
  87. </a-tab-pane>
  88. </a-tabs>
  89. </a-col>
  90. </a-row>
  91. </template>
  92. </transition>
  93. </a-spin>
  94. </a-layout-content>
  95. </a-layout>
  96. </a-layout>
  97. {{template "page/body_scripts" .}}
  98. <script src="{{ .base_path }}assets/qrcode/qrious2.min.js?{{ .cur_ver }}"></script>
  99. <script src="{{ .base_path }}assets/otpauth/otpauth.umd.min.js?{{ .cur_ver }}"></script>
  100. <script src="{{ .base_path }}assets/js/model/setting.js?{{ .cur_ver }}"></script>
  101. {{template "component/aSidebar" .}}
  102. {{template "component/aThemeSwitch" .}}
  103. {{template "component/aSettingListItem" .}}
  104. {{template "modals/twoFactorModal"}}
  105. <script>
  106. const app = new Vue({
  107. delimiters: ['[[', ']]'],
  108. mixins: [MediaQueryMixin],
  109. el: '#app',
  110. data: {
  111. themeSwitcher,
  112. loadingStates: {
  113. fetched: false,
  114. spinning: false
  115. },
  116. oldAllSetting: new AllSetting(),
  117. allSetting: new AllSetting(),
  118. saveBtnDisable: true,
  119. entryHost: null,
  120. entryPort: null,
  121. entryProtocol: null,
  122. entryIsIP: false,
  123. user: {},
  124. lang: LanguageManager.getLanguage(),
  125. inboundOptions: [],
  126. remarkModels: { i: 'Inbound', e: 'Email', o: 'Other' },
  127. remarkSeparators: [' ', '-', '_', '@', ':', '~', '|', ',', '.', '/'],
  128. datepickerList: [{ name: 'Gregorian (Standard)', value: 'gregorian' }, { name: 'Jalalian (شمسی)', value: 'jalalian' }],
  129. remarkSample: '',
  130. defaultFragment: {
  131. packets: "tlshello",
  132. length: "100-200",
  133. interval: "10-20",
  134. maxSplit: "300-400"
  135. },
  136. defaultNoises: [
  137. { type: "rand", packet: "10-20", delay: "10-16", applyTo: "ip" }
  138. ],
  139. defaultMux: {
  140. enabled: true,
  141. concurrency: 8,
  142. xudpConcurrency: 16,
  143. xudpProxyUDP443: "reject"
  144. },
  145. defaultRules: [
  146. {
  147. type: "field",
  148. outboundTag: "direct",
  149. domain: [
  150. "geosite:category-ir"
  151. ]
  152. },
  153. {
  154. type: "field",
  155. outboundTag: "direct",
  156. ip: [
  157. "geoip:private",
  158. "geoip:ir"
  159. ]
  160. },
  161. ],
  162. directIPsOptions: [
  163. { label: 'Private IP', value: 'geoip:private' },
  164. { label: '🇮🇷 Iran', value: 'geoip:ir' },
  165. { label: '🇨🇳 China', value: 'geoip:cn' },
  166. { label: '🇷🇺 Russia', value: 'geoip:ru' },
  167. { label: '🇻🇳 Vietnam', value: 'geoip:vn' },
  168. { label: '🇪🇸 Spain', value: 'geoip:es' },
  169. { label: '🇮🇩 Indonesia', value: 'geoip:id' },
  170. { label: '🇺🇦 Ukraine', value: 'geoip:ua' },
  171. { label: '🇹🇷 Türkiye', value: 'geoip:tr' },
  172. { label: '🇧🇷 Brazil', value: 'geoip:br' },
  173. ],
  174. diretDomainsOptions: [
  175. { label: 'Private DNS', value: 'geosite:private' },
  176. { label: '🇮🇷 Iran', value: 'geosite:category-ir' },
  177. { label: '🇨🇳 China', value: 'geosite:cn' },
  178. { label: '🇷🇺 Russia', value: 'geosite:category-ru' },
  179. { label: 'Apple', value: 'geosite:apple' },
  180. { label: 'Meta', value: 'geosite:meta' },
  181. { label: 'Google', value: 'geosite:google' },
  182. ],
  183. get remarkModel() {
  184. rm = this.allSetting.remarkModel;
  185. return rm.length > 1 ? rm.substring(1).split('') : [];
  186. },
  187. set remarkModel(value) {
  188. rs = this.allSetting.remarkModel[0];
  189. this.allSetting.remarkModel = rs + value.join('');
  190. this.changeRemarkSample();
  191. },
  192. get remarkSeparator() {
  193. return this.allSetting.remarkModel.length > 1 ? this.allSetting.remarkModel.charAt(0) : '-';
  194. },
  195. set remarkSeparator(value) {
  196. this.allSetting.remarkModel = value + this.allSetting.remarkModel.substring(1);
  197. this.changeRemarkSample();
  198. },
  199. get datepicker() {
  200. return this.allSetting.datepicker ? this.allSetting.datepicker : 'gregorian';
  201. },
  202. set datepicker(value) {
  203. this.allSetting.datepicker = value;
  204. },
  205. changeRemarkSample() {
  206. sample = []
  207. this.remarkModel.forEach(r => sample.push(this.remarkModels[r]));
  208. this.remarkSample = sample.length == 0 ? '' : sample.join(this.remarkSeparator);
  209. }
  210. },
  211. methods: {
  212. loading(spinning = true) {
  213. this.loadingStates.spinning = spinning;
  214. },
  215. _isIp(h) {
  216. if (typeof h !== "string") return false;
  217. // IPv4: four dot-separated octets 0-255
  218. const v4 = h.split(".");
  219. if (
  220. v4.length === 4 &&
  221. v4.every(p => /^\d{1,3}$/.test(p) && Number(p) <= 255)
  222. ) return true;
  223. // IPv6: hex groups, optional single :: compression
  224. if (!h.includes(":") || h.includes(":::")) return false;
  225. const parts = h.split("::");
  226. if (parts.length > 2) return false;
  227. const splitGroups = s => (s ? s.split(":").filter(Boolean) : []);
  228. const head = splitGroups(parts[0]);
  229. const tail = splitGroups(parts[1]);
  230. const validGroup = seg => /^[0-9a-fA-F]{1,4}$/.test(seg);
  231. if (![...head, ...tail].every(validGroup)) return false;
  232. const groups = head.length + tail.length;
  233. return parts.length === 2 ? groups < 8 : groups === 8;
  234. },
  235. async getAllSetting() {
  236. const msg = await HttpUtil.post("/panel/setting/all");
  237. if (msg.success) {
  238. if (!this.loadingStates.fetched) {
  239. this.loadingStates.fetched = true
  240. }
  241. this.oldAllSetting = new AllSetting(msg.obj);
  242. this.allSetting = new AllSetting(msg.obj);
  243. app.changeRemarkSample();
  244. this.saveBtnDisable = true;
  245. }
  246. },
  247. async loadInboundTags() {
  248. const msg = await HttpUtil.get("/panel/api/inbounds/list");
  249. if (msg && msg.success && Array.isArray(msg.obj)) {
  250. this.inboundOptions = msg.obj.map(ib => ({
  251. label: `${ib.tag} (${ib.protocol}@${ib.port})`,
  252. value: ib.tag,
  253. }));
  254. } else {
  255. this.inboundOptions = [];
  256. }
  257. },
  258. async updateAllSetting() {
  259. this.loading(true);
  260. const msg = await HttpUtil.post("/panel/setting/update", this.allSetting);
  261. this.loading(false);
  262. if (msg.success) {
  263. await this.getAllSetting();
  264. }
  265. },
  266. async updateUser() {
  267. const sendUpdateUserRequest = async () => {
  268. this.loading(true);
  269. const msg = await HttpUtil.post("/panel/setting/updateUser", this.user);
  270. this.loading(false);
  271. if (msg.success) {
  272. this.user = {};
  273. window.location.replace(basePath + "logout");
  274. }
  275. }
  276. if (this.allSetting.twoFactorEnable) {
  277. twoFactorModal.show({
  278. title: '{{ i18n "pages.settings.security.twoFactorModalChangeCredentialsTitle" }}',
  279. description: '{{ i18n "pages.settings.security.twoFactorModalChangeCredentialsStep" }}',
  280. token: this.allSetting.twoFactorToken,
  281. type: 'confirm',
  282. confirm: (success) => {
  283. if (success) {
  284. sendUpdateUserRequest();
  285. }
  286. }
  287. })
  288. } else {
  289. sendUpdateUserRequest();
  290. }
  291. },
  292. async restartPanel() {
  293. await new Promise(resolve => {
  294. this.$confirm({
  295. title: '{{ i18n "pages.settings.restartPanel" }}',
  296. content: '{{ i18n "pages.settings.restartPanelDesc" }}',
  297. class: themeSwitcher.currentTheme,
  298. okText: '{{ i18n "sure" }}',
  299. cancelText: '{{ i18n "cancel" }}',
  300. onOk: () => resolve(),
  301. });
  302. });
  303. this.loading(true);
  304. const msg = await HttpUtil.post("/panel/setting/restartPanel");
  305. this.loading(false);
  306. if (!msg.success) return;
  307. this.loading(true);
  308. await PromiseUtil.sleep(5000);
  309. const { webDomain, webPort, webBasePath, webCertFile, webKeyFile } = this.allSetting;
  310. const newProtocol = (webCertFile || webKeyFile) ? "https:" : "http:";
  311. let base = webBasePath ? webBasePath.replace(/^\//, "") : "";
  312. if (base && !base.endsWith("/")) base += "/";
  313. if (!this.entryIsIP) {
  314. const url = new URL(window.location.href);
  315. url.pathname = `/${base}panel/settings`;
  316. url.protocol = newProtocol;
  317. window.location.replace(url.toString());
  318. return;
  319. }
  320. let finalHost = this.entryHost;
  321. let finalPort = this.entryPort || "";
  322. if (webDomain && this._isIp(webDomain)) {
  323. finalHost = webDomain;
  324. }
  325. if (webPort && Number(webPort) !== Number(this.entryPort)) {
  326. finalPort = String(webPort);
  327. }
  328. const url = new URL(`${newProtocol}//${finalHost}`);
  329. if (finalPort) url.port = finalPort;
  330. url.pathname = `/${base}panel/settings`;
  331. window.location.replace(url.toString());
  332. },
  333. toggleTwoFactor(newValue) {
  334. if (newValue) {
  335. const newTwoFactorToken = RandomUtil.randomBase32String()
  336. twoFactorModal.show({
  337. title: '{{ i18n "pages.settings.security.twoFactorModalSetTitle" }}',
  338. token: newTwoFactorToken,
  339. type: 'set',
  340. confirm: (success) => {
  341. if (success) {
  342. Vue.prototype.$message['success']('{{ i18n "pages.settings.security.twoFactorModalSetSuccess" }}')
  343. this.allSetting.twoFactorToken = newTwoFactorToken
  344. }
  345. this.allSetting.twoFactorEnable = success
  346. }
  347. })
  348. } else {
  349. twoFactorModal.show({
  350. title: '{{ i18n "pages.settings.security.twoFactorModalDeleteTitle" }}',
  351. description: '{{ i18n "pages.settings.security.twoFactorModalRemoveStep" }}',
  352. token: this.allSetting.twoFactorToken,
  353. type: 'confirm',
  354. confirm: (success) => {
  355. if (success) {
  356. Vue.prototype.$message['success']('{{ i18n "pages.settings.security.twoFactorModalDeleteSuccess" }}')
  357. this.allSetting.twoFactorEnable = false
  358. this.allSetting.twoFactorToken = ""
  359. }
  360. }
  361. })
  362. }
  363. },
  364. addNoise() {
  365. const newNoise = { type: "rand", packet: "10-20", delay: "10-16", applyTo: "ip" };
  366. this.noisesArray = [...this.noisesArray, newNoise];
  367. },
  368. removeNoise(index) {
  369. const newNoises = [...this.noisesArray];
  370. newNoises.splice(index, 1);
  371. this.noisesArray = newNoises;
  372. },
  373. updateNoiseType(index, value) {
  374. const updatedNoises = [...this.noisesArray];
  375. updatedNoises[index] = { ...updatedNoises[index], type: value };
  376. this.noisesArray = updatedNoises;
  377. },
  378. updateNoisePacket(index, value) {
  379. const updatedNoises = [...this.noisesArray];
  380. updatedNoises[index] = { ...updatedNoises[index], packet: value };
  381. this.noisesArray = updatedNoises;
  382. },
  383. updateNoiseDelay(index, value) {
  384. const updatedNoises = [...this.noisesArray];
  385. updatedNoises[index] = { ...updatedNoises[index], delay: value };
  386. this.noisesArray = updatedNoises;
  387. },
  388. updateNoiseApplyTo(index, value) {
  389. const updatedNoises = [...this.noisesArray];
  390. updatedNoises[index] = { ...updatedNoises[index], applyTo: value };
  391. this.noisesArray = updatedNoises;
  392. },
  393. },
  394. computed: {
  395. ldapInboundTagList: {
  396. get: function () {
  397. const csv = this.allSetting.ldapInboundTags || "";
  398. return csv.length ? csv.split(',').map(s => s.trim()).filter(Boolean) : [];
  399. },
  400. set: function (list) {
  401. this.allSetting.ldapInboundTags = Array.isArray(list) ? list.join(',') : '';
  402. }
  403. },
  404. fragment: {
  405. get: function () { return this.allSetting?.subJsonFragment != ""; },
  406. set: function (v) {
  407. this.allSetting.subJsonFragment = v ? JSON.stringify(this.defaultFragment) : "";
  408. }
  409. },
  410. fragmentPackets: {
  411. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).packets : ""; },
  412. set: function (v) {
  413. if (v != "") {
  414. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  415. newFragment.packets = v;
  416. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  417. }
  418. }
  419. },
  420. fragmentLength: {
  421. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).length : ""; },
  422. set: function (v) {
  423. if (v != "") {
  424. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  425. newFragment.length = v;
  426. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  427. }
  428. }
  429. },
  430. fragmentInterval: {
  431. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).interval : ""; },
  432. set: function (v) {
  433. if (v != "") {
  434. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  435. newFragment.interval = v;
  436. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  437. }
  438. }
  439. },
  440. fragmentMaxSplit: {
  441. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).maxSplit : ""; },
  442. set: function (v) {
  443. if (v != "") {
  444. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  445. newFragment.maxSplit = v;
  446. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  447. }
  448. }
  449. },
  450. noises: {
  451. get() {
  452. return this.allSetting?.subJsonNoises != "";
  453. },
  454. set(v) {
  455. if (v) {
  456. this.allSetting.subJsonNoises = JSON.stringify(this.defaultNoises);
  457. } else {
  458. this.allSetting.subJsonNoises = "";
  459. }
  460. }
  461. },
  462. noisesArray: {
  463. get() {
  464. return this.noises ? JSON.parse(this.allSetting.subJsonNoises) : [];
  465. },
  466. set(value) {
  467. if (this.noises) {
  468. this.allSetting.subJsonNoises = JSON.stringify(value);
  469. }
  470. }
  471. },
  472. enableMux: {
  473. get: function () { return this.allSetting?.subJsonMux != ""; },
  474. set: function (v) {
  475. this.allSetting.subJsonMux = v ? JSON.stringify(this.defaultMux) : "";
  476. }
  477. },
  478. muxConcurrency: {
  479. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).concurrency : -1; },
  480. set: function (v) {
  481. newMux = JSON.parse(this.allSetting.subJsonMux);
  482. newMux.concurrency = v;
  483. this.allSetting.subJsonMux = JSON.stringify(newMux);
  484. }
  485. },
  486. muxXudpConcurrency: {
  487. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpConcurrency : -1; },
  488. set: function (v) {
  489. newMux = JSON.parse(this.allSetting.subJsonMux);
  490. newMux.xudpConcurrency = v;
  491. this.allSetting.subJsonMux = JSON.stringify(newMux);
  492. }
  493. },
  494. muxXudpProxyUDP443: {
  495. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpProxyUDP443 : "reject"; },
  496. set: function (v) {
  497. newMux = JSON.parse(this.allSetting.subJsonMux);
  498. newMux.xudpProxyUDP443 = v;
  499. this.allSetting.subJsonMux = JSON.stringify(newMux);
  500. }
  501. },
  502. enableDirect: {
  503. get: function () { return this.allSetting?.subJsonRules != ""; },
  504. set: function (v) {
  505. this.allSetting.subJsonRules = v ? JSON.stringify(this.defaultRules) : "";
  506. }
  507. },
  508. directIPs: {
  509. get: function () {
  510. if (!this.enableDirect) return [];
  511. const rules = JSON.parse(this.allSetting.subJsonRules);
  512. if (!Array.isArray(rules)) return [];
  513. const ipRule = rules.find(r => r.ip);
  514. return ipRule?.ip ?? [];
  515. },
  516. set: function (v) {
  517. let rules = JSON.parse(this.allSetting.subJsonRules);
  518. if (!Array.isArray(rules)) return;
  519. if (v.length == 0) {
  520. rules = rules.filter(r => !r.ip);
  521. } else {
  522. let ruleIndex = rules.findIndex(r => r.ip);
  523. if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[1]) - 1;
  524. rules[ruleIndex].ip = [];
  525. v.forEach(d => {
  526. rules[ruleIndex].ip.push(d);
  527. });
  528. }
  529. this.allSetting.subJsonRules = JSON.stringify(rules);
  530. }
  531. },
  532. directDomains: {
  533. get: function () {
  534. if (!this.enableDirect) return [];
  535. const rules = JSON.parse(this.allSetting.subJsonRules);
  536. if (!Array.isArray(rules)) return [];
  537. const domainRule = rules.find(r => r.domain);
  538. return domainRule?.domain ?? [];
  539. },
  540. set: function (v) {
  541. let rules = JSON.parse(this.allSetting.subJsonRules);
  542. if (!Array.isArray(rules)) return;
  543. if (v.length == 0) {
  544. rules = rules.filter(r => !r.domain);
  545. } else {
  546. let ruleIndex = rules.findIndex(r => r.domain);
  547. if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[0]) - 1;
  548. rules[ruleIndex].domain = v;
  549. }
  550. this.allSetting.subJsonRules = JSON.stringify(rules);
  551. }
  552. },
  553. confAlerts: {
  554. get: function () {
  555. if (!this.allSetting) return [];
  556. var alerts = []
  557. if (window.location.protocol !== "https:") alerts.push('{{ i18n "secAlertSSL" }}');
  558. if (this.allSetting.webPort === 2053) alerts.push('{{ i18n "secAlertPanelPort" }}');
  559. panelPath = window.location.pathname.split('/').length < 4
  560. if (panelPath && this.allSetting.webBasePath == '/') alerts.push('{{ i18n "secAlertPanelURI" }}');
  561. if (this.allSetting.subEnable) {
  562. subPath = this.allSetting.subURI.length > 0 ? new URL(this.allSetting.subURI).pathname : this.allSetting.subPath;
  563. if (subPath == '/sub/') alerts.push('{{ i18n "secAlertSubURI" }}');
  564. }
  565. if (this.allSetting.subJsonEnable) {
  566. subJsonPath = this.allSetting.subJsonURI.length > 0 ? new URL(this.allSetting.subJsonURI).pathname : this.allSetting.subJsonPath;
  567. if (subJsonPath == '/json/') alerts.push('{{ i18n "secAlertSubJsonURI" }}');
  568. }
  569. return alerts
  570. }
  571. }
  572. },
  573. async mounted() {
  574. this.entryHost = window.location.hostname;
  575. this.entryPort = window.location.port;
  576. this.entryProtocol = window.location.protocol;
  577. this.entryIsIP = this._isIp(this.entryHost);
  578. await this.getAllSetting();
  579. await this.loadInboundTags();
  580. while (true) {
  581. await PromiseUtil.sleep(1000);
  582. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  583. }
  584. }
  585. });
  586. </script>
  587. {{ template "page/body_end" .}}