setting.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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">保存配置</a-button>
  32. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartPanel">重启面板</a-button>
  33. </a-space>
  34. <a-tabs default-active-key="1">
  35. <a-tab-pane key="1" tab="面板配置">
  36. <a-list item-layout="horizontal" style="background: white">
  37. <setting-list-item type="text" title="面板监听 IP" desc="默认留空监听所有 IP" v-model="allSetting.webListen"></setting-list-item>
  38. <setting-list-item type="number" title="面板监听端口" v-model.number="allSetting.webPort"></setting-list-item>
  39. <setting-list-item type="text" title="面板证书公钥文件路径" desc="填写一个 '/' 开头的绝对路径" v-model="allSetting.webCertFile"></setting-list-item>
  40. <setting-list-item type="text" title="面板证书密钥文件路径" desc="填写一个 '/' 开头的绝对路径" v-model="allSetting.webKeyFile"></setting-list-item>
  41. <setting-list-item type="text" title="面板 url 根路径" desc="必须以 '/' 开头,以 '/' 结尾" v-model="allSetting.webBasePath"></setting-list-item>
  42. </a-list>
  43. </a-tab-pane>
  44. <a-tab-pane key="2" tab="用户设置">
  45. <a-form style="background: white; padding: 20px">
  46. <a-form-item label="原用户名">
  47. <a-input v-model="user.oldUsername" style="max-width: 300px"></a-input>
  48. </a-form-item>
  49. <a-form-item label="原密码">
  50. <a-input type="password" v-model="user.oldPassword"
  51. style="max-width: 300px"></a-input>
  52. </a-form-item>
  53. <a-form-item label="新用户名">
  54. <a-input v-model="user.newUsername" style="max-width: 300px"></a-input>
  55. </a-form-item>
  56. <a-form-item label="新密码">
  57. <a-input type="password" v-model="user.newPassword"
  58. style="max-width: 300px"></a-input>
  59. </a-form-item>
  60. <a-form-item>
  61. <a-button type="primary" @click="updateUser">修改</a-button>
  62. </a-form-item>
  63. </a-form>
  64. </a-tab-pane>
  65. <a-tab-pane key="3" tab="xray 相关设置">
  66. <a-list item-layout="horizontal" style="background: white">
  67. <setting-list-item type="textarea" title="xray 配置模版" desc="以该模版为基础生成最终的 xray 配置文件" v-model="allSetting.xrayTemplateConfig"></setting-list-item>
  68. </a-list>
  69. </a-tab-pane>
  70. <a-tab-pane key="4" tab="其他设置">
  71. <a-list item-layout="horizontal" style="background: white">
  72. <setting-list-item type="text" title="时区" desc="定时任务按照该时区的时间运行" v-model="allSetting.timeLocation"></setting-list-item>
  73. </a-list>
  74. </a-tab-pane>
  75. </a-tabs>
  76. </a-space>
  77. </a-spin>
  78. </a-layout-content>
  79. </a-layout>
  80. </a-layout>
  81. {{template "js" .}}
  82. {{template "component/setting"}}
  83. <script>
  84. const app = new Vue({
  85. delimiters: ['[[', ']]'],
  86. el: '#app',
  87. data: {
  88. siderDrawer,
  89. spinning: false,
  90. oldAllSetting: new AllSetting(),
  91. allSetting: new AllSetting(),
  92. saveBtnDisable: true,
  93. user: {},
  94. },
  95. methods: {
  96. loading(spinning = true) {
  97. this.spinning = spinning;
  98. },
  99. async getAllSetting() {
  100. this.loading(true);
  101. const msg = await HttpUtil.post("/xui/setting/all");
  102. this.loading(false);
  103. if (msg.success) {
  104. this.oldAllSetting = new AllSetting(msg.obj);
  105. this.allSetting = new AllSetting(msg.obj);
  106. this.saveBtnDisable = true;
  107. }
  108. },
  109. async updateAllSetting() {
  110. this.loading(true);
  111. const msg = await HttpUtil.post("/xui/setting/update", this.allSetting);
  112. this.loading(false);
  113. if (msg.success) {
  114. await this.getAllSetting();
  115. }
  116. },
  117. async updateUser() {
  118. this.loading(true);
  119. const msg = await HttpUtil.post("/xui/setting/updateUser", this.user);
  120. this.loading(false);
  121. if (msg.success) {
  122. this.user = {};
  123. }
  124. },
  125. async restartPanel() {
  126. await new Promise(resolve => {
  127. this.$confirm({
  128. title: '重启面板',
  129. content: '确定要重启面板吗?点击确定将于 3 秒后重启,若重启后无法访问面板,请前往服务器查看面板日志信息',
  130. okText: '确定',
  131. cancelText: '取消',
  132. onOk: () => resolve(),
  133. });
  134. });
  135. this.loading(true);
  136. const msg = await HttpUtil.post("/xui/setting/restartPanel");
  137. this.loading(false);
  138. if (msg.success) {
  139. this.loading(true);
  140. await PromiseUtil.sleep(5000);
  141. location.reload();
  142. }
  143. }
  144. },
  145. async mounted() {
  146. await this.getAllSetting();
  147. while (true) {
  148. await PromiseUtil.sleep(1000);
  149. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  150. }
  151. },
  152. });
  153. </script>
  154. </body>
  155. </html>