index.html 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  1. {{ template "page/head_start" .}}
  2. {{ template "page/head_end" .}}
  3. {{ template "page/body_start" .}}
  4. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme + ' index-page'">
  5. <a-sidebar></a-sidebar>
  6. <a-layout id="content-layout">
  7. <a-layout-content>
  8. <a-spin :spinning="loadingStates.spinning" :delay="200" :tip="loadingTip">
  9. <transition name="list" appear>
  10. <a-alert type="error" v-if="showAlert && loadingStates.fetched" class="mb-10"
  11. message='{{ i18n "secAlertTitle" }}'
  12. color="red"
  13. description='{{ i18n "secAlertSsl" }}'
  14. show-icon closable>
  15. </a-alert>
  16. </transition>
  17. <transition name="list" appear>
  18. <template>
  19. <a-row v-if="!loadingStates.fetched">
  20. <a-card class="card-placeholder text-center">
  21. <a-spin tip='{{ i18n "loading" }}'></a-spin>
  22. </a-card>
  23. </a-row>
  24. <a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else>
  25. <a-col>
  26. <a-card hoverable>
  27. <a-row :gutter="[0, isMobile ? 16 : 0]">
  28. <a-col :sm="24" :md="12">
  29. <a-row>
  30. <a-col :span="12" class="text-center">
  31. <a-progress type="dashboard" status="normal"
  32. :stroke-color="status.cpu.color"
  33. :percent="status.cpu.percent"></a-progress>
  34. <div>
  35. <b>{{ i18n "pages.index.cpu" }}:</b> [[ CPUFormatter.cpuCoreFormat(status.cpuCores) ]]
  36. <a-tooltip>
  37. <a-icon type="area-chart"></a-icon>
  38. <template slot="title">
  39. <div><b>{{ i18n "pages.index.logicalProcessors" }}:</b> [[ (status.logicalPro) ]]</div>
  40. <div><b>{{ i18n "pages.index.frequency" }}:</b> [[ CPUFormatter.cpuSpeedFormat(status.cpuSpeedMhz) ]]</div>
  41. </template>
  42. </a-tooltip>
  43. <a-tooltip :overlay-class-name="themeSwitcher.currentTheme">
  44. <a-button size="small" type="default" class="ml-8" @click="openCpuHistory()">
  45. <a-icon type="history" />
  46. </a-button>
  47. </a-tooltip>
  48. </div>
  49. </a-col>
  50. <a-col :span="12" class="text-center">
  51. <a-progress type="dashboard" status="normal"
  52. :stroke-color="status.mem.color"
  53. :percent="status.mem.percent"></a-progress>
  54. <div>
  55. <b>{{ i18n "pages.index.memory"}}:</b> [[ SizeFormatter.sizeFormat(status.mem.current) ]] / [[ SizeFormatter.sizeFormat(status.mem.total) ]]
  56. </div>
  57. </a-col>
  58. </a-row>
  59. </a-col>
  60. <a-col :sm="24" :md="12">
  61. <a-row>
  62. <a-col :span="12" class="text-center">
  63. <a-progress type="dashboard" status="normal"
  64. :stroke-color="status.swap.color"
  65. :percent="status.swap.percent"></a-progress>
  66. <div>
  67. <b>{{ i18n "pages.index.swap" }}:</b> [[ SizeFormatter.sizeFormat(status.swap.current) ]] / [[ SizeFormatter.sizeFormat(status.swap.total) ]]
  68. </div>
  69. </a-col>
  70. <a-col :span="12" class="text-center">
  71. <a-progress type="dashboard" status="normal"
  72. :stroke-color="status.disk.color"
  73. :percent="status.disk.percent"></a-progress>
  74. <div>
  75. <b>{{ i18n "pages.index.storage"}}:</b> [[ SizeFormatter.sizeFormat(status.disk.current) ]] / [[ SizeFormatter.sizeFormat(status.disk.total) ]]
  76. </div>
  77. </a-col>
  78. </a-row>
  79. </a-col>
  80. </a-row>
  81. </a-card>
  82. </a-col>
  83. <a-col :sm="24" :lg="12">
  84. <a-card hoverable>
  85. <template #title>
  86. <a-space direction="horizontal">
  87. <span>{{ i18n "pages.index.xrayStatus" }}</span>
  88. <a-tag v-if="isMobile && status.xray.version != 'Unknown'" color="green">
  89. v[[ status.xray.version ]]
  90. </a-tag>
  91. </a-space>
  92. </template>
  93. <template #extra>
  94. <template v-if="status.xray.state != 'error'">
  95. <a-badge status="processing" :class="({ green: 'xray-running-animation', orange: 'xray-stop-animation' }[status.xray.color]) || 'xray-processing-animation'" :text="status.xray.stateMsg" :color="status.xray.color"/>
  96. </template>
  97. <template v-else>
  98. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  99. <span slot="title">
  100. <a-row type="flex" align="middle" justify="space-between">
  101. <a-col>
  102. <span>{{ i18n "pages.index.xrayErrorPopoverTitle" }}</span>
  103. </a-col>
  104. <a-col>
  105. <a-icon type="bars" class="cursor-pointer float-right" @click="openLogs()"></a-icon>
  106. </a-col>
  107. </a-row>
  108. </span>
  109. <template slot="content">
  110. <span class="max-w-400" v-for="line in status.xray.errorMsg.split('\n')">[[ line ]]</span>
  111. </template>
  112. <a-badge :text="status.xray.stateMsg" :color="status.xray.color" :class="status.xray.color === 'red' ? 'xray-error-animation' : ''"/>
  113. </a-popover>
  114. </template>
  115. </template>
  116. <template #actions>
  117. <a-space v-if="app.ipLimitEnable" direction="horizontal" @click="openXrayLogs()" class="jc-center">
  118. <a-icon type="bars"></a-icon>
  119. <span v-if="!isMobile">{{ i18n "pages.index.logs" }}</span>
  120. </a-space>
  121. <a-space direction="horizontal" @click="stopXrayService" class="jc-center">
  122. <a-icon type="poweroff"></a-icon>
  123. <span v-if="!isMobile">{{ i18n "pages.index.stopXray" }}</span>
  124. </a-space>
  125. <a-space direction="horizontal" @click="restartXrayService" class="jc-center">
  126. <a-icon type="reload"></a-icon>
  127. <span v-if="!isMobile">{{ i18n "pages.index.restartXray" }}</span>
  128. </a-space>
  129. <a-space direction="horizontal" @click="openSelectV2rayVersion" class="jc-center">
  130. <a-icon type="tool"></a-icon>
  131. <span v-if="!isMobile">
  132. [[ status.xray.version != 'Unknown' ? `v${status.xray.version}` : '{{ i18n "pages.index.xraySwitch" }}' ]]
  133. </span>
  134. </a-space>
  135. </template>
  136. </a-card>
  137. </a-col>
  138. <a-col :sm="24" :lg="12">
  139. <a-card title='{{ i18n "menu.link" }}' hoverable>
  140. <template #actions>
  141. <a-space direction="horizontal" @click="openLogs()" class="jc-center">
  142. <a-icon type="bars"></a-icon>
  143. <span v-if="!isMobile">{{ i18n "pages.index.logs" }}</span>
  144. </a-space>
  145. <a-space direction="horizontal" @click="openConfig" class="jc-center">
  146. <a-icon type="control"></a-icon>
  147. <span v-if="!isMobile">{{ i18n "pages.index.config" }}</span>
  148. </a-space>
  149. <a-space direction="horizontal" @click="openBackup" class="jc-center">
  150. <a-icon type="cloud-server"></a-icon>
  151. <span v-if="!isMobile">{{ i18n "pages.index.backup" }}</span>
  152. </a-space>
  153. </template>
  154. </a-card>
  155. </a-col>
  156. <a-col :sm="24" :lg="12">
  157. <a-card title='3X-UI' hoverable>
  158. <a rel="noopener" href="https://github.com/MHSanaei/3x-ui/releases" target="_blank">
  159. <a-tag color="green">
  160. <span>v{{ .cur_ver }}</span>
  161. </a-tag>
  162. </a>
  163. <a rel="noopener" href="https://t.me/XrayUI" target="_blank">
  164. <a-tag color="green">
  165. <span>@XrayUI</span>
  166. </a-tag>
  167. </a>
  168. <a rel="noopener" href="https://github.com/MHSanaei/3x-ui/wiki" target="_blank">
  169. <a-tag color="purple">
  170. <span>{{ i18n "pages.index.documentation" }}</span>
  171. </a-tag>
  172. </a>
  173. </a-card>
  174. </a-col>
  175. <a-col :sm="24" :lg="12">
  176. <a-card title='{{ i18n "pages.index.operationHours" }}' hoverable>
  177. <a-tag :color="status.xray.color">Xray: [[ TimeFormatter.formatSecond(status.appStats.uptime) ]]</a-tag>
  178. <a-tag color="green">OS: [[ TimeFormatter.formatSecond(status.uptime) ]]</a-tag>
  179. </a-card>
  180. </a-col>
  181. <a-col :sm="24" :lg="12">
  182. <a-card title='{{ i18n "pages.index.systemLoad" }}' hoverable>
  183. <a-tag color="green">
  184. <a-tooltip>
  185. [[ status.loads[0] ]] | [[ status.loads[1] ]] | [[ status.loads[2] ]]
  186. <template slot="title">
  187. {{ i18n "pages.index.systemLoadDesc" }}
  188. </template>
  189. </a-tooltip>
  190. </a-tag>
  191. </a-card>
  192. </a-col>
  193. <a-col :sm="24" :lg="12">
  194. <a-card title='{{ i18n "usage"}}' hoverable>
  195. <a-tag color="green"> {{ i18n "pages.index.memory" }}: [[ SizeFormatter.sizeFormat(status.appStats.mem) ]] </a-tag>
  196. <a-tag color="green"> {{ i18n "pages.index.threads" }}: [[ status.appStats.threads ]] </a-tag>
  197. </a-card>
  198. </a-col>
  199. <a-col :sm="24" :lg="12">
  200. <a-card title='{{ i18n "pages.index.overallSpeed" }}' hoverable>
  201. <a-row :gutter="isMobile ? [8,8] : 0">
  202. <a-col :span="12">
  203. <a-custom-statistic title='{{ i18n "pages.index.upload" }}' :value="SizeFormatter.sizeFormat(status.netIO.up)">
  204. <template #prefix>
  205. <a-icon type="arrow-up" />
  206. </template>
  207. <template #suffix>
  208. /s
  209. </template>
  210. </a-custom-statistic>
  211. </a-col>
  212. <a-col :span="12">
  213. <a-custom-statistic title='{{ i18n "pages.index.download" }}' :value="SizeFormatter.sizeFormat(status.netIO.down)">
  214. <template #prefix>
  215. <a-icon type="arrow-down" />
  216. </template>
  217. <template #suffix>
  218. /s
  219. </template>
  220. </a-custom-statistic>
  221. </a-col>
  222. </a-row>
  223. </a-card>
  224. </a-col>
  225. <a-col :sm="24" :lg="12">
  226. <a-card title='{{ i18n "pages.index.totalData" }}' hoverable>
  227. <a-row :gutter="isMobile ? [8,8] : 0">
  228. <a-col :span="12">
  229. <a-custom-statistic title='{{ i18n "pages.index.sent" }}' :value="SizeFormatter.sizeFormat(status.netTraffic.sent)">
  230. <template #prefix>
  231. <a-icon type="cloud-upload" />
  232. </template>
  233. </a-custom-statistic>
  234. </a-col>
  235. <a-col :span="12">
  236. <a-custom-statistic title='{{ i18n "pages.index.received" }}' :value="SizeFormatter.sizeFormat(status.netTraffic.recv)">
  237. <template #prefix>
  238. <a-icon type="cloud-download" />
  239. </template>
  240. </a-custom-statistic>
  241. </a-col>
  242. </a-row>
  243. </a-card>
  244. </a-col>
  245. <a-col :sm="24" :lg="12">
  246. <a-card title='{{ i18n "pages.index.ipAddresses" }}' hoverable>
  247. <template #extra>
  248. <a-tooltip :placement="isMobile ? 'topRight' : 'top'">
  249. <template #title>
  250. {{ i18n "pages.index.toggleIpVisibility" }}
  251. </template>
  252. <a-icon :type="showIp ? 'eye' : 'eye-invisible'" class="fs-1rem" @click="showIp = !showIp"></a-icon>
  253. </a-tooltip>
  254. </template>
  255. <a-row :class="showIp ? 'ip-visible' : 'ip-hidden'" :gutter="isMobile ? [8,8] : 0">
  256. <a-col :span="isMobile ? 24 : 12">
  257. <a-custom-statistic title="IPv4" :value="status.publicIP.ipv4">
  258. <template #prefix>
  259. <a-icon type="global" />
  260. </template>
  261. </a-custom-statistic>
  262. </a-col>
  263. <a-col :span="isMobile ? 24 : 12">
  264. <a-custom-statistic title="IPv6" :value="status.publicIP.ipv6">
  265. <template #prefix>
  266. <a-icon type="global" />
  267. </template>
  268. </a-custom-statistic>
  269. </a-col>
  270. </a-row>
  271. </a-card>
  272. </a-col>
  273. <a-col :sm="24" :lg="12">
  274. <a-card title='{{ i18n "pages.index.connectionCount" }}' hoverable>
  275. <a-row :gutter="isMobile ? [8,8] : 0">
  276. <a-col :span="12">
  277. <a-custom-statistic title="TCP" :value="status.tcpCount">
  278. <template #prefix>
  279. <a-icon type="swap" />
  280. </template>
  281. </a-custom-statistic>
  282. </a-col>
  283. <a-col :span="12">
  284. <a-custom-statistic title="UDP" :value="status.udpCount">
  285. <template #prefix>
  286. <a-icon type="swap" />
  287. </template>
  288. </a-custom-statistic>
  289. </a-col>
  290. </a-row>
  291. </a-card>
  292. </a-col>
  293. </a-row>
  294. </template>
  295. </transition>
  296. </a-spin>
  297. </a-layout-content>
  298. </a-layout>
  299. <a-modal id="version-modal" v-model="versionModal.visible" title='{{ i18n "pages.index.xraySwitch" }}' :closable="true"
  300. @ok="() => versionModal.visible = false" :class="themeSwitcher.currentTheme" footer="">
  301. <a-collapse default-active-key="1">
  302. <a-collapse-panel key="1" header='Xray'>
  303. <a-alert type="warning" class="mb-12 w-100" message='{{ i18n "pages.index.xraySwitchClickDesk" }}' show-icon></a-alert>
  304. <a-list class="ant-version-list w-100" bordered>
  305. <a-list-item class="ant-version-list-item" v-for="version, index in versionModal.versions">
  306. <a-tag :color="index % 2 == 0 ? 'purple' : 'green'">[[ version ]]</a-tag>
  307. <a-radio :class="themeSwitcher.currentTheme" :checked="version === `v${status.xray.version}`" @click="switchV2rayVersion(version)"></a-radio>
  308. </a-list-item>
  309. </a-list>
  310. </a-collapse-panel>
  311. <a-collapse-panel key="2" header='Geofiles'>
  312. <a-list class="ant-version-list w-100" bordered>
  313. <a-list-item class="ant-version-list-item" v-for="file, index in ['geosite.dat', 'geoip.dat', 'geosite_IR.dat', 'geoip_IR.dat', 'geosite_RU.dat', 'geoip_RU.dat']">
  314. <a-tag :color="index % 2 == 0 ? 'purple' : 'green'">[[ file ]]</a-tag>
  315. <a-icon type="reload" @click="updateGeofile(file)" class="mr-8"/>
  316. </a-list-item>
  317. </a-list>
  318. <div class="mt-5 d-flex justify-end"><a-button @click="updateGeofile('')">{{ i18n "pages.index.geofilesUpdateAll" }}</a-button></div>
  319. </a-collapse-panel>
  320. </a-collapse>
  321. </a-modal>
  322. <a-modal id="log-modal" v-model="logModal.visible"
  323. :closable="true" @cancel="() => logModal.visible = false"
  324. :class="themeSwitcher.currentTheme"
  325. width="800px" footer="">
  326. <template slot="title">
  327. {{ i18n "pages.index.logs" }}
  328. <a-icon :spin="logModal.loading"
  329. type="sync"
  330. class="va-middle ml-10"
  331. :disabled="logModal.loading"
  332. @click="openLogs()">
  333. </a-icon>
  334. </template>
  335. <a-form layout="inline">
  336. <a-form-item class="mr-05">
  337. <a-input-group compact>
  338. <a-select size="small" v-model="logModal.rows" class="w-70"
  339. @change="openLogs()" :dropdown-class-name="themeSwitcher.currentTheme">
  340. <a-select-option value="10">10</a-select-option>
  341. <a-select-option value="20">20</a-select-option>
  342. <a-select-option value="50">50</a-select-option>
  343. <a-select-option value="100">100</a-select-option>
  344. <a-select-option value="500">500</a-select-option>
  345. </a-select>
  346. <a-select size="small" v-model="logModal.level" class="w-95"
  347. @change="openLogs()" :dropdown-class-name="themeSwitcher.currentTheme">
  348. <a-select-option value="debug">Debug</a-select-option>
  349. <a-select-option value="info">Info</a-select-option>
  350. <a-select-option value="notice">Notice</a-select-option>
  351. <a-select-option value="warning">Warning</a-select-option>
  352. <a-select-option value="err">Error</a-select-option>
  353. </a-select>
  354. </a-input-group>
  355. </a-form-item>
  356. <a-form-item>
  357. <a-checkbox v-model="logModal.syslog" @change="openLogs()">SysLog</a-checkbox>
  358. </a-form-item>
  359. <a-form-item style="float: right;">
  360. <a-button type="primary" icon="download" @click="FileManager.downloadTextFile(logModal.logs?.join('\n'), 'x-ui.log')"></a-button>
  361. </a-form-item>
  362. </a-form>
  363. <div class="ant-input log-container" v-html="logModal.formattedLogs"></div>
  364. </a-modal>
  365. <a-modal id="xraylog-modal"
  366. v-model="xraylogModal.visible"
  367. :closable="true" @cancel="() => xraylogModal.visible = false"
  368. :class="themeSwitcher.currentTheme"
  369. width="80vw"
  370. footer="">
  371. <template slot="title">
  372. {{ i18n "pages.index.logs" }}
  373. <a-icon :spin="xraylogModal.loading"
  374. type="sync"
  375. class="va-middle ml-10"
  376. :disabled="xraylogModal.loading"
  377. @click="openXrayLogs()">
  378. </a-icon>
  379. </template>
  380. <a-form layout="inline">
  381. <a-form-item class="mr-05">
  382. <a-input-group compact>
  383. <a-select size="small" v-model="xraylogModal.rows" class="w-70"
  384. @change="openXrayLogs()" :dropdown-class-name="themeSwitcher.currentTheme">
  385. <a-select-option value="10">10</a-select-option>
  386. <a-select-option value="20">20</a-select-option>
  387. <a-select-option value="50">50</a-select-option>
  388. <a-select-option value="100">100</a-select-option>
  389. <a-select-option value="500">500</a-select-option>
  390. </a-select>
  391. </a-input-group>
  392. </a-form-item>
  393. <a-form-item label="Filter:">
  394. <a-input size="small" v-model="xraylogModal.filter" @keyup.enter="openXrayLogs()"></a-input>
  395. </a-form-item>
  396. <a-form-item>
  397. <a-checkbox v-model="xraylogModal.showDirect" @change="openXrayLogs()">Direct</a-checkbox>
  398. <a-checkbox v-model="xraylogModal.showBlocked" @change="openXrayLogs()">Blocked</a-checkbox>
  399. <a-checkbox v-model="xraylogModal.showProxy" @change="openXrayLogs()">Proxy</a-checkbox>
  400. </a-form-item>
  401. <a-form-item style="float: right;">
  402. <a-button type="primary" icon="download" @click="FileManager.downloadTextFile(xraylogModal.logs?.join('\n'), 'x-ui.log')"></a-button>
  403. </a-form-item>
  404. </a-form>
  405. <div class="ant-input log-container" v-html="xraylogModal.formattedLogs"></div>
  406. </a-modal>
  407. <a-modal id="backup-modal"
  408. v-model="backupModal.visible"
  409. title='{{ i18n "pages.index.backupTitle" }}'
  410. :closable="true"
  411. footer=""
  412. :class="themeSwitcher.currentTheme">
  413. <a-list class="ant-backup-list w-100" bordered>
  414. <a-list-item class="ant-backup-list-item">
  415. <a-list-item-meta>
  416. <template #title>{{ i18n "pages.index.exportDatabase" }}</template>
  417. <template #description>{{ i18n "pages.index.exportDatabaseDesc" }}</template>
  418. </a-list-item-meta>
  419. <a-button @click="exportDatabase()" type="primary" icon="download"/>
  420. </a-list-item>
  421. <a-list-item class="ant-backup-list-item">
  422. <a-list-item-meta>
  423. <template #title>{{ i18n "pages.index.importDatabase" }}</template>
  424. <template #description>{{ i18n "pages.index.importDatabaseDesc" }}</template>
  425. </a-list-item-meta>
  426. <a-button @click="importDatabase()" type="primary" icon="upload" />
  427. </a-list-item>
  428. </a-list>
  429. </a-modal>
  430. <!-- CPU History Modal -->
  431. <a-modal id="cpu-history-modal"
  432. v-model="cpuHistoryModal.visible"
  433. :closable="true" @cancel="() => cpuHistoryModal.visible = false"
  434. :class="themeSwitcher.currentTheme"
  435. width="900px" footer="">
  436. <template slot="title">
  437. CPU History
  438. <a-select size="small" v-model="cpuHistoryModal.minutes" class="ml-10" style="width: 120px" @change="loadCpuHistory">
  439. <a-select-option :value="15">15 min</a-select-option>
  440. <a-select-option :value="60">1 hour</a-select-option>
  441. <a-select-option :value="180">3 hours</a-select-option>
  442. <a-select-option :value="360">6 hours</a-select-option>
  443. </a-select>
  444. </template>
  445. <div style="padding: 8px 0;">
  446. <sparkline :data="cpuHistoryLong"
  447. :labels="cpuHistoryLabels"
  448. :vb-width="840"
  449. :height="220"
  450. :stroke="status.cpu.color"
  451. :stroke-width="2.2"
  452. :show-grid="true"
  453. :show-axes="true"
  454. :tick-count-x="5"
  455. :fill-opacity="0.18"
  456. :marker-radius="3.2"
  457. :show-tooltip="true" />
  458. </div>
  459. </a-modal>
  460. </a-layout>
  461. {{template "page/body_scripts" .}}
  462. {{template "component/aSidebar" .}}
  463. {{template "component/aThemeSwitch" .}}
  464. {{template "component/aCustomStatistic" .}}
  465. {{template "modals/textModal"}}
  466. <script>
  467. // Tiny Sparkline component using an inline SVG polyline
  468. Vue.component('sparkline', {
  469. props: {
  470. data: { type: Array, required: true },
  471. // viewBox width for drawing space; SVG width will be 100% of container
  472. vbWidth: { type: Number, default: 320 },
  473. height: { type: Number, default: 80 },
  474. stroke: { type: String, default: '#008771' },
  475. strokeWidth: { type: Number, default: 2 },
  476. maxPoints: { type: Number, default: 120 },
  477. showGrid: { type: Boolean, default: true },
  478. gridColor: { type: String, default: 'rgba(255,255,255,0.08)' },
  479. fillOpacity: { type: Number, default: 0.15 },
  480. showMarker: { type: Boolean, default: true },
  481. markerRadius: { type: Number, default: 2.8 },
  482. // New opts for axes/labels/tooltip
  483. labels: { type: Array, default: () => [] }, // same length as data for x labels (e.g., timestamps)
  484. showAxes: { type: Boolean, default: false },
  485. yTickStep: { type: Number, default: 25 }, // percent ticks
  486. tickCountX: { type: Number, default: 4 },
  487. paddingLeft: { type: Number, default: 32 },
  488. paddingRight: { type: Number, default: 6 },
  489. paddingTop: { type: Number, default: 6 },
  490. paddingBottom: { type: Number, default: 20 },
  491. showTooltip: { type: Boolean, default: false },
  492. },
  493. data() {
  494. return {
  495. hoverIdx: -1,
  496. }
  497. },
  498. computed: {
  499. viewBoxAttr() {
  500. return '0 0 ' + this.vbWidth + ' ' + this.height
  501. },
  502. drawWidth() {
  503. return Math.max(1, this.vbWidth - this.paddingLeft - this.paddingRight)
  504. },
  505. drawHeight() {
  506. return Math.max(1, this.height - this.paddingTop - this.paddingBottom)
  507. },
  508. nPoints() {
  509. return Math.min(this.data.length, this.maxPoints)
  510. },
  511. dataSlice() {
  512. const n = this.nPoints
  513. if (n === 0) return []
  514. return this.data.slice(this.data.length - n)
  515. },
  516. labelsSlice() {
  517. const n = this.nPoints
  518. if (!this.labels || this.labels.length === 0 || n === 0) return []
  519. const start = Math.max(0, this.labels.length - n)
  520. return this.labels.slice(start)
  521. },
  522. pointsArr() {
  523. const n = this.nPoints
  524. if (n === 0) return []
  525. const slice = this.dataSlice
  526. const max = 100
  527. const w = this.drawWidth
  528. const h = this.drawHeight
  529. const dx = n > 1 ? w / (n - 1) : 0
  530. return slice.map((v, i) => {
  531. const x = Math.round(this.paddingLeft + i * dx)
  532. const y = Math.round(this.paddingTop + (h - (Math.max(0, Math.min(100, v)) / max) * h))
  533. return [x, y]
  534. })
  535. },
  536. points() {
  537. return this.pointsArr.map(p => `${p[0]},${p[1]}`).join(' ')
  538. },
  539. areaPath() {
  540. if (this.pointsArr.length === 0) return ''
  541. const first = this.pointsArr[0]
  542. const last = this.pointsArr[this.pointsArr.length - 1]
  543. const line = this.points
  544. // Close to bottom to create an area fill
  545. return `M ${first[0]},${this.paddingTop + this.drawHeight} L ${line.replace(/ /g,' L ')} L ${last[0]},${this.paddingTop + this.drawHeight} Z`
  546. },
  547. gridLines() {
  548. if (!this.showGrid) return []
  549. const h = this.drawHeight
  550. const w = this.drawWidth
  551. // draw at 25%, 50%, 75%
  552. return [0.25, 0.5, 0.75]
  553. .map(r => Math.round(this.paddingTop + h * r))
  554. .map(y => ({ x1: this.paddingLeft, y1: y, x2: this.paddingLeft + w, y2: y }))
  555. },
  556. lastPoint() {
  557. if (this.pointsArr.length === 0) return null
  558. return this.pointsArr[this.pointsArr.length - 1]
  559. },
  560. yTicks() {
  561. if (!this.showAxes) return []
  562. const step = Math.max(1, this.yTickStep)
  563. const ticks = []
  564. for (let p = 0; p <= 100; p += step) {
  565. const y = Math.round(this.paddingTop + (this.drawHeight - (p / 100) * this.drawHeight))
  566. ticks.push({ y, label: `${p}%` })
  567. }
  568. return ticks
  569. },
  570. xTicks() {
  571. if (!this.showAxes) return []
  572. const labels = this.labelsSlice
  573. const n = this.nPoints
  574. const m = Math.max(2, this.tickCountX)
  575. const ticks = []
  576. if (n === 0) return ticks
  577. const w = this.drawWidth
  578. const dx = n > 1 ? w / (n - 1) : 0
  579. const positions = []
  580. for (let i = 0; i < m; i++) {
  581. const idx = Math.round((i * (n - 1)) / (m - 1))
  582. positions.push(idx)
  583. }
  584. positions.forEach(idx => {
  585. const label = labels[idx] != null ? String(labels[idx]) : String(idx)
  586. const x = Math.round(this.paddingLeft + idx * dx)
  587. ticks.push({ x, label })
  588. })
  589. return ticks
  590. },
  591. },
  592. methods: {
  593. onMouseMove(evt) {
  594. if (!this.showTooltip || this.pointsArr.length === 0) return
  595. const rect = evt.currentTarget.getBoundingClientRect()
  596. const px = evt.clientX - rect.left
  597. // translate to viewBox space
  598. const x = (px / rect.width) * this.vbWidth
  599. const n = this.nPoints
  600. const dx = n > 1 ? this.drawWidth / (n - 1) : 0
  601. const idx = Math.max(0, Math.min(n - 1, Math.round((x - this.paddingLeft) / (dx || 1))))
  602. this.hoverIdx = idx
  603. },
  604. onMouseLeave() {
  605. this.hoverIdx = -1
  606. },
  607. fmtHoverText() {
  608. const labels = this.labelsSlice
  609. const idx = this.hoverIdx
  610. if (idx < 0 || idx >= this.dataSlice.length) return ''
  611. const val = Math.max(0, Math.min(100, Number(this.dataSlice[idx] || 0)))
  612. const lab = labels[idx] != null ? labels[idx] : ''
  613. return `${val}%${lab ? ' • ' + lab : ''}`
  614. },
  615. },
  616. template: `
  617. <svg width="100%" :height="height" :viewBox="viewBoxAttr" preserveAspectRatio="none" style="display:block"
  618. @mousemove="onMouseMove" @mouseleave="onMouseLeave">
  619. <defs>
  620. <linearGradient id="spkGrad" x1="0" y1="0" x2="0" y2="1">
  621. <stop offset="0%" :stop-color="stroke" :stop-opacity="fillOpacity"/>
  622. <stop offset="100%" :stop-color="stroke" stop-opacity="0"/>
  623. </linearGradient>
  624. </defs>
  625. <g v-if="showGrid">
  626. <line v-for="(g,i) in gridLines" :key="i" :x1="g.x1" :y1="g.y1" :x2="g.x2" :y2="g.y2" :stroke="gridColor" stroke-width="1"/>
  627. </g>
  628. <g v-if="showAxes">
  629. <!-- Y ticks/labels -->
  630. <g v-for="(t,i) in yTicks" :key="'y'+i">
  631. <text :x="Math.max(0, paddingLeft - 4)" :y="t.y + 4" text-anchor="end" font-size="10" fill="rgba(200,200,200,0.8)" v-text="t.label"></text>
  632. </g>
  633. <!-- X ticks/labels -->
  634. <g v-for="(t,i) in xTicks" :key="'x'+i">
  635. <text :x="t.x" :y="paddingTop + drawHeight + 14" text-anchor="middle" font-size="10" fill="rgba(200,200,200,0.8)" v-text="t.label"></text>
  636. </g>
  637. </g>
  638. <path v-if="areaPath" :d="areaPath" fill="url(#spkGrad)" stroke="none" />
  639. <polyline :points="points" fill="none" :stroke="stroke" :stroke-width="strokeWidth" stroke-linecap="round" stroke-linejoin="round"/>
  640. <circle v-if="showMarker && lastPoint" :cx="lastPoint[0]" :cy="lastPoint[1]" :r="markerRadius" :fill="stroke" />
  641. <!-- Hover marker/tooltip -->
  642. <g v-if="showTooltip && hoverIdx >= 0">
  643. <line :x1="pointsArr[hoverIdx][0]" :x2="pointsArr[hoverIdx][0]" :y1="paddingTop" :y2="paddingTop + drawHeight" stroke="rgba(255,255,255,0.25)" stroke-width="1" />
  644. <circle :cx="pointsArr[hoverIdx][0]" :cy="pointsArr[hoverIdx][1]" r="3.5" :fill="stroke" />
  645. <text :x="pointsArr[hoverIdx][0]" :y="paddingTop + 12" text-anchor="middle" font-size="11" fill="#fff" style="paint-order: stroke; stroke: rgba(0,0,0,0.35); stroke-width: 3;" v-text="fmtHoverText()"></text>
  646. </g>
  647. </svg>
  648. `,
  649. })
  650. class CurTotal {
  651. constructor(current, total) {
  652. this.current = current;
  653. this.total = total;
  654. }
  655. get percent() {
  656. if (this.total === 0) {
  657. return 0;
  658. }
  659. return NumberFormatter.toFixed(this.current / this.total * 100, 2);
  660. }
  661. get color() {
  662. const percent = this.percent;
  663. if (percent < 80) {
  664. return '#008771'; // Green
  665. } else if (percent < 90) {
  666. return "#f37b24"; // Orange
  667. } else {
  668. return "#cf3c3c"; // Red
  669. }
  670. }
  671. }
  672. class Status {
  673. constructor(data) {
  674. this.cpu = new CurTotal(0, 0);
  675. this.cpuCores = 0;
  676. this.logicalPro = 0;
  677. this.cpuSpeedMhz = 0;
  678. this.disk = new CurTotal(0, 0);
  679. this.loads = [0, 0, 0];
  680. this.mem = new CurTotal(0, 0);
  681. this.netIO = { up: 0, down: 0 };
  682. this.netTraffic = { sent: 0, recv: 0 };
  683. this.publicIP = { ipv4: 0, ipv6: 0 };
  684. this.swap = new CurTotal(0, 0);
  685. this.tcpCount = 0;
  686. this.udpCount = 0;
  687. this.uptime = 0;
  688. this.appUptime = 0;
  689. this.appStats = {threads: 0, mem: 0, uptime: 0};
  690. this.xray = { state: 'stop', stateMsg: "", errorMsg: "", version: "", color: "" };
  691. if (data == null) {
  692. return;
  693. }
  694. this.cpu = new CurTotal(data.cpu, 100);
  695. this.cpuCores = data.cpuCores;
  696. this.logicalPro = data.logicalPro;
  697. this.cpuSpeedMhz = data.cpuSpeedMhz;
  698. this.disk = new CurTotal(data.disk.current, data.disk.total);
  699. this.loads = data.loads.map(load => NumberFormatter.toFixed(load, 2));
  700. this.mem = new CurTotal(data.mem.current, data.mem.total);
  701. this.netIO = data.netIO;
  702. this.netTraffic = data.netTraffic;
  703. this.publicIP = data.publicIP;
  704. this.swap = new CurTotal(data.swap.current, data.swap.total);
  705. this.tcpCount = data.tcpCount;
  706. this.udpCount = data.udpCount;
  707. this.uptime = data.uptime;
  708. this.appUptime = data.appUptime;
  709. this.appStats = data.appStats;
  710. this.xray = data.xray;
  711. switch (this.xray.state) {
  712. case 'running':
  713. this.xray.color = "green";
  714. this.xray.stateMsg = '{{ i18n "pages.index.xrayStatusRunning" }}';
  715. break;
  716. case 'stop':
  717. this.xray.color = "orange";
  718. this.xray.stateMsg = '{{ i18n "pages.index.xrayStatusStop" }}';
  719. break;
  720. case 'error':
  721. this.xray.color = "red";
  722. this.xray.stateMsg ='{{ i18n "pages.index.xrayStatusError" }}';
  723. break;
  724. default:
  725. this.xray.color = "gray";
  726. this.xray.stateMsg = '{{ i18n "pages.index.xrayStatusUnknown" }}';
  727. break;
  728. }
  729. }
  730. }
  731. const versionModal = {
  732. visible: false,
  733. versions: [],
  734. show(versions) {
  735. this.visible = true;
  736. this.versions = versions;
  737. },
  738. hide() {
  739. this.visible = false;
  740. },
  741. };
  742. const logModal = {
  743. visible: false,
  744. logs: [],
  745. rows: 20,
  746. level: 'info',
  747. syslog: false,
  748. loading: false,
  749. show(logs) {
  750. this.visible = true;
  751. this.logs = logs;
  752. this.formattedLogs = this.logs?.length > 0 ? this.formatLogs(this.logs) : "No Record...";
  753. },
  754. formatLogs(logs) {
  755. let formattedLogs = '';
  756. const levels = ["DEBUG","INFO","NOTICE","WARNING","ERROR"];
  757. const levelColors = ["#3c89e8","#008771","#008771","#f37b24","#e04141","#bcbcbc"];
  758. logs.forEach((log, index) => {
  759. let [data, message] = log.split(" - ",2);
  760. const parts = data.split(" ")
  761. if(index>0) formattedLogs += '<br>';
  762. if (parts.length === 3) {
  763. const d = parts[0];
  764. const t = parts[1];
  765. const level = parts[2];
  766. const levelIndex = levels.indexOf(level,levels) || 5;
  767. //formattedLogs += `<span style="color: gray;">${index + 1}.</span>`;
  768. formattedLogs += `<span style="color: ${levelColors[0]};">${d} ${t}</span> `;
  769. formattedLogs += `<span style="color: ${levelColors[levelIndex]}">${level}</span>`;
  770. } else {
  771. const levelIndex = levels.indexOf(data,levels) || 5;
  772. formattedLogs += `<span style="color: ${levelColors[levelIndex]}">${data}</span>`;
  773. }
  774. if(message){
  775. if(message.startsWith("XRAY:"))
  776. message = "<b>XRAY: </b>" + message.substring(5);
  777. else
  778. message = "<b>X-UI: </b>" + message;
  779. }
  780. formattedLogs += message ? ' - ' + message : '';
  781. });
  782. return formattedLogs;
  783. },
  784. hide() {
  785. this.visible = false;
  786. },
  787. };
  788. const xraylogModal = {
  789. visible: false,
  790. logs: [],
  791. rows: 20,
  792. showDirect: true,
  793. showBlocked: true,
  794. showProxy: true,
  795. loading: false,
  796. show(logs) {
  797. this.visible = true;
  798. this.logs = logs;
  799. this.formattedLogs = this.logs?.length > 0 ? this.formatLogs(this.logs) : "No Record...";
  800. },
  801. formatLogs(logs) {
  802. let formattedLogs = '';
  803. logs.forEach((log, index) => {
  804. if(index > 0) formattedLogs += '<br>';
  805. const parts = log.split(' ');
  806. if(parts.length === 10) {
  807. const dateTime = `<b>${parts[0]} ${parts[1]}</b>`;
  808. const from = `<b>${parts[3]}</b>`;
  809. const to = `<b>${parts[5].replace(/^\/+/, "")}</b>`;
  810. let outboundColor = '';
  811. if (parts[9] === "b") {
  812. outboundColor = ' style="color: #e04141;"'; //red for blocked
  813. }
  814. else if (parts[9] === "p") {
  815. outboundColor = ' style="color: #3c89e8;"'; //blue for proxies
  816. }
  817. formattedLogs += `<span${outboundColor}>
  818. ${dateTime}
  819. ${parts[2]}
  820. ${from}
  821. ${parts[4]}
  822. ${to}
  823. ${parts.slice(6, 9).join(' ')}
  824. </span>`;
  825. } else {
  826. formattedLogs += `<span>${log}</span>`;
  827. }
  828. });
  829. return formattedLogs;
  830. },
  831. hide() {
  832. this.visible = false;
  833. },
  834. };
  835. const backupModal = {
  836. visible: false,
  837. show() {
  838. this.visible = true;
  839. },
  840. hide() {
  841. this.visible = false;
  842. },
  843. };
  844. const app = new Vue({
  845. delimiters: ['[[', ']]'],
  846. el: '#app',
  847. mixins: [MediaQueryMixin],
  848. data: {
  849. themeSwitcher,
  850. loadingStates: {
  851. fetched: false,
  852. spinning: false
  853. },
  854. status: new Status(),
  855. cpuHistory: [], // keep last N cpu utilization points (0..100)
  856. cpuHistoryLong: [], // long-range history for modal (values)
  857. cpuHistoryLabels: [], // formatted timestamps matching long history
  858. cpuHistoryModal: { visible: false, minutes: 60 },
  859. versionModal,
  860. logModal,
  861. xraylogModal,
  862. backupModal,
  863. loadingTip: '{{ i18n "loading"}}',
  864. showAlert: false,
  865. showIp: false,
  866. ipLimitEnable: false,
  867. },
  868. methods: {
  869. loading(spinning, tip = '{{ i18n "loading"}}') {
  870. this.loadingStates.spinning = spinning;
  871. this.loadingTip = tip;
  872. },
  873. async getStatus() {
  874. try {
  875. const msg = await HttpUtil.get('/panel/api/server/status');
  876. if (msg.success) {
  877. if (!this.loadingStates.fetched) {
  878. this.loadingStates.fetched = true;
  879. }
  880. this.setStatus(msg.obj, true);
  881. }
  882. } catch (e) {
  883. console.error("Failed to get status:", e);
  884. }
  885. },
  886. setStatus(data) {
  887. this.status = new Status(data);
  888. // Push CPU percent into history (clamped 0..100)
  889. const v = Math.max(0, Math.min(100, Number(data?.cpu ?? 0)))
  890. this.cpuHistory.push(v)
  891. const maxPoints = this.isMobile ? 60 : 120
  892. if (this.cpuHistory.length > maxPoints) {
  893. this.cpuHistory.splice(0, this.cpuHistory.length - maxPoints)
  894. }
  895. },
  896. openCpuHistory() {
  897. this.cpuHistoryModal.visible = true
  898. this.loadCpuHistory()
  899. },
  900. async loadCpuHistory() {
  901. const mins = this.cpuHistoryModal.minutes || 60
  902. try {
  903. const msg = await HttpUtil.get(`/panel/api/server/cpuHistory?q=${mins}`)
  904. if (msg.success && Array.isArray(msg.obj)) {
  905. // msg.obj is array of {t, cpu}
  906. const arr = msg.obj.map(p => Math.max(0, Math.min(100, Number(p.cpu || 0))))
  907. const labels = msg.obj.map(p => {
  908. const t = p.t
  909. let d
  910. if (typeof t === 'number') {
  911. // Heuristic: if seconds, convert to ms
  912. d = new Date(t < 1e12 ? t * 1000 : t)
  913. } else {
  914. d = new Date(t)
  915. }
  916. if (isNaN(d.getTime())) return ''
  917. const hh = String(d.getHours()).padStart(2, '0')
  918. const mm = String(d.getMinutes()).padStart(2, '0')
  919. return `${hh}:${mm}`
  920. })
  921. this.cpuHistoryLong = arr
  922. this.cpuHistoryLabels = labels
  923. }
  924. } catch (e) {
  925. console.error('Failed to load CPU history', e)
  926. }
  927. },
  928. async openSelectV2rayVersion() {
  929. this.loading(true);
  930. const msg = await HttpUtil.get('/panel/api/server/getXrayVersion');
  931. this.loading(false);
  932. if (!msg.success) {
  933. return;
  934. }
  935. versionModal.show(msg.obj);
  936. },
  937. switchV2rayVersion(version) {
  938. this.$confirm({
  939. title: '{{ i18n "pages.index.xraySwitchVersionDialog"}}',
  940. content: '{{ i18n "pages.index.xraySwitchVersionDialogDesc"}}'.replace('#version#', version),
  941. okText: '{{ i18n "confirm"}}',
  942. class: themeSwitcher.currentTheme,
  943. cancelText: '{{ i18n "cancel"}}',
  944. onOk: async () => {
  945. versionModal.hide();
  946. this.loading(true, '{{ i18n "pages.index.dontRefresh"}}');
  947. await HttpUtil.post(`/panel/api/server/installXray/${version}`);
  948. this.loading(false);
  949. },
  950. });
  951. },
  952. updateGeofile(fileName) {
  953. const isSingleFile = !!fileName;
  954. this.$confirm({
  955. title: '{{ i18n "pages.index.geofileUpdateDialog" }}',
  956. content: isSingleFile
  957. ? '{{ i18n "pages.index.geofileUpdateDialogDesc" }}'.replace("#filename#", fileName)
  958. : '{{ i18n "pages.index.geofilesUpdateDialogDesc" }}',
  959. okText: '{{ i18n "confirm"}}',
  960. class: themeSwitcher.currentTheme,
  961. cancelText: '{{ i18n "cancel"}}',
  962. onOk: async () => {
  963. versionModal.hide();
  964. this.loading(true, '{{ i18n "pages.index.dontRefresh"}}');
  965. const url = isSingleFile
  966. ? `/panel/api/server/updateGeofile/${fileName}`
  967. : `/panel/api/server/updateGeofile`;
  968. await HttpUtil.post(url);
  969. this.loading(false);
  970. },
  971. });
  972. },
  973. async stopXrayService() {
  974. this.loading(true);
  975. const msg = await HttpUtil.post('/panel/api/server/stopXrayService');
  976. this.loading(false);
  977. if (!msg.success) {
  978. return;
  979. }
  980. },
  981. async restartXrayService() {
  982. this.loading(true);
  983. const msg = await HttpUtil.post('/panel/api/server/restartXrayService');
  984. this.loading(false);
  985. if (!msg.success) {
  986. return;
  987. }
  988. },
  989. async openLogs(){
  990. logModal.loading = true;
  991. const msg = await HttpUtil.post('/panel/api/server/logs/'+logModal.rows,{level: logModal.level, syslog: logModal.syslog});
  992. if (!msg.success) {
  993. return;
  994. }
  995. logModal.show(msg.obj);
  996. await PromiseUtil.sleep(500);
  997. logModal.loading = false;
  998. },
  999. async openXrayLogs(){
  1000. xraylogModal.loading = true;
  1001. const msg = await HttpUtil.post('/panel/api/server/xraylogs/'+xraylogModal.rows,{filter: xraylogModal.filter, showDirect: xraylogModal.showDirect, showBlocked: xraylogModal.showBlocked, showProxy: xraylogModal.showProxy});
  1002. if (!msg.success) {
  1003. return;
  1004. }
  1005. xraylogModal.show(msg.obj);
  1006. await PromiseUtil.sleep(500);
  1007. xraylogModal.loading = false;
  1008. },
  1009. async openConfig() {
  1010. this.loading(true);
  1011. const msg = await HttpUtil.get('/panel/api/server/getConfigJson');
  1012. this.loading(false);
  1013. if (!msg.success) {
  1014. return;
  1015. }
  1016. txtModal.show('config.json', JSON.stringify(msg.obj, null, 2), 'config.json');
  1017. },
  1018. openBackup() {
  1019. backupModal.show();
  1020. },
  1021. exportDatabase() {
  1022. window.location = basePath + 'panel/api/server/getDb';
  1023. },
  1024. importDatabase() {
  1025. const fileInput = document.createElement('input');
  1026. fileInput.type = 'file';
  1027. fileInput.accept = '.db';
  1028. fileInput.addEventListener('change', async (event) => {
  1029. const dbFile = event.target.files[0];
  1030. if (dbFile) {
  1031. const formData = new FormData();
  1032. formData.append('db', dbFile);
  1033. backupModal.hide();
  1034. this.loading(true);
  1035. const uploadMsg = await HttpUtil.post('/panel/api/server/importDB', formData, {
  1036. headers: {
  1037. 'Content-Type': 'multipart/form-data',
  1038. }
  1039. });
  1040. this.loading(false);
  1041. if (!uploadMsg.success) {
  1042. return;
  1043. }
  1044. this.loading(true);
  1045. const restartMsg = await HttpUtil.post("/panel/setting/restartPanel");
  1046. this.loading(false);
  1047. if (restartMsg.success) {
  1048. this.loading(true);
  1049. await PromiseUtil.sleep(5000);
  1050. location.reload();
  1051. }
  1052. }
  1053. });
  1054. fileInput.click();
  1055. },
  1056. },
  1057. async mounted() {
  1058. if (window.location.protocol !== "https:") {
  1059. this.showAlert = true;
  1060. }
  1061. const msg = await HttpUtil.post('/panel/setting/defaultSettings');
  1062. if (msg.success) {
  1063. this.ipLimitEnable = msg.obj.ipLimitEnable;
  1064. }
  1065. while (true) {
  1066. try {
  1067. await this.getStatus();
  1068. } catch (e) {
  1069. console.error(e);
  1070. }
  1071. await PromiseUtil.sleep(2000);
  1072. }
  1073. },
  1074. });
  1075. </script>
  1076. {{ template "page/body_end" .}}