index.html 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  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. <style>
  804. table {
  805. border-collapse: collapse;
  806. width: auto;
  807. }
  808. table td, table th {
  809. padding: 2px 15px;
  810. }
  811. </style>
  812. <table>
  813. <tr>
  814. <th>Date</th>
  815. <th>From</th>
  816. <th>To</th>
  817. <th>Inbound</th>
  818. <th>Outbound</th>
  819. <th>Email</th>
  820. </tr>
  821. `;
  822. logs.reverse().forEach((log, index) => {
  823. let outboundColor = '';
  824. if (log.Event === 1) {
  825. outboundColor = ' style="color: #e04141;"'; //red for blocked
  826. }
  827. else if (log.Event === 2) {
  828. outboundColor = ' style="color: #3c89e8;"'; //blue for proxies
  829. }
  830. let text = ``;
  831. if (log.Email !== "") {
  832. text = `<td>${log.Email}</td>`;
  833. }
  834. formattedLogs += `
  835. <tr ${outboundColor}>
  836. <td><b>${new Date(log.DateTime).toLocaleString()}</b></td>
  837. <td>${log.FromAddress}</td>
  838. <td>${log.ToAddress}</td>
  839. <td>${log.Inbound}</td>
  840. <td>${log.Outbound}</td>
  841. ${text}
  842. </tr>
  843. `;
  844. });
  845. return formattedLogs += "</table>";
  846. },
  847. hide() {
  848. this.visible = false;
  849. },
  850. };
  851. const backupModal = {
  852. visible: false,
  853. show() {
  854. this.visible = true;
  855. },
  856. hide() {
  857. this.visible = false;
  858. },
  859. };
  860. const app = new Vue({
  861. delimiters: ['[[', ']]'],
  862. el: '#app',
  863. mixins: [MediaQueryMixin],
  864. data: {
  865. themeSwitcher,
  866. loadingStates: {
  867. fetched: false,
  868. spinning: false
  869. },
  870. status: new Status(),
  871. cpuHistory: [], // keep last N cpu utilization points (0..100)
  872. cpuHistoryLong: [], // long-range history for modal (values)
  873. cpuHistoryLabels: [], // formatted timestamps matching long history
  874. cpuHistoryModal: { visible: false, minutes: 60 },
  875. versionModal,
  876. logModal,
  877. xraylogModal,
  878. backupModal,
  879. loadingTip: '{{ i18n "loading"}}',
  880. showAlert: false,
  881. showIp: false,
  882. ipLimitEnable: false,
  883. },
  884. methods: {
  885. loading(spinning, tip = '{{ i18n "loading"}}') {
  886. this.loadingStates.spinning = spinning;
  887. this.loadingTip = tip;
  888. },
  889. async getStatus() {
  890. try {
  891. const msg = await HttpUtil.get('/panel/api/server/status');
  892. if (msg.success) {
  893. if (!this.loadingStates.fetched) {
  894. this.loadingStates.fetched = true;
  895. }
  896. this.setStatus(msg.obj, true);
  897. }
  898. } catch (e) {
  899. console.error("Failed to get status:", e);
  900. }
  901. },
  902. setStatus(data) {
  903. this.status = new Status(data);
  904. // Push CPU percent into history (clamped 0..100)
  905. const v = Math.max(0, Math.min(100, Number(data?.cpu ?? 0)))
  906. this.cpuHistory.push(v)
  907. const maxPoints = this.isMobile ? 60 : 120
  908. if (this.cpuHistory.length > maxPoints) {
  909. this.cpuHistory.splice(0, this.cpuHistory.length - maxPoints)
  910. }
  911. },
  912. openCpuHistory() {
  913. this.cpuHistoryModal.visible = true
  914. this.loadCpuHistory()
  915. },
  916. async loadCpuHistory() {
  917. const mins = this.cpuHistoryModal.minutes || 60
  918. try {
  919. const msg = await HttpUtil.get(`/panel/api/server/cpuHistory?q=${mins}`)
  920. if (msg.success && Array.isArray(msg.obj)) {
  921. // msg.obj is array of {t, cpu}
  922. const arr = msg.obj.map(p => Math.max(0, Math.min(100, Number(p.cpu || 0))))
  923. const labels = msg.obj.map(p => {
  924. const t = p.t
  925. let d
  926. if (typeof t === 'number') {
  927. // Heuristic: if seconds, convert to ms
  928. d = new Date(t < 1e12 ? t * 1000 : t)
  929. } else {
  930. d = new Date(t)
  931. }
  932. if (isNaN(d.getTime())) return ''
  933. const hh = String(d.getHours()).padStart(2, '0')
  934. const mm = String(d.getMinutes()).padStart(2, '0')
  935. return `${hh}:${mm}`
  936. })
  937. this.cpuHistoryLong = arr
  938. this.cpuHistoryLabels = labels
  939. }
  940. } catch (e) {
  941. console.error('Failed to load CPU history', e)
  942. }
  943. },
  944. async openSelectV2rayVersion() {
  945. this.loading(true);
  946. const msg = await HttpUtil.get('/panel/api/server/getXrayVersion');
  947. this.loading(false);
  948. if (!msg.success) {
  949. return;
  950. }
  951. versionModal.show(msg.obj);
  952. },
  953. switchV2rayVersion(version) {
  954. this.$confirm({
  955. title: '{{ i18n "pages.index.xraySwitchVersionDialog"}}',
  956. content: '{{ i18n "pages.index.xraySwitchVersionDialogDesc"}}'.replace('#version#', version),
  957. okText: '{{ i18n "confirm"}}',
  958. class: themeSwitcher.currentTheme,
  959. cancelText: '{{ i18n "cancel"}}',
  960. onOk: async () => {
  961. versionModal.hide();
  962. this.loading(true, '{{ i18n "pages.index.dontRefresh"}}');
  963. await HttpUtil.post(`/panel/api/server/installXray/${version}`);
  964. this.loading(false);
  965. },
  966. });
  967. },
  968. updateGeofile(fileName) {
  969. const isSingleFile = !!fileName;
  970. this.$confirm({
  971. title: '{{ i18n "pages.index.geofileUpdateDialog" }}',
  972. content: isSingleFile
  973. ? '{{ i18n "pages.index.geofileUpdateDialogDesc" }}'.replace("#filename#", fileName)
  974. : '{{ i18n "pages.index.geofilesUpdateDialogDesc" }}',
  975. okText: '{{ i18n "confirm"}}',
  976. class: themeSwitcher.currentTheme,
  977. cancelText: '{{ i18n "cancel"}}',
  978. onOk: async () => {
  979. versionModal.hide();
  980. this.loading(true, '{{ i18n "pages.index.dontRefresh"}}');
  981. const url = isSingleFile
  982. ? `/panel/api/server/updateGeofile/${fileName}`
  983. : `/panel/api/server/updateGeofile`;
  984. await HttpUtil.post(url);
  985. this.loading(false);
  986. },
  987. });
  988. },
  989. async stopXrayService() {
  990. this.loading(true);
  991. const msg = await HttpUtil.post('/panel/api/server/stopXrayService');
  992. this.loading(false);
  993. if (!msg.success) {
  994. return;
  995. }
  996. },
  997. async restartXrayService() {
  998. this.loading(true);
  999. const msg = await HttpUtil.post('/panel/api/server/restartXrayService');
  1000. this.loading(false);
  1001. if (!msg.success) {
  1002. return;
  1003. }
  1004. },
  1005. async openLogs(){
  1006. logModal.loading = true;
  1007. const msg = await HttpUtil.post('/panel/api/server/logs/'+logModal.rows,{level: logModal.level, syslog: logModal.syslog});
  1008. if (!msg.success) {
  1009. return;
  1010. }
  1011. logModal.show(msg.obj);
  1012. await PromiseUtil.sleep(500);
  1013. logModal.loading = false;
  1014. },
  1015. async openXrayLogs(){
  1016. xraylogModal.loading = true;
  1017. const msg = await HttpUtil.post('/panel/api/server/xraylogs/'+xraylogModal.rows,{filter: xraylogModal.filter, showDirect: xraylogModal.showDirect, showBlocked: xraylogModal.showBlocked, showProxy: xraylogModal.showProxy});
  1018. if (!msg.success) {
  1019. return;
  1020. }
  1021. xraylogModal.show(msg.obj);
  1022. await PromiseUtil.sleep(500);
  1023. xraylogModal.loading = false;
  1024. },
  1025. async openConfig() {
  1026. this.loading(true);
  1027. const msg = await HttpUtil.get('/panel/api/server/getConfigJson');
  1028. this.loading(false);
  1029. if (!msg.success) {
  1030. return;
  1031. }
  1032. txtModal.show('config.json', JSON.stringify(msg.obj, null, 2), 'config.json');
  1033. },
  1034. openBackup() {
  1035. backupModal.show();
  1036. },
  1037. exportDatabase() {
  1038. window.location = basePath + 'panel/api/server/getDb';
  1039. },
  1040. importDatabase() {
  1041. const fileInput = document.createElement('input');
  1042. fileInput.type = 'file';
  1043. fileInput.accept = '.db';
  1044. fileInput.addEventListener('change', async (event) => {
  1045. const dbFile = event.target.files[0];
  1046. if (dbFile) {
  1047. const formData = new FormData();
  1048. formData.append('db', dbFile);
  1049. backupModal.hide();
  1050. this.loading(true);
  1051. const uploadMsg = await HttpUtil.post('/panel/api/server/importDB', formData, {
  1052. headers: {
  1053. 'Content-Type': 'multipart/form-data',
  1054. }
  1055. });
  1056. this.loading(false);
  1057. if (!uploadMsg.success) {
  1058. return;
  1059. }
  1060. this.loading(true);
  1061. const restartMsg = await HttpUtil.post("/panel/setting/restartPanel");
  1062. this.loading(false);
  1063. if (restartMsg.success) {
  1064. this.loading(true);
  1065. await PromiseUtil.sleep(5000);
  1066. location.reload();
  1067. }
  1068. }
  1069. });
  1070. fileInput.click();
  1071. },
  1072. },
  1073. async mounted() {
  1074. if (window.location.protocol !== "https:") {
  1075. this.showAlert = true;
  1076. }
  1077. const msg = await HttpUtil.post('/panel/setting/defaultSettings');
  1078. if (msg.success) {
  1079. this.ipLimitEnable = msg.obj.ipLimitEnable;
  1080. }
  1081. while (true) {
  1082. try {
  1083. await this.getStatus();
  1084. } catch (e) {
  1085. console.error(e);
  1086. }
  1087. await PromiseUtil.sleep(2000);
  1088. }
  1089. },
  1090. });
  1091. </script>
  1092. {{ template "page/body_end" .}}