setting.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <style>
  5. @media (min-width: 769px) {
  6. .ant-layout-content {
  7. margin: 24px 16px;
  8. }
  9. }
  10. .ant-col-sm-24 {
  11. margin-top: 10px;
  12. }
  13. .ant-tabs-bar {
  14. margin: 0;
  15. }
  16. .ant-list-item {
  17. display: block;
  18. }
  19. .ant-tabs-top-bar {
  20. background: white;
  21. }
  22. </style>
  23. <body>
  24. <a-layout id="app" v-cloak>
  25. {{ template "commonSider" . }}
  26. <a-layout id="content-layout">
  27. <a-layout-content>
  28. <a-spin :spinning="spinning" :delay="500" tip="loading">
  29. <a-space direction="vertical">
  30. <a-space direction="horizontal">
  31. <a-button type="primary" :disabled="saveBtnDisable" @click="updateAllSetting">{{ i18n "pages.setting.save" }}</a-button>
  32. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartPanel">{{ i18n "pages.setting.restartPanel" }}</a-button>
  33. </a-space>
  34. <a-tabs default-active-key="1">
  35. <a-tab-pane key="1" tab='{{ i18n "pages.setting.panelConfig"}}'>
  36. <a-list item-layout="horizontal" style="background: white">
  37. <setting-list-item type="text" title='{{ i18n "pages.setting.panelListeningIP"}}' desc='{{ i18n "pages.setting.panelListeningIPDesc"}}' v-model="allSetting.webListen"></setting-list-item>
  38. <setting-list-item type="number" title='{{ i18n "pages.setting.panelPort"}}' desc='{{ i18n "pages.setting.panelPortDesc"}}' v-model.number="allSetting.webPort"></setting-list-item>
  39. <setting-list-item type="text" title='{{ i18n "pages.setting.publicKeyPath"}}' desc='{{ i18n "pages.setting.publicKeyPathDesc"}}' v-model="allSetting.webCertFile"></setting-list-item>
  40. <setting-list-item type="text" title='{{ i18n "pages.setting.privateKeyPath"}}' desc='{{ i18n "pages.setting.privateKeyPathDesc"}}' v-model="allSetting.webKeyFile"></setting-list-item>
  41. <setting-list-item type="text" title='{{ i18n "pages.setting.panelUrlPath"}}' desc='{{ i18n "pages.setting.panelUrlPathDesc"}}' v-model="allSetting.webBasePath"></setting-list-item>
  42. <a-list-item>
  43. <a-row style="padding: 20px">
  44. <a-col :lg="24" :xl="12">
  45. <a-list-item-meta title="Language"/>
  46. </a-col>
  47. <a-col :lg="24" :xl="12">
  48. <temlate>
  49. <a-select
  50. ref="selectLang"
  51. v-model="lang"
  52. @change="setLang(lang)"
  53. style="width: 100%"
  54. >
  55. <a-select-option :value="l.value" label="China" v-for="l in supportLangs" >
  56. <span role="img" aria-label="l.name" v-text="l.icon"></span>
  57. &nbsp;&nbsp;<span v-text="l.name"></span>
  58. </a-select-option>
  59. </a-select>
  60. </temlate>
  61. </a-col>
  62. </a-row>
  63. </a-list-item>
  64. </a-list>
  65. </a-tab-pane>
  66. <a-tab-pane key="2" tab='{{ i18n "pages.setting.userSetting"}}'>
  67. <a-form style="background: white; padding: 20px">
  68. <a-form-item label='{{ i18n "pages.setting.oldUsername"}}'>
  69. <a-input v-model="user.oldUsername" style="max-width: 300px"></a-input>
  70. </a-form-item>
  71. <a-form-item label='{{ i18n "pages.setting.currentPassword"}}'>
  72. <a-input type="password" v-model="user.oldPassword"
  73. style="max-width: 300px"></a-input>
  74. </a-form-item>
  75. <a-form-item label='{{ i18n "pages.setting.newUsername"}}'>
  76. <a-input v-model="user.newUsername" style="max-width: 300px"></a-input>
  77. </a-form-item>
  78. <a-form-item label='{{ i18n "pages.setting.newPassword"}}'>
  79. <a-input type="password" v-model="user.newPassword"
  80. style="max-width: 300px"></a-input>
  81. </a-form-item>
  82. <a-form-item>
  83. <!-- <a-button type="primary" @click="updateUser">update</a-button>-->
  84. <a-button type="primary" @click="updateUser">{{ i18n "confirm" }}</a-button>
  85. </a-form-item>
  86. </a-form>
  87. </a-tab-pane>
  88. <a-tab-pane key="3" tab='{{ i18n "pages.setting.xrayConfiguration"}}'>
  89. <a-list item-layout="horizontal" style="background: white">
  90. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigTemplate"}}' desc='{{ i18n "pages.setting.xrayConfigTemplateDesc"}}' v-model="allSetting.xrayTemplateConfig"></setting-list-item>
  91. </a-list>
  92. </a-tab-pane>
  93. <a-tab-pane key="4" tab='{{ i18n "pages.setting.TGReminder"}}'>
  94. <a-list item-layout="horizontal" style="background: white">
  95. <setting-list-item type="switch" title='{{ i18n "pages.setting.telegramBotEnable" }}' desc='{{ i18n "pages.setting.telegramBotEnableDesc" }}' v-model="allSetting.tgBotEnable"></setting-list-item>
  96. <setting-list-item type="text" title='{{ i18n "pages.setting.telegramToken"}}' desc='{{ i18n "pages.setting.telegramTokenDesc"}}' v-model="allSetting.tgBotToken"></setting-list-item>
  97. <setting-list-item type="number" title='{{ i18n "pages.setting.telegramChatId"}}' desc='{{ i18n "pages.setting.telegramChatIdDesc"}}' v-model.number="allSetting.tgBotChatId"></setting-list-item>
  98. <setting-list-item type="text" title='{{ i18n "pages.setting.telegramNotifyTime"}}' desc='{{ i18n "pages.setting.telegramNotifyTimeDesc"}}' v-model="allSetting.tgRunTime"></setting-list-item>
  99. </a-list>
  100. </a-tab-pane>
  101. <a-tab-pane key="5" tab='{{ i18n "pages.setting.otherSetting"}}'>
  102. <a-list item-layout="horizontal" style="background: white">
  103. <setting-list-item type="text" title='{{ i18n "pages.setting.timeZonee"}}' desc='{{ i18n "pages.setting.timeZoneDesc"}}' v-model="allSetting.timeLocation"></setting-list-item>
  104. </a-list>
  105. </a-tab-pane>
  106. </a-tabs>
  107. </a-space>
  108. </a-spin>
  109. </a-layout-content>
  110. </a-layout>
  111. </a-layout>
  112. {{template "js" .}}
  113. {{template "component/setting"}}
  114. <script>
  115. const app = new Vue({
  116. delimiters: ['[[', ']]'],
  117. el: '#app',
  118. data: {
  119. siderDrawer,
  120. spinning: false,
  121. oldAllSetting: new AllSetting(),
  122. allSetting: new AllSetting(),
  123. saveBtnDisable: true,
  124. user: {},
  125. lang : getLang()
  126. },
  127. methods: {
  128. loading(spinning = true) {
  129. this.spinning = spinning;
  130. },
  131. async getAllSetting() {
  132. this.loading(true);
  133. const msg = await HttpUtil.post("/xui/setting/all");
  134. this.loading(false);
  135. if (msg.success) {
  136. this.oldAllSetting = new AllSetting(msg.obj);
  137. this.allSetting = new AllSetting(msg.obj);
  138. this.saveBtnDisable = true;
  139. }
  140. },
  141. async updateAllSetting() {
  142. this.loading(true);
  143. const msg = await HttpUtil.post("/xui/setting/update", this.allSetting);
  144. this.loading(false);
  145. if (msg.success) {
  146. await this.getAllSetting();
  147. }
  148. },
  149. async updateUser() {
  150. this.loading(true);
  151. const msg = await HttpUtil.post("/xui/setting/updateUser", this.user);
  152. this.loading(false);
  153. if (msg.success) {
  154. this.user = {};
  155. }
  156. },
  157. async restartPanel() {
  158. await new Promise(resolve => {
  159. this.$confirm({
  160. title: '{{ i18n "pages.setting.restartPanel" }}',
  161. content: '{{ i18n "pages.setting.restartPanelDesc" }}',
  162. okText: '{{ i18n "sure" }}',
  163. cancelText: '{{ i18n "cancel" }}',
  164. onOk: () => resolve(),
  165. });
  166. });
  167. this.loading(true);
  168. const msg = await HttpUtil.post("/xui/setting/restartPanel");
  169. this.loading(false);
  170. if (msg.success) {
  171. this.loading(true);
  172. await PromiseUtil.sleep(5000);
  173. location.reload();
  174. }
  175. }
  176. },
  177. async mounted() {
  178. await this.getAllSetting();
  179. while (true) {
  180. await PromiseUtil.sleep(1000);
  181. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  182. }
  183. },
  184. });
  185. </script>
  186. </body>
  187. </html>