1
0

settings.html 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  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="LanguageManager.setLanguage(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 LanguageManager.supportedLanguages">
  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. <a-password-input autocomplete="current-password" v-model="user.oldPassword"></a-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. <a-password-input autocomplete="new-password" v-model="user.newPassword"></a-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 LanguageManager.supportedLanguages">
  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" style="width: 100%;"></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.subTitle"}}</template>
  412. <template #description>{{ i18n "pages.settings.subTitleDesc"}}</template>
  413. <template #control>
  414. <a-input type="text" v-model="allSetting.subTitle"></a-input>
  415. </template>
  416. </a-setting-list-item>
  417. <a-setting-list-item paddings="small">
  418. <template #title>{{ i18n "pages.settings.subListen"}}</template>
  419. <template #description>{{ i18n "pages.settings.subListenDesc"}}</template>
  420. <template #control>
  421. <a-input type="text" v-model="allSetting.subListen"></a-input>
  422. </template>
  423. </a-setting-list-item>
  424. <a-setting-list-item paddings="small">
  425. <template #title>{{ i18n "pages.settings.subDomain"}}</template>
  426. <template #description>{{ i18n "pages.settings.subDomainDesc"}}</template>
  427. <template #control>
  428. <a-input type="text" v-model="allSetting.subDomain"></a-input>
  429. </template>
  430. </a-setting-list-item>
  431. <a-setting-list-item paddings="small">
  432. <template #title>{{ i18n "pages.settings.subPort"}}</template>
  433. <template #description>{{ i18n "pages.settings.subPortDesc"}}</template>
  434. <template #control>
  435. <a-input-number v-model="allSetting.subPort" :min="1" :min="65531" style="width: 100%;"></a-input-number>
  436. </template>
  437. </a-setting-list-item>
  438. <a-setting-list-item paddings="small">
  439. <template #title>{{ i18n "pages.settings.subPath"}}</template>
  440. <template #description>{{ i18n "pages.settings.subPathDesc"}}</template>
  441. <template #control>
  442. <a-input type="text" v-model="allSetting.subPath"></a-input>
  443. </template>
  444. </a-setting-list-item>
  445. <a-setting-list-item paddings="small">
  446. <template #title>{{ i18n "pages.settings.subURI"}}</template>
  447. <template #description>{{ i18n "pages.settings.subURIDesc"}}</template>
  448. <template #control>
  449. <a-input type="text" placeholder="(http|https)://domain[:port]/path/" v-model="allSetting.subURI"></a-input>
  450. </template>
  451. </a-setting-list-item>
  452. </a-collapse-panel>
  453. <a-collapse-panel header='{{ i18n "pages.settings.information" }}'>
  454. <a-setting-list-item paddings="small">
  455. <template #title>{{ i18n "pages.settings.subEncrypt"}}</template>
  456. <template #description>{{ i18n "pages.settings.subEncryptDesc"}}</template>
  457. <template #control>
  458. <a-switch v-model="allSetting.subEncrypt"></a-switch>
  459. </template>
  460. </a-setting-list-item>
  461. <a-setting-list-item paddings="small">
  462. <template #title>{{ i18n "pages.settings.subShowInfo"}}</template>
  463. <template #description>{{ i18n "pages.settings.subShowInfoDesc"}}</template>
  464. <template #control>
  465. <a-switch v-model="allSetting.subShowInfo"></a-switch>
  466. </template>
  467. </a-setting-list-item>
  468. </a-collapse-panel>
  469. <a-collapse-panel header='{{ i18n "pages.settings.certs" }}'>
  470. <a-setting-list-item paddings="small">
  471. <template #title>{{ i18n "pages.settings.subCertPath"}}</template>
  472. <template #description>{{ i18n "pages.settings.subCertPathDesc"}}</template>
  473. <template #control>
  474. <a-input type="text" v-model="allSetting.subCertFile"></a-input>
  475. </template>
  476. </a-setting-list-item>
  477. <a-setting-list-item paddings="small">
  478. <template #title>{{ i18n "pages.settings.subKeyPath"}}</template>
  479. <template #description>{{ i18n "pages.settings.subKeyPathDesc"}}</template>
  480. <template #control>
  481. <a-input type="text" v-model="allSetting.subKeyFile"></a-input>
  482. </template>
  483. </a-setting-list-item>
  484. </a-collapse-panel>
  485. <a-collapse-panel header='{{ i18n "pages.settings.intervals"}}'>
  486. <a-setting-list-item paddings="small">
  487. <template #title>{{ i18n "pages.settings.subUpdates"}}</template>
  488. <template #description>{{ i18n "pages.settings.subUpdatesDesc"}}</template>
  489. <template #control>
  490. <a-input-number :min="1" v-model="allSetting.subUpdates" style="width: 100%;"></a-input-number>
  491. </template>
  492. </a-setting-list-item>
  493. </a-collapse-panel>
  494. </a-collapse>
  495. </a-tab-pane>
  496. <a-tab-pane key="5" tab='{{ i18n "pages.settings.subSettings" }} Json' v-if="allSetting.subEnable" style="padding-top: 20px;">
  497. <a-collapse>
  498. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  499. <a-setting-list-item paddings="small">
  500. <template #title>{{ i18n "pages.settings.subPath"}}</template>
  501. <template #description>{{ i18n "pages.settings.subPathDesc"}}</template>
  502. <template #control>
  503. <a-input type="text" v-model="allSetting.subJsonPath"></a-input>
  504. </template>
  505. </a-setting-list-item>
  506. <a-setting-list-item paddings="small">
  507. <template #title>{{ i18n "pages.settings.subURI"}}</template>
  508. <template #description>{{ i18n "pages.settings.subURIDesc"}}</template>
  509. <template #control>
  510. <a-input type="text" placeholder="(http|https)://domain[:port]/path/" v-model="allSetting.subJsonURI"></a-input>
  511. </template>
  512. </a-setting-list-item>
  513. </a-collapse-panel>
  514. <a-collapse-panel header='{{ i18n "pages.settings.fragment"}}'>
  515. <a-setting-list-item paddings="small">
  516. <template #title>{{ i18n "pages.settings.fragment"}}</template>
  517. <template #description>{{ i18n "pages.settings.fragmentDesc"}}</template>
  518. <template #control>
  519. <a-switch v-model="fragment"></a-switch>
  520. </template>
  521. </a-setting-list-item>
  522. <a-list-item v-if="fragment" style="padding: 10px 20px;">
  523. <a-collapse>
  524. <a-collapse-panel header='{{ i18n "pages.settings.fragmentSett"}}' v-if="fragment">
  525. <a-setting-list-item paddings="small">
  526. <template #title>Packets</template>
  527. <template #control>
  528. <a-input type="text" v-model="fragmentPackets" placeholder="1-1 | 1-3 | tlshello | ..."></a-input>
  529. </template>
  530. </a-setting-list-item>
  531. <a-setting-list-item paddings="small">
  532. <template #title>Length</template>
  533. <template #control>
  534. <a-input type="text" v-model="fragmentLength" placeholder="100-200"></a-input>
  535. </template>
  536. </a-setting-list-item>
  537. <a-setting-list-item paddings="small">
  538. <template #title>Interval</template>
  539. <template #control>
  540. <a-input type="text" v-model="fragmentInterval" placeholder="10-20"></a-input>
  541. </template>
  542. </a-setting-list-item>
  543. </a-collapse-panel>
  544. </a-collapse>
  545. </a-list-item>
  546. </a-collapse-panel>
  547. <a-collapse-panel header="Noises">
  548. <a-setting-list-item paddings="small">
  549. <template #title>Noises</template>
  550. <template #description>{{ i18n "pages.settings.noisesDesc"}}</template>
  551. <template #control>
  552. <a-switch v-model="noises"></a-switch>
  553. </template>
  554. </a-setting-list-item>
  555. <a-list-item v-if="noises" style="padding: 10px 20px;">
  556. <a-collapse>
  557. <a-collapse-panel v-for="(noise, index) in noisesArray" :key="index" :header="`Noise №${index + 1}`">
  558. <a-setting-list-item paddings="small">
  559. <template #title>Type</template>
  560. <template #control>
  561. <a-select :value="noise.type" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme"
  562. @change="(value) => updateNoiseType(index, value)">
  563. <a-select-option :value="p" :label="p" v-for="p in ['rand', 'base64', 'str', 'hex']" :key="p">
  564. [[ p ]] </a-select-option>
  565. </a-select>
  566. </template>
  567. </a-setting-list-item>
  568. <a-setting-list-item paddings="small">
  569. <template #title>Packet</template>
  570. <template #control>
  571. <a-input type="text" :value="noise.packet" @input="(value) => updateNoisePacket(index, event.target.value)" placeholder="5-10"></a-input>
  572. </template>
  573. </a-setting-list-item>
  574. <a-setting-list-item paddings="small">
  575. <template #title>Delay (ms)</template>
  576. <template #control>
  577. <a-input type="text" :value="noise.delay" @input="(value) => updateNoiseDelay(index, event.target.value)" placeholder="10-20"></a-input>
  578. </template>
  579. </a-setting-list-item>
  580. <a-space direction="horizontal" style="padding: 10px 20px;">
  581. <a-button v-if="noisesArray.length > 1" type="danger" @click="removeNoise(index)">Remove</a-button>
  582. </a-space>
  583. </a-collapse-panel>
  584. </a-collapse>
  585. <a-button v-if="noises" type="primary" @click="addNoise" style="margin-top: 10px">Add Noise</a-button>
  586. </a-list-item>
  587. </a-collapse-panel>
  588. <a-collapse-panel header='{{ i18n "pages.settings.mux"}}'>
  589. <a-setting-list-item paddings="small">
  590. <template #title>{{ i18n "pages.settings.mux"}}</template>
  591. <template #description>{{ i18n "pages.settings.muxDesc"}}</template>
  592. <template #control>
  593. <a-switch v-model="enableMux"></a-switch>
  594. </template>
  595. </a-setting-list-item>
  596. <a-list-item v-if="enableMux" style="padding: 10px 20px;">
  597. <a-collapse>
  598. <a-collapse-panel header='{{ i18n "pages.settings.muxSett"}}'>
  599. <a-setting-list-item paddings="small">
  600. <template #title>Concurrency</template>
  601. <template #control>
  602. <a-input-number v-model="muxConcurrency" :min="-1" :max="1024" style="width: 100%;"></a-input-number>
  603. </template>
  604. </a-setting-list-item>
  605. <a-setting-list-item paddings="small">
  606. <template #title>xudp Concurrency</template>
  607. <template #control>
  608. <a-input-number v-model="muxXudpConcurrency" :min="-1" :max="1024" style="width: 100%;"></a-input-number>
  609. </template>
  610. </a-setting-list-item>
  611. <a-setting-list-item paddings="small">
  612. <template #title>xudp UDP 443</template>
  613. <template #control>
  614. <a-select v-model="muxXudpProxyUDP443" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme">
  615. <a-select-option :value="p" :label="p" v-for="p in ['reject', 'allow', 'skip']"> [[ p ]] </a-select-option>
  616. </a-select>
  617. </template>
  618. </a-setting-list-item>
  619. </a-collapse-panel>
  620. </a-collapse>
  621. </a-list-item>
  622. </a-collapse-panel>
  623. <a-collapse-panel header='{{ i18n "pages.settings.direct" }}'>
  624. <a-setting-list-item paddings="small">
  625. <template #title>{{ i18n "pages.settings.direct"}}</template>
  626. <template #description>{{ i18n "pages.settings.directDesc"}}</template>
  627. <template #control>
  628. <a-switch v-model="enableDirect"></a-switch>
  629. </template>
  630. </a-setting-list-item>
  631. <a-list-item v-if="enableDirect" style="padding: 10px 20px;">
  632. <a-collapse>
  633. <a-collapse-panel header='{{ i18n "pages.settings.direct"}}'>
  634. <a-setting-list-item paddings="small">
  635. <template #title>{{ i18n "pages.xray.directips" }}</template>
  636. <template #control>
  637. <a-select mode="tags" style="width: 100%" v-model="directIPs" :dropdown-class-name="themeSwitcher.currentTheme">
  638. <a-select-option :value="p.value" :label="p.label" v-for="p in directIPsOptions">[[ p.label ]]</a-select-option>
  639. </a-select>
  640. </template>
  641. </a-setting-list-item>
  642. <a-setting-list-item paddings="small">
  643. <template #title>{{ i18n "pages.xray.directdomains" }}</template>
  644. <template #control>
  645. <a-select mode="tags" style="width: 100%" v-model="directDomains" :dropdown-class-name="themeSwitcher.currentTheme">
  646. <a-select-option :value="p.value" :label="p.label" v-for="p in diretDomainsOptions">[[ p.label ]]</a-select-option>
  647. </a-select>
  648. </template>
  649. </a-setting-list-item>
  650. </a-collapse-panel>
  651. </a-collapse>
  652. </a-list-item>
  653. </a-collapse-panel>
  654. </a-collapse>
  655. </a-tab-pane>
  656. </a-tabs>
  657. </a-space>
  658. </a-spin>
  659. </a-layout-content>
  660. </a-layout>
  661. </a-layout>
  662. {{template "js" .}}
  663. <script src="{{ .base_path }}assets/js/model/setting.js?{{ .cur_ver }}"></script>
  664. {{template "component/aThemeSwitch" .}}
  665. {{template "component/aPasswordInput" .}}
  666. {{template "component/aSettingListItem" .}}
  667. <script>
  668. const app = new Vue({
  669. delimiters: ['[[', ']]'],
  670. el: '#app',
  671. data: {
  672. siderDrawer,
  673. themeSwitcher,
  674. spinning: false,
  675. changeSecret: false,
  676. oldAllSetting: new AllSetting(),
  677. allSetting: new AllSetting(),
  678. saveBtnDisable: true,
  679. user: {},
  680. lang: LanguageManager.getLanguage(),
  681. remarkModels: { i: 'Inbound', e: 'Email', o: 'Other' },
  682. remarkSeparators: [' ', '-', '_', '@', ':', '~', '|', ',', '.', '/'],
  683. datepickerList: [{ name: 'Gregorian (Standard)', value: 'gregorian' }, { name: 'Jalalian (شمسی)', value: 'jalalian' }],
  684. remarkSample: '',
  685. defaultFragment: {
  686. tag: "fragment",
  687. protocol: "freedom",
  688. settings: {
  689. domainStrategy: "AsIs",
  690. fragment: {
  691. packets: "tlshello",
  692. length: "100-200",
  693. interval: "10-20"
  694. }
  695. },
  696. streamSettings: {
  697. sockopt: {
  698. tcpKeepAliveIdle: 100,
  699. tcpMptcp: true,
  700. penetrate: true
  701. }
  702. }
  703. },
  704. defaultNoises: {
  705. tag: "noises",
  706. protocol: "freedom",
  707. settings: {
  708. domainStrategy: "AsIs",
  709. noises: [
  710. { type: "rand", packet: "10-20", delay: "10-16" },
  711. ],
  712. },
  713. },
  714. defaultMux: {
  715. enabled: true,
  716. concurrency: 8,
  717. xudpConcurrency: 16,
  718. xudpProxyUDP443: "reject"
  719. },
  720. defaultRules: [
  721. {
  722. type: "field",
  723. outboundTag: "direct",
  724. domain: [
  725. "geosite:category-ir"
  726. ]
  727. },
  728. {
  729. type: "field",
  730. outboundTag: "direct",
  731. ip: [
  732. "geoip:private",
  733. "geoip:ir"
  734. ]
  735. },
  736. ],
  737. directIPsOptions: [
  738. { label: 'Private IP', value: 'geoip:private' },
  739. { label: '🇮🇷 Iran', value: 'geoip:ir' },
  740. { label: '🇨🇳 China', value: 'geoip:cn' },
  741. { label: '🇷🇺 Russia', value: 'geoip:ru' },
  742. { label: '🇻🇳 Vietnam', value: 'geoip:vn' },
  743. { label: '🇪🇸 Spain', value: 'geoip:es' },
  744. { label: '🇮🇩 Indonesia', value: 'geoip:id' },
  745. { label: '🇺🇦 Ukraine', value: 'geoip:ua' },
  746. { label: '🇹🇷 Türkiye', value: 'geoip:tr' },
  747. { label: '🇧🇷 Brazil', value: 'geoip:br' },
  748. ],
  749. diretDomainsOptions: [
  750. { label: 'Private DNS', value: 'geosite:private' },
  751. { label: '🇮🇷 Iran', value: 'geosite:category-ir' },
  752. { label: '🇨🇳 China', value: 'geosite:cn' },
  753. { label: '🇷🇺 Russia', value: 'geosite:category-ru' },
  754. { label: 'Apple', value: 'geosite:apple' },
  755. { label: 'Meta', value: 'geosite:meta' },
  756. { label: 'Google', value: 'geosite:google' },
  757. ],
  758. get remarkModel() {
  759. rm = this.allSetting.remarkModel;
  760. return rm.length > 1 ? rm.substring(1).split('') : [];
  761. },
  762. set remarkModel(value) {
  763. rs = this.allSetting.remarkModel[0];
  764. this.allSetting.remarkModel = rs + value.join('');
  765. this.changeRemarkSample();
  766. },
  767. get remarkSeparator() {
  768. return this.allSetting.remarkModel.length > 1 ? this.allSetting.remarkModel.charAt(0) : '-';
  769. },
  770. set remarkSeparator(value) {
  771. this.allSetting.remarkModel = value + this.allSetting.remarkModel.substring(1);
  772. this.changeRemarkSample();
  773. },
  774. get datepicker() {
  775. return this.allSetting.datepicker ? this.allSetting.datepicker : 'gregorian';
  776. },
  777. set datepicker(value) {
  778. this.allSetting.datepicker = value;
  779. },
  780. changeRemarkSample() {
  781. sample = []
  782. this.remarkModel.forEach(r => sample.push(this.remarkModels[r]));
  783. this.remarkSample = sample.length == 0 ? '' : sample.join(this.remarkSeparator);
  784. }
  785. },
  786. methods: {
  787. loading(spinning = true) {
  788. this.spinning = spinning;
  789. },
  790. async getAllSetting() {
  791. this.loading(true);
  792. const msg = await HttpUtil.post("/panel/setting/all");
  793. this.loading(false);
  794. if (msg.success) {
  795. this.oldAllSetting = new AllSetting(msg.obj);
  796. this.allSetting = new AllSetting(msg.obj);
  797. app.changeRemarkSample();
  798. this.saveBtnDisable = true;
  799. }
  800. await this.fetchUserSecret();
  801. },
  802. async updateAllSetting() {
  803. this.loading(true);
  804. const msg = await HttpUtil.post("/panel/setting/update", this.allSetting);
  805. this.loading(false);
  806. if (msg.success) {
  807. await this.getAllSetting();
  808. }
  809. },
  810. async updateUser() {
  811. this.loading(true);
  812. const msg = await HttpUtil.post("/panel/setting/updateUser", this.user);
  813. this.loading(false);
  814. if (msg.success) {
  815. this.user = {};
  816. window.location.replace(basePath + "logout");
  817. }
  818. },
  819. async restartPanel() {
  820. await new Promise(resolve => {
  821. this.$confirm({
  822. title: '{{ i18n "pages.settings.restartPanel" }}',
  823. content: '{{ i18n "pages.settings.restartPanelDesc" }}',
  824. class: themeSwitcher.currentTheme,
  825. okText: '{{ i18n "sure" }}',
  826. cancelText: '{{ i18n "cancel" }}',
  827. onOk: () => resolve(),
  828. });
  829. });
  830. this.loading(true);
  831. const msg = await HttpUtil.post("/panel/setting/restartPanel");
  832. this.loading(false);
  833. if (msg.success) {
  834. this.loading(true);
  835. await PromiseUtil.sleep(5000);
  836. var { webCertFile, webKeyFile, webDomain: host, webPort: port, webBasePath: base } = this.allSetting;
  837. if (host == this.oldAllSetting.webDomain) host = null;
  838. if (port == this.oldAllSetting.webPort) port = null;
  839. const isTLS = webCertFile !== "" || webKeyFile !== "";
  840. const url = URLBuilder.buildURL({ host, port, isTLS, base, path: "panel/settings" });
  841. window.location.replace(url);
  842. }
  843. },
  844. async fetchUserSecret() {
  845. this.loading(true);
  846. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  847. if (userMessage.success) {
  848. this.user = userMessage.obj;
  849. }
  850. this.loading(false);
  851. },
  852. async updateSecret() {
  853. this.loading(true);
  854. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  855. if (msg && msg.obj) {
  856. this.user = msg.obj;
  857. }
  858. this.loading(false);
  859. await this.updateAllSetting();
  860. },
  861. generateRandomString(length) {
  862. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  863. let randomString = "";
  864. for (let i = 0; i < length; i++) {
  865. randomString += chars[Math.floor(Math.random() * chars.length)];
  866. }
  867. return randomString;
  868. },
  869. async getNewSecret() {
  870. if (!this.changeSecret) {
  871. this.changeSecret = true;
  872. this.user.loginSecret = '';
  873. const newSecret = this.generateRandomString(64);
  874. await PromiseUtil.sleep(1000);
  875. this.user.loginSecret = newSecret;
  876. this.changeSecret = false;
  877. }
  878. },
  879. async toggleToken(value) {
  880. if (value) {
  881. await this.getNewSecret();
  882. } else {
  883. this.user.loginSecret = "";
  884. }
  885. },
  886. addNoise() {
  887. const newNoise = { type: "rand", packet: "10-20", delay: "10-16" };
  888. this.noisesArray = [...this.noisesArray, newNoise];
  889. },
  890. removeNoise(index) {
  891. const newNoises = [...this.noisesArray];
  892. newNoises.splice(index, 1);
  893. this.noisesArray = newNoises;
  894. },
  895. updateNoiseType(index, value) {
  896. const updatedNoises = [...this.noisesArray];
  897. updatedNoises[index] = { ...updatedNoises[index], type: value };
  898. this.noisesArray = updatedNoises;
  899. },
  900. updateNoisePacket(index, value) {
  901. const updatedNoises = [...this.noisesArray];
  902. updatedNoises[index] = { ...updatedNoises[index], packet: value };
  903. this.noisesArray = updatedNoises;
  904. },
  905. updateNoiseDelay(index, value) {
  906. const updatedNoises = [...this.noisesArray];
  907. updatedNoises[index] = { ...updatedNoises[index], delay: value };
  908. this.noisesArray = updatedNoises;
  909. },
  910. },
  911. computed: {
  912. fragment: {
  913. get: function () { return this.allSetting?.subJsonFragment != ""; },
  914. set: function (v) {
  915. this.allSetting.subJsonFragment = v ? JSON.stringify(this.defaultFragment) : "";
  916. }
  917. },
  918. fragmentPackets: {
  919. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.packets : ""; },
  920. set: function (v) {
  921. if (v != "") {
  922. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  923. newFragment.settings.fragment.packets = v;
  924. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  925. }
  926. }
  927. },
  928. fragmentLength: {
  929. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.length : ""; },
  930. set: function (v) {
  931. if (v != "") {
  932. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  933. newFragment.settings.fragment.length = v;
  934. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  935. }
  936. }
  937. },
  938. fragmentInterval: {
  939. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.interval : ""; },
  940. set: function (v) {
  941. if (v != "") {
  942. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  943. newFragment.settings.fragment.interval = v;
  944. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  945. }
  946. }
  947. },
  948. noises: {
  949. get() {
  950. return this.allSetting?.subJsonNoises != "";
  951. },
  952. set(v) {
  953. if (v) {
  954. this.allSetting.subJsonNoises = JSON.stringify(this.defaultNoises);
  955. } else {
  956. this.allSetting.subJsonNoises = "";
  957. }
  958. }
  959. },
  960. noisesArray: {
  961. get() {
  962. return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises : [];
  963. },
  964. set(value) {
  965. if (this.noises) {
  966. const newNoises = JSON.parse(this.allSetting.subJsonNoises);
  967. newNoises.settings.noises = value;
  968. this.allSetting.subJsonNoises = JSON.stringify(newNoises);
  969. }
  970. }
  971. },
  972. enableMux: {
  973. get: function () { return this.allSetting?.subJsonMux != ""; },
  974. set: function (v) {
  975. this.allSetting.subJsonMux = v ? JSON.stringify(this.defaultMux) : "";
  976. }
  977. },
  978. muxConcurrency: {
  979. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).concurrency : -1; },
  980. set: function (v) {
  981. newMux = JSON.parse(this.allSetting.subJsonMux);
  982. newMux.concurrency = v;
  983. this.allSetting.subJsonMux = JSON.stringify(newMux);
  984. }
  985. },
  986. muxXudpConcurrency: {
  987. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpConcurrency : -1; },
  988. set: function (v) {
  989. newMux = JSON.parse(this.allSetting.subJsonMux);
  990. newMux.xudpConcurrency = v;
  991. this.allSetting.subJsonMux = JSON.stringify(newMux);
  992. }
  993. },
  994. muxXudpProxyUDP443: {
  995. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpProxyUDP443 : "reject"; },
  996. set: function (v) {
  997. newMux = JSON.parse(this.allSetting.subJsonMux);
  998. newMux.xudpProxyUDP443 = v;
  999. this.allSetting.subJsonMux = JSON.stringify(newMux);
  1000. }
  1001. },
  1002. enableDirect: {
  1003. get: function () { return this.allSetting?.subJsonRules != ""; },
  1004. set: function (v) {
  1005. this.allSetting.subJsonRules = v ? JSON.stringify(this.defaultRules) : "";
  1006. }
  1007. },
  1008. directIPs: {
  1009. get: function () {
  1010. if (!this.enableDirect) return [];
  1011. const rules = JSON.parse(this.allSetting.subJsonRules);
  1012. if (!Array.isArray(rules)) return [];
  1013. const ipRule = rules.find(r => r.ip);
  1014. return ipRule?.ip ?? [];
  1015. },
  1016. set: function (v) {
  1017. let rules = JSON.parse(this.allSetting.subJsonRules);
  1018. if (!Array.isArray(rules)) return;
  1019. if (v.length == 0) {
  1020. rules = rules.filter(r => !r.ip);
  1021. } else {
  1022. let ruleIndex = rules.findIndex(r => r.ip);
  1023. if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[1]) - 1;
  1024. rules[ruleIndex].ip = [];
  1025. v.forEach(d => {
  1026. rules[ruleIndex].ip.push(d);
  1027. });
  1028. }
  1029. this.allSetting.subJsonRules = JSON.stringify(rules);
  1030. }
  1031. },
  1032. directDomains: {
  1033. get: function () {
  1034. if (!this.enableDirect) return [];
  1035. const rules = JSON.parse(this.allSetting.subJsonRules);
  1036. if (!Array.isArray(rules)) return [];
  1037. const domainRule = rules.find(r => r.domain);
  1038. return domainRule?.domain ?? [];
  1039. },
  1040. set: function (v) {
  1041. let rules = JSON.parse(this.allSetting.subJsonRules);
  1042. if (!Array.isArray(rules)) return;
  1043. if (v.length == 0) {
  1044. rules = rules.filter(r => !r.domain);
  1045. } else {
  1046. let ruleIndex = rules.findIndex(r => r.domain);
  1047. if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[0]) - 1;
  1048. rules[ruleIndex].domain = v;
  1049. }
  1050. this.allSetting.subJsonRules = JSON.stringify(rules);
  1051. }
  1052. },
  1053. confAlerts: {
  1054. get: function () {
  1055. if (!this.allSetting) return [];
  1056. var alerts = []
  1057. if (window.location.protocol !== "https:") alerts.push('{{ i18n "secAlertSSL" }}');
  1058. if (this.allSetting.webPort == 54321) alerts.push('{{ i18n "secAlertPanelPort" }}');
  1059. panelPath = window.location.pathname.split('/').length < 4
  1060. if (panelPath && this.allSetting.webBasePath == '/') alerts.push('{{ i18n "secAlertPanelURI" }}');
  1061. if (this.allSetting.subEnable) {
  1062. subPath = this.allSetting.subURI.length > 0 ? new URL(this.allSetting.subURI).pathname : this.allSetting.subPath;
  1063. if (subPath == '/sub/') alerts.push('{{ i18n "secAlertSubURI" }}');
  1064. subJsonPath = this.allSetting.subJsonURI.length > 0 ? new URL(this.allSetting.subJsonURI).pathname : this.allSetting.subJsonPath;
  1065. if (subJsonPath == '/json/') alerts.push('{{ i18n "secAlertSubJsonURI" }}');
  1066. }
  1067. return alerts
  1068. }
  1069. }
  1070. },
  1071. async mounted() {
  1072. await this.getAllSetting();
  1073. while (true) {
  1074. await PromiseUtil.sleep(1000);
  1075. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  1076. }
  1077. }
  1078. });
  1079. </script>
  1080. </body>
  1081. </html>