index.html 45 KB

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