settings.html 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  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. @media (max-width: 768px) {
  11. .ant-tabs-nav .ant-tabs-tab {
  12. margin: 0;
  13. padding: 12px .5rem;
  14. }
  15. }
  16. .ant-tabs-bar {
  17. margin: 0;
  18. }
  19. .ant-list-item {
  20. display: block;
  21. }
  22. .alert-msg {
  23. color: rgb(194, 117, 18);
  24. font-weight: normal;
  25. font-size: 16px;
  26. padding: .5rem 1rem;
  27. text-align: center;
  28. background: rgb(255 145 0 / 15%);
  29. margin: 1.5rem 2.5rem 0rem;
  30. border-radius: .5rem;
  31. transition: all 0.5s;
  32. animation: signal 3s cubic-bezier(0.18, 0.89, 0.32, 1.28) infinite;
  33. }
  34. .alert-msg:hover {
  35. cursor: default;
  36. transition-duration: .3s;
  37. animation: signal 0.9s ease infinite;
  38. }
  39. @keyframes signal {
  40. 0% {
  41. box-shadow: 0 0 0 0 rgba(194, 118, 18, 0.5);
  42. }
  43. 50% {
  44. box-shadow: 0 0 0 6px rgba(0, 0, 0, 0);
  45. }
  46. 100% {
  47. box-shadow: 0 0 0 6px rgba(0, 0, 0, 0);
  48. }
  49. }
  50. .alert-msg>i {
  51. color: inherit;
  52. font-size: 24px;
  53. }
  54. .collapse-title {
  55. color: inherit;
  56. font-weight: bold;
  57. font-size: 18px;
  58. padding: 10px 20px;
  59. border-bottom: 2px solid;
  60. }
  61. .collapse-title>i {
  62. color: inherit;
  63. font-size: 24px;
  64. }
  65. .ant-collapse-content-box .ant-list-item {
  66. border-bottom: none !important;
  67. }
  68. </style>
  69. <body>
  70. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
  71. {{ template "commonSider" . }}
  72. <a-layout id="content-layout">
  73. <a-layout-content>
  74. <a-spin :spinning="spinning" :delay="500" tip='{{ i18n "loading"}}'>
  75. <transition name="list" appear>
  76. <a-alert type="error" v-if="confAlerts.length>0" style="margin-bottom: 10px;"
  77. message='{{ i18n "secAlertTitle" }}'
  78. color="red"
  79. show-icon closable>
  80. <template slot="description">
  81. <b>{{ i18n "secAlertConf" }}</b>
  82. <ul><li v-for="a in confAlerts">[[ a ]]</li></ul>
  83. </template>
  84. </a-alert>
  85. </transition>
  86. <a-space direction="vertical">
  87. <a-card hoverable style="margin-bottom: .5rem; overflow-x: hidden;">
  88. <a-row style="display: flex; flex-wrap: wrap; align-items: center;">
  89. <a-col :xs="24" :sm="10" style="padding: 4px;">
  90. <a-space direction="horizontal">
  91. <a-button type="primary" :disabled="saveBtnDisable" @click="updateAllSetting">{{ i18n "pages.settings.save" }}</a-button>
  92. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartPanel">{{ i18n "pages.settings.restartPanel" }}</a-button>
  93. </a-space>
  94. </a-col>
  95. <a-col :xs="24" :sm="14">
  96. <template>
  97. <div>
  98. <a-back-top :target="() => document.getElementById('content-layout')" visibility-height="200"></a-back-top>
  99. <a-alert type="warning" style="float: right; width: fit-content"
  100. message='{{ i18n "pages.settings.infoDesc" }}'
  101. show-icon>
  102. </a-alert>
  103. </div>
  104. </template>
  105. </a-col>
  106. </a-row>
  107. </a-card>
  108. <a-tabs default-active-key="1">
  109. <a-tab-pane key="1" tab='{{ i18n "pages.settings.panelSettings" }}' style="padding-top: 20px;">
  110. <a-collapse>
  111. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  112. <a-setting-list-item paddings="small">
  113. <template #title>
  114. {{ i18n "pages.settings.remarkModel"}}
  115. </template>
  116. <template #description>
  117. {{ i18n "pages.settings.sampleRemark"}}: <i>#[[ remarkSample ]]</i>
  118. </template>
  119. <template #control>
  120. <a-input-group style="width: 100%;">
  121. <a-select style="padding-right: .5rem; min-width: 80%; width: auto;"
  122. mode="multiple"
  123. v-model="remarkModel"
  124. :dropdown-class-name="themeSwitcher.currentTheme">
  125. <a-select-option v-for="(value, key) in remarkModels" :value="key">[[ value ]]</a-select-option>
  126. </a-select>
  127. <a-select style="width: 20%;" v-model="remarkSeparator" :dropdown-class-name="themeSwitcher.currentTheme">
  128. <a-select-option v-for="key in remarkSeparators" :value="key">[[ key ]]</a-select-option>
  129. </a-select>
  130. </a-input-group>
  131. </template>
  132. </a-setting-list-item>
  133. <a-setting-list-item paddings="small">
  134. <template #title>{{ i18n "pages.settings.panelListeningIP"}}</template>
  135. <template #description>{{ i18n "pages.settings.panelListeningIPDesc"}}</template>
  136. <template #control>
  137. <a-input type="text" v-model="allSetting.webListen"></a-input>
  138. </template>
  139. </a-setting-list-item>
  140. <a-setting-list-item paddings="small">
  141. <template #title>{{ i18n "pages.settings.panelListeningDomain"}}</template>
  142. <template #description>{{ i18n "pages.settings.panelListeningDomainDesc"}}</template>
  143. <template #control>
  144. <a-input type="text" v-model="allSetting.webDomain"></a-input>
  145. </template>
  146. </a-setting-list-item>
  147. <a-setting-list-item paddings="small">
  148. <template #title>{{ i18n "pages.settings.panelPort"}}</template>
  149. <template #description>{{ i18n "pages.settings.panelPortDesc"}}</template>
  150. <template #control>
  151. <a-input-number :min="1" :min="65531" v-model="allSetting.webPort" style="width: 100%;"></a-input>
  152. </template>
  153. </a-setting-list-item>
  154. <a-setting-list-item paddings="small">
  155. <template #title>{{ i18n "pages.settings.panelUrlPath"}}</template>
  156. <template #description>{{ i18n "pages.settings.panelUrlPathDesc"}}</template>
  157. <template #control>
  158. <a-input type="text" v-model="allSetting.webBasePath"></a-input>
  159. </template>
  160. </a-setting-list-item>
  161. <a-setting-list-item paddings="small">
  162. <template #title>{{ i18n "pages.settings.sessionMaxAge" }}</template>
  163. <template #description>{{ i18n "pages.settings.sessionMaxAgeDesc" }}</template>
  164. <template #control>
  165. <a-input-number :min="60" v-model="allSetting.sessionMaxAge" style="width: 100%;"></a-input>
  166. </template>
  167. </a-setting-list-item>
  168. <a-setting-list-item paddings="small">
  169. <template #title>{{ i18n "pages.settings.pageSize" }}</template>
  170. <template #description>{{ i18n "pages.settings.pageSizeDesc" }}</template>
  171. <template #control>
  172. <a-input-number :min="0" step="5" v-model="allSetting.pageSize" style="width: 100%;"></a-input>
  173. </template>
  174. </a-setting-list-item>
  175. <a-setting-list-item paddings="small">
  176. <template #title>{{ i18n "pages.settings.language"}}</template>
  177. <template #control>
  178. <a-select ref="selectLang"
  179. v-model="lang"
  180. @change="setLang(lang)"
  181. :dropdown-class-name="themeSwitcher.currentTheme"
  182. style="width: 100%">
  183. <a-select-option :value="l.value" :label="l.value" v-for="l in supportLangs">
  184. <span role="img" :aria-label="l.name" v-text="l.icon"></span> &nbsp;&nbsp; <span v-text="l.name"></span>
  185. </a-select-option>
  186. </a-select>
  187. </template>
  188. </a-setting-list-item>
  189. </a-collapse-panel>
  190. <a-collapse-panel header='{{ i18n "pages.settings.notifications" }}'>
  191. <a-setting-list-item paddings="small">
  192. <template #title>{{ i18n "pages.settings.expireTimeDiff" }}</template>
  193. <template #description>{{ i18n "pages.settings.expireTimeDiffDesc" }}</template>
  194. <template #control>
  195. <a-input-number :min="0" v-model="allSetting.expireDiff" style="width: 100%;"></a-input>
  196. </template>
  197. </a-setting-list-item>
  198. <a-setting-list-item paddings="small">
  199. <template #title>{{ i18n "pages.settings.trafficDiff" }}</template>
  200. <template #description>{{ i18n "pages.settings.trafficDiffDesc" }}</template>
  201. <template #control>
  202. <a-input-number :min="0" v-model="allSetting.trafficDiff" style="width: 100%;"></a-input>
  203. </template>
  204. </a-setting-list-item>
  205. </a-collapse-panel>
  206. <a-collapse-panel header='{{ i18n "pages.settings.certs" }}'>
  207. <a-setting-list-item paddings="small">
  208. <template #title>{{ i18n "pages.settings.publicKeyPath"}}</template>
  209. <template #description>{{ i18n "pages.settings.publicKeyPathDesc"}}</template>
  210. <template #control>
  211. <a-input type="text" v-model="allSetting.webCertFile"></a-input>
  212. </template>
  213. </a-setting-list-item>
  214. <a-setting-list-item paddings="small">
  215. <template #title>{{ i18n "pages.settings.privateKeyPath"}}</template>
  216. <template #description>{{ i18n "pages.settings.privateKeyPathDesc"}}</template>
  217. <template #control>
  218. <a-input type="text" v-model="allSetting.webKeyFile"></a-input>
  219. </template>
  220. </a-setting-list-item>
  221. </a-collapse-panel>
  222. <a-collapse-panel header='{{ i18n "pages.settings.externalTraffic" }}'>
  223. <a-setting-list-item paddings="small">
  224. <template #title>{{ i18n "pages.settings.externalTrafficInformEnable"}}</template>
  225. <template #description>{{ i18n "pages.settings.externalTrafficInformEnableDesc"}}</template>
  226. <template #control>
  227. <a-switch v-model="allSetting.externalTrafficInformEnable"></a-switch>
  228. </template>
  229. </a-setting-list-item>
  230. <a-setting-list-item paddings="small">
  231. <template #title>{{ i18n "pages.settings.externalTrafficInformURI"}}</template>
  232. <template #description>{{ i18n "pages.settings.externalTrafficInformURIDesc"}}</template>
  233. <template #control>
  234. <a-input type="text" placeholder="(http|https)://domain[:port]/path/" v-model="allSetting.externalTrafficInformURI"></a-input>
  235. </template>
  236. </a-setting-list-item>
  237. </a-collapse-panel>
  238. <a-collapse-panel header='{{ i18n "pages.settings.dateAndTime" }}'>
  239. <a-setting-list-item paddings="small">
  240. <template #title>{{ i18n "pages.settings.timeZone"}}</template>
  241. <template #description>{{ i18n "pages.settings.timeZoneDesc"}}</template>
  242. <template #control>
  243. <a-input type="text" v-model="allSetting.timeLocation"></a-input>
  244. </template>
  245. </a-setting-list-item>
  246. <a-setting-list-item paddings="small">
  247. <template #title>{{ i18n "pages.settings.datepicker"}}</template>
  248. <template #description>{{ i18n "pages.settings.datepickerDescription"}}</template>
  249. <template #control>
  250. <a-select style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme" v-model="datepicker">
  251. <a-select-option v-for="item in datepickerList" :value="item.value">
  252. <span v-text="item.name"></span>
  253. </a-select-option>
  254. </a-select>
  255. </template>
  256. </a-setting-list-item>
  257. </a-collapse-panel>
  258. </a-collapse>
  259. </a-tab-pane>
  260. <a-tab-pane key="2" tab='{{ i18n "pages.settings.securitySettings" }}' style="padding-top: 20px;">
  261. <a-collapse>
  262. <a-collapse-panel header='{{ i18n "pages.settings.security.admin"}}'>
  263. <a-setting-list-item paddings="small">
  264. <template #title>{{ i18n "pages.settings.oldUsername"}}</template>
  265. <template #control>
  266. <a-input autocomplete="username" v-model="user.oldUsername"></a-input>
  267. </template>
  268. </a-setting-list-item>
  269. <a-setting-list-item paddings="small">
  270. <template #title>{{ i18n "pages.settings.currentPassword"}}</template>
  271. <template #control>
  272. <password-input autocomplete="current-password" v-model="user.oldPassword"></password-input>
  273. </template>
  274. </a-setting-list-item>
  275. <a-setting-list-item paddings="small">
  276. <template #title>{{ i18n "pages.settings.newUsername"}}</template>
  277. <template #control>
  278. <a-input v-model="user.newUsername"></a-input>
  279. </template>
  280. </a-setting-list-item>
  281. <a-setting-list-item paddings="small">
  282. <template #title>{{ i18n "pages.settings.newPassword"}}</template>
  283. <template #control>
  284. <password-input autocomplete="new-password" v-model="user.newPassword"></password-input>
  285. </template>
  286. </a-setting-list-item>
  287. <a-list-item>
  288. <a-space direction="horizontal" style="padding: 0 20px;">
  289. <a-button type="primary" @click="updateUser">{{ i18n "confirm" }}</a-button>
  290. </a-space>
  291. </a-list-item>
  292. </a-collapse-panel>
  293. <a-collapse-panel header='{{ i18n "pages.settings.security.secret"}}'>
  294. <a-setting-list-item paddings="small">
  295. <template #title>{{ i18n "pages.settings.security.loginSecurity" }}</template>
  296. <template #description>{{ i18n "pages.settings.security.loginSecurityDesc" }}</template>
  297. <template #control>
  298. <a-switch @change="toggleToken(allSetting.secretEnable)" v-model="allSetting.secretEnable"></a-switch>
  299. <a-icon style="margin-left: 1rem;" v-if="allSetting.secretEnable" :spin="this.changeSecret" type="sync" @click="getNewSecret"></a-icon>
  300. </template>
  301. </a-setting-list-item>
  302. <a-setting-list-item paddings="small">
  303. <template #title>{{ i18n "pages.settings.security.secretToken" }}</template>
  304. <template #description>{{ i18n "pages.settings.security.secretTokenDesc" }}</template>
  305. <template #control>
  306. <a-textarea type="text" :disabled="!allSetting.secretEnable" v-model="user.loginSecret"></a-textarea>
  307. </template>
  308. </a-setting-list-item>
  309. <a-list-item>
  310. <a-space direction="horizontal" style="padding: 0 20px;">
  311. <a-button type="primary" :loading="this.changeSecret" @click="updateSecret">{{ i18n "confirm" }}</a-button>
  312. </a-space>
  313. </a-list-item>
  314. </a-collapse-panel>
  315. </a-collapse>
  316. </a-tab-pane>
  317. <a-tab-pane key="3" tab='{{ i18n "pages.settings.TGBotSettings" }}' style="padding-top: 20px;">
  318. <a-collapse>
  319. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  320. <a-setting-list-item paddings="small">
  321. <template #title>{{ i18n "pages.settings.telegramBotEnable" }}</template>
  322. <template #description>{{ i18n "pages.settings.telegramBotEnableDesc" }}</template>
  323. <template #control>
  324. <a-switch v-model="allSetting.tgBotEnable"></a-switch>
  325. </template>
  326. </a-setting-list-item>
  327. <a-setting-list-item paddings="small">
  328. <template #title>{{ i18n "pages.settings.telegramToken"}}</template>
  329. <template #description>{{ i18n "pages.settings.telegramTokenDesc"}}</template>
  330. <template #control>
  331. <a-input type="text" v-model="allSetting.tgBotToken"></a-input>
  332. </template>
  333. </a-setting-list-item>
  334. <a-setting-list-item paddings="small">
  335. <template #title>{{ i18n "pages.settings.telegramChatId"}}</template>
  336. <template #description>{{ i18n "pages.settings.telegramChatIdDesc"}}</template>
  337. <template #control>
  338. <a-input type="text" v-model="allSetting.tgBotChatId"></a-input>
  339. </template>
  340. </a-setting-list-item>
  341. <a-setting-list-item paddings="small">
  342. <template #title>{{ i18n "pages.settings.telegramBotLanguage"}}</template>
  343. <template #control>
  344. <a-select ref="selectBotLang" v-model="allSetting.tgLang" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  345. <a-select-option :value="l.value" :label="l.value" v-for="l in supportLangs">
  346. <span role="img" :aria-label="l.name" v-text="l.icon"></span> &nbsp;&nbsp; <span v-text="l.name"></span>
  347. </a-select-option>
  348. </a-select>
  349. </template>
  350. </a-setting-list-item>
  351. </a-collapse-panel>
  352. <a-collapse-panel header='{{ i18n "pages.settings.notifications" }}'>
  353. <a-setting-list-item paddings="small">
  354. <template #title>{{ i18n "pages.settings.telegramNotifyTime"}}</template>
  355. <template #description>{{ i18n "pages.settings.telegramNotifyTimeDesc"}}</template>
  356. <template #control>
  357. <a-input type="text" v-model="allSetting.tgRunTime"></a-input>
  358. </template>
  359. </a-setting-list-item>
  360. <a-setting-list-item paddings="small">
  361. <template #title>{{ i18n "pages.settings.tgNotifyBackup" }}</template>
  362. <template #description>{{ i18n "pages.settings.tgNotifyBackupDesc" }}</template>
  363. <template #control>
  364. <a-switch v-model="allSetting.tgBotBackup"></a-switch>
  365. </template>
  366. </a-setting-list-item>
  367. <a-setting-list-item paddings="small">
  368. <template #title>{{ i18n "pages.settings.tgNotifyLogin" }}</template>
  369. <template #description>{{ i18n "pages.settings.tgNotifyLoginDesc" }}</template>
  370. <template #control>
  371. <a-switch v-model="allSetting.tgBotLoginNotify"></a-switch>
  372. </template>
  373. </a-setting-list-item>
  374. <a-setting-list-item paddings="small">
  375. <template #title>{{ i18n "pages.settings.tgNotifyCpu" }}</template>
  376. <template #description>{{ i18n "pages.settings.tgNotifyCpuDesc" }}</template>
  377. <template #control>
  378. <a-input-number :min="0" :min="100" v-model="allSetting.tgCpu"></a-switch>
  379. </template>
  380. </a-setting-list-item>
  381. </a-collapse-panel>
  382. <a-collapse-panel header='{{ i18n "pages.settings.proxyAndServer" }}'>
  383. <a-setting-list-item paddings="small">
  384. <template #title>{{ i18n "pages.settings.telegramProxy"}}</template>
  385. <template #description>{{ i18n "pages.settings.telegramProxyDesc"}}</template>
  386. <template #control>
  387. <a-input type="text" placeholder="socks5://user:pass@host:port" v-model="allSetting.tgBotProxy"></a-input>
  388. </template>
  389. </a-setting-list-item>
  390. <a-setting-list-item paddings="small">
  391. <template #title>{{ i18n "pages.settings.telegramAPIServer"}}</template>
  392. <template #description>{{ i18n "pages.settings.telegramAPIServerDesc"}}</template>
  393. <template #control>
  394. <a-input type="text" placeholder="https://api.example.com" v-model="allSetting.tgBotAPIServer"></a-input>
  395. </template>
  396. </a-setting-list-item>
  397. </a-collapse-panel>
  398. </a-collapse>
  399. </a-tab-pane>
  400. <a-tab-pane key="4" tab='{{ i18n "pages.settings.subSettings" }}' style="padding-top: 20px;">
  401. <a-collapse>
  402. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  403. <a-setting-list-item paddings="small">
  404. <template #title>{{ i18n "pages.settings.subEnable"}}</template>
  405. <template #description>{{ i18n "pages.settings.subEnableDesc"}}</template>
  406. <template #control>
  407. <a-switch v-model="allSetting.subEnable"></a-switch>
  408. </template>
  409. </a-setting-list-item>
  410. <a-setting-list-item paddings="small">
  411. <template #title>{{ i18n "pages.settings.subListen"}}</template>
  412. <template #description>{{ i18n "pages.settings.subListenDesc"}}</template>
  413. <template #control>
  414. <a-input type="text" v-model="allSetting.subListen"></a-input>
  415. </template>
  416. </a-setting-list-item>
  417. <a-setting-list-item paddings="small">
  418. <template #title>{{ i18n "pages.settings.subDomain"}}</template>
  419. <template #description>{{ i18n "pages.settings.subDomainDesc"}}</template>
  420. <template #control>
  421. <a-input type="text" v-model="allSetting.subDomain"></a-input>
  422. </template>
  423. </a-setting-list-item>
  424. <a-setting-list-item paddings="small">
  425. <template #title>{{ i18n "pages.settings.subPort"}}</template>
  426. <template #description>{{ i18n "pages.settings.subPortDesc"}}</template>
  427. <template #control>
  428. <a-input-number v-model="allSetting.subPort" :min="1" :min="65531" style="width: 100%;"></a-input-number>
  429. </template>
  430. </a-setting-list-item>
  431. <a-setting-list-item paddings="small">
  432. <template #title>{{ i18n "pages.settings.subPath"}}</template>
  433. <template #description>{{ i18n "pages.settings.subPathDesc"}}</template>
  434. <template #control>
  435. <a-input type="text" v-model="allSetting.subPath"></a-input>
  436. </template>
  437. </a-setting-list-item>
  438. <a-setting-list-item paddings="small">
  439. <template #title>{{ i18n "pages.settings.subURI"}}</template>
  440. <template #description>{{ i18n "pages.settings.subURIDesc"}}</template>
  441. <template #control>
  442. <a-input type="text" placeholder="(http|https)://domain[:port]/path/" v-model="allSetting.subURI"></a-input>
  443. </template>
  444. </a-setting-list-item>
  445. </a-collapse-panel>
  446. <a-collapse-panel header='{{ i18n "pages.settings.information" }}'>
  447. <a-setting-list-item paddings="small">
  448. <template #title>{{ i18n "pages.settings.subEncrypt"}}</template>
  449. <template #description>{{ i18n "pages.settings.subEncryptDesc"}}</template>
  450. <template #control>
  451. <a-switch v-model="allSetting.subEncrypt"></a-switch>
  452. </template>
  453. </a-setting-list-item>
  454. <a-setting-list-item paddings="small">
  455. <template #title>{{ i18n "pages.settings.subShowInfo"}}</template>
  456. <template #description>{{ i18n "pages.settings.subShowInfoDesc"}}</template>
  457. <template #control>
  458. <a-switch v-model="allSetting.subShowInfo"></a-switch>
  459. </template>
  460. </a-setting-list-item>
  461. </a-collapse-panel>
  462. <a-collapse-panel header='{{ i18n "pages.settings.certs" }}'>
  463. <a-setting-list-item paddings="small">
  464. <template #title>{{ i18n "pages.settings.subCertPath"}}</template>
  465. <template #description>{{ i18n "pages.settings.subCertPathDesc"}}</template>
  466. <template #control>
  467. <a-input type="text" v-model="allSetting.subCertFile"></a-input>
  468. </template>
  469. </a-setting-list-item>
  470. <a-setting-list-item paddings="small">
  471. <template #title>{{ i18n "pages.settings.subKeyPath"}}</template>
  472. <template #description>{{ i18n "pages.settings.subKeyPathDesc"}}</template>
  473. <template #control>
  474. <a-input type="text" v-model="allSetting.subKeyFile"></a-input>
  475. </template>
  476. </a-setting-list-item>
  477. </a-collapse-panel>
  478. <a-collapse-panel header='{{ i18n "pages.settings.intervals"}}'>
  479. <a-setting-list-item paddings="small">
  480. <template #title>{{ i18n "pages.settings.subUpdates"}}</template>
  481. <template #description>{{ i18n "pages.settings.subUpdatesDesc"}}</template>
  482. <template #control>
  483. <a-input-number :min="1" v-model="allSetting.subUpdates" style="width: 100%;"></a-input-number>
  484. </template>
  485. </a-setting-list-item>
  486. </a-collapse-panel>
  487. </a-collapse>
  488. </a-tab-pane>
  489. <a-tab-pane key="5" tab='{{ i18n "pages.settings.subSettings" }} Json' v-if="allSetting.subEnable" style="padding-top: 20px;">
  490. <a-collapse>
  491. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  492. <a-setting-list-item paddings="small">
  493. <template #title>{{ i18n "pages.settings.subPath"}}</template>
  494. <template #description>{{ i18n "pages.settings.subPathDesc"}}</template>
  495. <template #control>
  496. <a-input type="text" v-model="allSetting.subJsonPath"></a-input>
  497. </template>
  498. </a-setting-list-item>
  499. <a-setting-list-item paddings="small">
  500. <template #title>{{ i18n "pages.settings.subURI"}}</template>
  501. <template #description>{{ i18n "pages.settings.subURIDesc"}}</template>
  502. <template #control>
  503. <a-input type="text" placeholder="(http|https)://domain[:port]/path/" v-model="allSetting.subJsonURI"></a-input>
  504. </template>
  505. </a-setting-list-item>
  506. </a-collapse-panel>
  507. <a-collapse-panel header='{{ i18n "pages.settings.fragment"}}'>
  508. <a-setting-list-item paddings="small">
  509. <template #title>{{ i18n "pages.settings.fragment"}}</template>
  510. <template #description>{{ i18n "pages.settings.fragmentDesc"}}</template>
  511. <template #control>
  512. <a-switch v-model="fragment"></a-switch>
  513. </template>
  514. </a-setting-list-item>
  515. <a-list-item v-if="fragment" style="padding: 10px 20px;">
  516. <a-collapse>
  517. <a-collapse-panel header='{{ i18n "pages.settings.fragmentSett"}}' v-if="fragment">
  518. <a-setting-list-item paddings="small">
  519. <template #title>Packets</template>
  520. <template #control>
  521. <a-input type="text" v-model="fragmentPackets" placeholder="1-1 | 1-3 | tlshello | ..."></a-input>
  522. </template>
  523. </a-setting-list-item>
  524. <a-setting-list-item paddings="small">
  525. <template #title>Length</template>
  526. <template #control>
  527. <a-input type="text" v-model="fragmentLength" placeholder="100-200"></a-input>
  528. </template>
  529. </a-setting-list-item>
  530. <a-setting-list-item paddings="small">
  531. <template #title>Interval</template>
  532. <template #control>
  533. <a-input type="text" v-model="fragmentInterval" placeholder="10-20"></a-input>
  534. </template>
  535. </a-setting-list-item>
  536. </a-collapse-panel>
  537. </a-collapse>
  538. </a-list-item>
  539. </a-collapse-panel>
  540. <a-collapse-panel header="Noises">
  541. <a-setting-list-item paddings="small">
  542. <template #title>Noises</template>
  543. <template #description>{{ i18n "pages.settings.noisesDesc"}}</template>
  544. <template #control>
  545. <a-switch v-model="noises"></a-switch>
  546. </template>
  547. </a-setting-list-item>
  548. <a-list-item v-if="noises" style="padding: 10px 20px;">
  549. <a-collapse>
  550. <a-collapse-panel v-for="(noise, index) in noisesArray" :key="index" :header="`Noise №${index + 1}`">
  551. <a-setting-list-item paddings="small">
  552. <template #title>Type</template>
  553. <template #control>
  554. <a-select :value="noise.type" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme"
  555. @change="(value) => updateNoiseType(index, value)">
  556. <a-select-option :value="p" :label="p" v-for="p in ['rand', 'base64', 'str', 'hex']" :key="p">
  557. [[ p ]] </a-select-option>
  558. </a-select>
  559. </template>
  560. </a-setting-list-item>
  561. <a-setting-list-item paddings="small">
  562. <template #title>Packet</template>
  563. <template #control>
  564. <a-input type="text" :value="noise.packet" @input="(value) => updateNoisePacket(index, event.target.value)" placeholder="5-10"></a-input>
  565. </template>
  566. </a-setting-list-item>
  567. <a-setting-list-item paddings="small">
  568. <template #title>Delay (ms)</template>
  569. <template #control>
  570. <a-input type="text" :value="noise.delay" @input="(value) => updateNoiseDelay(index, event.target.value)" placeholder="10-20"></a-input>
  571. </template>
  572. </a-setting-list-item>
  573. <a-space direction="horizontal" style="padding: 10px 20px;">
  574. <a-button v-if="noisesArray.length > 1" type="danger" @click="removeNoise(index)">Remove</a-button>
  575. </a-space>
  576. </a-collapse-panel>
  577. </a-collapse>
  578. <a-button v-if="noises" type="primary" @click="addNoise" style="margin-top: 10px">Add Noise</a-button>
  579. </a-list-item>
  580. </a-collapse-panel>
  581. <a-collapse-panel header='{{ i18n "pages.settings.mux"}}'>
  582. <a-setting-list-item paddings="small">
  583. <template #title>{{ i18n "pages.settings.mux"}}</template>
  584. <template #description>{{ i18n "pages.settings.muxDesc"}}</template>
  585. <template #control>
  586. <a-switch v-model="enableMux"></a-switch>
  587. </template>
  588. </a-setting-list-item>
  589. <a-list-item v-if="enableMux" style="padding: 10px 20px;">
  590. <a-collapse>
  591. <a-collapse-panel header='{{ i18n "pages.settings.muxSett"}}'>
  592. <a-setting-list-item paddings="small">
  593. <template #title>Concurrency</template>
  594. <template #control>
  595. <a-input-number v-model="muxConcurrency" :min="-1" :max="1024" style="width: 100%;"></a-input-number>
  596. </template>
  597. </a-setting-list-item>
  598. <a-setting-list-item paddings="small">
  599. <template #title>xudp Concurrency</template>
  600. <template #control>
  601. <a-input-number v-model="muxXudpConcurrency" :min="-1" :max="1024" style="width: 100%;"></a-input-number>
  602. </template>
  603. </a-setting-list-item>
  604. <a-setting-list-item paddings="small">
  605. <template #title>xudp UDP 443</template>
  606. <template #control>
  607. <a-select v-model="muxXudpProxyUDP443" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme">
  608. <a-select-option :value="p" :label="p" v-for="p in ['reject', 'allow', 'skip']"> [[ p ]] </a-select-option>
  609. </a-select>
  610. </template>
  611. </a-setting-list-item>
  612. </a-collapse-panel>
  613. </a-collapse>
  614. </a-list-item>
  615. </a-collapse-panel>
  616. <a-collapse-panel header='{{ i18n "pages.settings.direct" }}'>
  617. <a-setting-list-item paddings="small">
  618. <template #title>{{ i18n "pages.settings.direct"}}</template>
  619. <template #description>{{ i18n "pages.settings.directDesc"}}</template>
  620. <template #control>
  621. <a-switch v-model="enableDirect"></a-switch>
  622. </template>
  623. </a-setting-list-item>
  624. <a-list-item v-if="enableDirect" style="padding: 10px 20px;">
  625. <a-collapse>
  626. <a-collapse-panel header='{{ i18n "pages.settings.direct"}}'>
  627. <a-setting-list-item paddings="small">
  628. <template #title>{{ i18n "pages.xray.directips" }}</template>
  629. <template #control>
  630. <a-select mode="tags" style="width: 100%" v-model="directIPs" :dropdown-class-name="themeSwitcher.currentTheme">
  631. <a-select-option :value="p.value" :label="p.label" v-for="p in directIPsOptions">[[ p.label ]]</a-select-option>
  632. </a-select>
  633. </template>
  634. </a-setting-list-item>
  635. <a-setting-list-item paddings="small">
  636. <template #title>{{ i18n "pages.xray.directdomains" }}</template>
  637. <template #control>
  638. <a-select mode="tags" style="width: 100%" v-model="directDomains" :dropdown-class-name="themeSwitcher.currentTheme">
  639. <a-select-option :value="p.value" :label="p.label" v-for="p in diretDomainsOptions">[[ p.label ]]</a-select-option>
  640. </a-select>
  641. </template>
  642. </a-setting-list-item>
  643. </a-collapse-panel>
  644. </a-collapse>
  645. </a-list-item>
  646. </a-collapse-panel>
  647. </a-collapse>
  648. </a-tab-pane>
  649. </a-tabs>
  650. </a-space>
  651. </a-spin>
  652. </a-layout-content>
  653. </a-layout>
  654. </a-layout>
  655. {{template "js" .}}
  656. <script src="{{ .base_path }}assets/js/model/setting.js?{{ .cur_ver }}"></script>
  657. {{template "component/themeSwitcher" .}}
  658. {{template "component/password" .}}
  659. {{template "component/setting"}}
  660. <script>
  661. const app = new Vue({
  662. delimiters: ['[[', ']]'],
  663. el: '#app',
  664. data: {
  665. siderDrawer,
  666. themeSwitcher,
  667. spinning: false,
  668. changeSecret: false,
  669. oldAllSetting: new AllSetting(),
  670. allSetting: new AllSetting(),
  671. saveBtnDisable: true,
  672. user: {},
  673. lang: getLang(),
  674. remarkModels: { i: 'Inbound', e: 'Email', o: 'Other' },
  675. remarkSeparators: [' ', '-', '_', '@', ':', '~', '|', ',', '.', '/'],
  676. datepickerList: [{ name: 'Gregorian (Standard)', value: 'gregorian' }, { name: 'Jalalian (شمسی)', value: 'jalalian' }],
  677. remarkSample: '',
  678. defaultFragment: {
  679. tag: "fragment",
  680. protocol: "freedom",
  681. settings: {
  682. domainStrategy: "AsIs",
  683. fragment: {
  684. packets: "tlshello",
  685. length: "100-200",
  686. interval: "10-20"
  687. }
  688. },
  689. streamSettings: {
  690. sockopt: {
  691. tcpKeepAliveIdle: 100,
  692. tcpMptcp: true,
  693. penetrate: true
  694. }
  695. }
  696. },
  697. defaultNoises: {
  698. tag: "noises",
  699. protocol: "freedom",
  700. settings: {
  701. domainStrategy: "AsIs",
  702. noises: [
  703. { type: "rand", packet: "10-20", delay: "10-16" },
  704. ],
  705. },
  706. },
  707. defaultMux: {
  708. enabled: true,
  709. concurrency: 8,
  710. xudpConcurrency: 16,
  711. xudpProxyUDP443: "reject"
  712. },
  713. defaultRules: [
  714. {
  715. type: "field",
  716. outboundTag: "direct",
  717. domain: [
  718. "geosite:category-ir"
  719. ]
  720. },
  721. {
  722. type: "field",
  723. outboundTag: "direct",
  724. ip: [
  725. "geoip:private",
  726. "geoip:ir"
  727. ]
  728. },
  729. ],
  730. directIPsOptions: [
  731. { label: 'Private IP', value: 'geoip:private' },
  732. { label: '🇮🇷 Iran', value: 'geoip:ir' },
  733. { label: '🇨🇳 China', value: 'geoip:cn' },
  734. { label: '🇷🇺 Russia', value: 'geoip:ru' },
  735. { label: '🇻🇳 Vietnam', value: 'geoip:vn' },
  736. { label: '🇪🇸 Spain', value: 'geoip:es' },
  737. { label: '🇮🇩 Indonesia', value: 'geoip:id' },
  738. { label: '🇺🇦 Ukraine', value: 'geoip:ua' },
  739. { label: '🇹🇷 Türkiye', value: 'geoip:tr' },
  740. { label: '🇧🇷 Brazil', value: 'geoip:br' },
  741. ],
  742. diretDomainsOptions: [
  743. { label: 'Private DNS', value: 'geosite:private' },
  744. { label: '🇮🇷 Iran', value: 'geosite:category-ir' },
  745. { label: '🇨🇳 China', value: 'geosite:cn' },
  746. { label: '🇷🇺 Russia', value: 'geosite:category-ru' },
  747. { label: 'Apple', value: 'geosite:apple' },
  748. { label: 'Meta', value: 'geosite:meta' },
  749. { label: 'Google', value: 'geosite:google' },
  750. ],
  751. get remarkModel() {
  752. rm = this.allSetting.remarkModel;
  753. return rm.length > 1 ? rm.substring(1).split('') : [];
  754. },
  755. set remarkModel(value) {
  756. rs = this.allSetting.remarkModel[0];
  757. this.allSetting.remarkModel = rs + value.join('');
  758. this.changeRemarkSample();
  759. },
  760. get remarkSeparator() {
  761. return this.allSetting.remarkModel.length > 1 ? this.allSetting.remarkModel.charAt(0) : '-';
  762. },
  763. set remarkSeparator(value) {
  764. this.allSetting.remarkModel = value + this.allSetting.remarkModel.substring(1);
  765. this.changeRemarkSample();
  766. },
  767. get datepicker() {
  768. return this.allSetting.datepicker ? this.allSetting.datepicker : 'gregorian';
  769. },
  770. set datepicker(value) {
  771. this.allSetting.datepicker = value;
  772. },
  773. changeRemarkSample() {
  774. sample = []
  775. this.remarkModel.forEach(r => sample.push(this.remarkModels[r]));
  776. this.remarkSample = sample.length == 0 ? '' : sample.join(this.remarkSeparator);
  777. }
  778. },
  779. methods: {
  780. loading(spinning = true) {
  781. this.spinning = spinning;
  782. },
  783. async getAllSetting() {
  784. this.loading(true);
  785. const msg = await HttpUtil.post("/panel/setting/all");
  786. this.loading(false);
  787. if (msg.success) {
  788. this.oldAllSetting = new AllSetting(msg.obj);
  789. this.allSetting = new AllSetting(msg.obj);
  790. app.changeRemarkSample();
  791. this.saveBtnDisable = true;
  792. }
  793. await this.fetchUserSecret();
  794. },
  795. async updateAllSetting() {
  796. this.loading(true);
  797. const msg = await HttpUtil.post("/panel/setting/update", this.allSetting);
  798. this.loading(false);
  799. if (msg.success) {
  800. await this.getAllSetting();
  801. }
  802. },
  803. async updateUser() {
  804. this.loading(true);
  805. const msg = await HttpUtil.post("/panel/setting/updateUser", this.user);
  806. this.loading(false);
  807. if (msg.success) {
  808. this.user = {};
  809. window.location.replace(basePath + "logout");
  810. }
  811. },
  812. async restartPanel() {
  813. await new Promise(resolve => {
  814. this.$confirm({
  815. title: '{{ i18n "pages.settings.restartPanel" }}',
  816. content: '{{ i18n "pages.settings.restartPanelDesc" }}',
  817. class: themeSwitcher.currentTheme,
  818. okText: '{{ i18n "sure" }}',
  819. cancelText: '{{ i18n "cancel" }}',
  820. onOk: () => resolve(),
  821. });
  822. });
  823. this.loading(true);
  824. const msg = await HttpUtil.post("/panel/setting/restartPanel");
  825. this.loading(false);
  826. if (msg.success) {
  827. this.loading(true);
  828. await PromiseUtil.sleep(5000);
  829. var { webCertFile, webKeyFile, webDomain: host, webPort: port, webBasePath: base } = this.allSetting;
  830. if (host == this.oldAllSetting.webDomain) host = null;
  831. if (port == this.oldAllSetting.webPort) port = null;
  832. const isTLS = webCertFile !== "" || webKeyFile !== "";
  833. const url = URLBuilder.buildURL({ host, port, isTLS, base, path: "panel/settings" });
  834. window.location.replace(url);
  835. }
  836. },
  837. async fetchUserSecret() {
  838. this.loading(true);
  839. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  840. if (userMessage.success) {
  841. this.user = userMessage.obj;
  842. }
  843. this.loading(false);
  844. },
  845. async updateSecret() {
  846. this.loading(true);
  847. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  848. if (msg && msg.obj) {
  849. this.user = msg.obj;
  850. }
  851. this.loading(false);
  852. await this.updateAllSetting();
  853. },
  854. generateRandomString(length) {
  855. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  856. let randomString = "";
  857. for (let i = 0; i < length; i++) {
  858. randomString += chars[Math.floor(Math.random() * chars.length)];
  859. }
  860. return randomString;
  861. },
  862. async getNewSecret() {
  863. if (!this.changeSecret) {
  864. this.changeSecret = true;
  865. this.user.loginSecret = '';
  866. const newSecret = this.generateRandomString(64);
  867. await PromiseUtil.sleep(1000);
  868. this.user.loginSecret = newSecret;
  869. this.changeSecret = false;
  870. }
  871. },
  872. async toggleToken(value) {
  873. if (value) {
  874. await this.getNewSecret();
  875. } else {
  876. this.user.loginSecret = "";
  877. }
  878. },
  879. addNoise() {
  880. const newNoise = { type: "rand", packet: "10-20", delay: "10-16" };
  881. this.noisesArray = [...this.noisesArray, newNoise];
  882. },
  883. removeNoise(index) {
  884. const newNoises = [...this.noisesArray];
  885. newNoises.splice(index, 1);
  886. this.noisesArray = newNoises;
  887. },
  888. updateNoiseType(index, value) {
  889. const updatedNoises = [...this.noisesArray];
  890. updatedNoises[index] = { ...updatedNoises[index], type: value };
  891. this.noisesArray = updatedNoises;
  892. },
  893. updateNoisePacket(index, value) {
  894. const updatedNoises = [...this.noisesArray];
  895. updatedNoises[index] = { ...updatedNoises[index], packet: value };
  896. this.noisesArray = updatedNoises;
  897. },
  898. updateNoiseDelay(index, value) {
  899. const updatedNoises = [...this.noisesArray];
  900. updatedNoises[index] = { ...updatedNoises[index], delay: value };
  901. this.noisesArray = updatedNoises;
  902. },
  903. },
  904. computed: {
  905. fragment: {
  906. get: function () { return this.allSetting?.subJsonFragment != ""; },
  907. set: function (v) {
  908. this.allSetting.subJsonFragment = v ? JSON.stringify(this.defaultFragment) : "";
  909. }
  910. },
  911. fragmentPackets: {
  912. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.packets : ""; },
  913. set: function (v) {
  914. if (v != "") {
  915. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  916. newFragment.settings.fragment.packets = v;
  917. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  918. }
  919. }
  920. },
  921. fragmentLength: {
  922. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.length : ""; },
  923. set: function (v) {
  924. if (v != "") {
  925. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  926. newFragment.settings.fragment.length = v;
  927. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  928. }
  929. }
  930. },
  931. fragmentInterval: {
  932. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.interval : ""; },
  933. set: function (v) {
  934. if (v != "") {
  935. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  936. newFragment.settings.fragment.interval = v;
  937. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  938. }
  939. }
  940. },
  941. noises: {
  942. get() {
  943. return this.allSetting?.subJsonNoises != "";
  944. },
  945. set(v) {
  946. if (v) {
  947. this.allSetting.subJsonNoises = JSON.stringify(this.defaultNoises);
  948. } else {
  949. this.allSetting.subJsonNoises = "";
  950. }
  951. }
  952. },
  953. noisesArray: {
  954. get() {
  955. return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises : [];
  956. },
  957. set(value) {
  958. if (this.noises) {
  959. const newNoises = JSON.parse(this.allSetting.subJsonNoises);
  960. newNoises.settings.noises = value;
  961. this.allSetting.subJsonNoises = JSON.stringify(newNoises);
  962. }
  963. }
  964. },
  965. enableMux: {
  966. get: function () { return this.allSetting?.subJsonMux != ""; },
  967. set: function (v) {
  968. this.allSetting.subJsonMux = v ? JSON.stringify(this.defaultMux) : "";
  969. }
  970. },
  971. muxConcurrency: {
  972. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).concurrency : -1; },
  973. set: function (v) {
  974. newMux = JSON.parse(this.allSetting.subJsonMux);
  975. newMux.concurrency = v;
  976. this.allSetting.subJsonMux = JSON.stringify(newMux);
  977. }
  978. },
  979. muxXudpConcurrency: {
  980. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpConcurrency : -1; },
  981. set: function (v) {
  982. newMux = JSON.parse(this.allSetting.subJsonMux);
  983. newMux.xudpConcurrency = v;
  984. this.allSetting.subJsonMux = JSON.stringify(newMux);
  985. }
  986. },
  987. muxXudpProxyUDP443: {
  988. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpProxyUDP443 : "reject"; },
  989. set: function (v) {
  990. newMux = JSON.parse(this.allSetting.subJsonMux);
  991. newMux.xudpProxyUDP443 = v;
  992. this.allSetting.subJsonMux = JSON.stringify(newMux);
  993. }
  994. },
  995. enableDirect: {
  996. get: function () { return this.allSetting?.subJsonRules != ""; },
  997. set: function (v) {
  998. this.allSetting.subJsonRules = v ? JSON.stringify(this.defaultRules) : "";
  999. }
  1000. },
  1001. directIPs: {
  1002. get: function () {
  1003. if (!this.enableDirect) return [];
  1004. const rules = JSON.parse(this.allSetting.subJsonRules);
  1005. if (!Array.isArray(rules)) return [];
  1006. const ipRule = rules.find(r => r.ip);
  1007. return ipRule?.ip ?? [];
  1008. },
  1009. set: function (v) {
  1010. let rules = JSON.parse(this.allSetting.subJsonRules);
  1011. if (!Array.isArray(rules)) return;
  1012. if (v.length == 0) {
  1013. rules = rules.filter(r => !r.ip);
  1014. } else {
  1015. let ruleIndex = rules.findIndex(r => r.ip);
  1016. if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[1]) - 1;
  1017. rules[ruleIndex].ip = [];
  1018. v.forEach(d => {
  1019. rules[ruleIndex].ip.push(d);
  1020. });
  1021. }
  1022. this.allSetting.subJsonRules = JSON.stringify(rules);
  1023. }
  1024. },
  1025. directDomains: {
  1026. get: function () {
  1027. if (!this.enableDirect) return [];
  1028. const rules = JSON.parse(this.allSetting.subJsonRules);
  1029. if (!Array.isArray(rules)) return [];
  1030. const domainRule = rules.find(r => r.domain);
  1031. return domainRule?.domain ?? [];
  1032. },
  1033. set: function (v) {
  1034. let rules = JSON.parse(this.allSetting.subJsonRules);
  1035. if (!Array.isArray(rules)) return;
  1036. if (v.length == 0) {
  1037. rules = rules.filter(r => !r.domain);
  1038. } else {
  1039. let ruleIndex = rules.findIndex(r => r.domain);
  1040. if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[0]) - 1;
  1041. rules[ruleIndex].domain = v;
  1042. }
  1043. this.allSetting.subJsonRules = JSON.stringify(rules);
  1044. }
  1045. },
  1046. confAlerts: {
  1047. get: function () {
  1048. if (!this.allSetting) return [];
  1049. var alerts = []
  1050. if (window.location.protocol !== "https:") alerts.push('{{ i18n "secAlertSSL" }}');
  1051. if (this.allSetting.webPort == 54321) alerts.push('{{ i18n "secAlertPanelPort" }}');
  1052. panelPath = window.location.pathname.split('/').length < 4
  1053. if (panelPath && this.allSetting.webBasePath == '/') alerts.push('{{ i18n "secAlertPanelURI" }}');
  1054. if (this.allSetting.subEnable) {
  1055. subPath = this.allSetting.subURI.length > 0 ? new URL(this.allSetting.subURI).pathname : this.allSetting.subPath;
  1056. if (subPath == '/sub/') alerts.push('{{ i18n "secAlertSubURI" }}');
  1057. subJsonPath = this.allSetting.subJsonURI.length > 0 ? new URL(this.allSetting.subJsonURI).pathname : this.allSetting.subJsonPath;
  1058. if (subJsonPath == '/json/') alerts.push('{{ i18n "secAlertSubJsonURI" }}');
  1059. }
  1060. return alerts
  1061. }
  1062. }
  1063. },
  1064. async mounted() {
  1065. await this.getAllSetting();
  1066. while (true) {
  1067. await PromiseUtil.sleep(1000);
  1068. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  1069. }
  1070. }
  1071. });
  1072. </script>
  1073. </body>
  1074. </html>