outbounds.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. {{define "settings/xray/outbounds"}}
  2. <a-space direction="vertical" size="middle" class="outbounds-modern">
  3. <a-row :gutter="[12, 12]" align="middle" justify="space-between">
  4. <a-col :xs="24" :sm="14" :lg="14">
  5. <a-space direction="horizontal" size="small" class="outbounds-toolbar">
  6. <a-button type="primary" icon="plus" @click="addOutbound">
  7. <span v-if="!isMobile">{{ i18n "pages.xray.outbound.addOutbound" }}</span>
  8. </a-button>
  9. <a-button type="primary" icon="cloud" @click="showWarp()">WARP</a-button>
  10. <a-button type="primary" icon="api" @click="showNord()">NordVPN</a-button>
  11. </a-space>
  12. </a-col>
  13. <a-col :xs="24" :sm="10" :lg="10" class="outbounds-toolbar-right">
  14. <a-button-group>
  15. <a-button icon="sync" @click="refreshOutboundTraffic()" :loading="refreshing"></a-button>
  16. <a-popconfirm placement="topRight" @confirm="resetOutboundTraffic(-1)"
  17. title='{{ i18n "pages.inbounds.resetTrafficContent"}}'
  18. :overlay-class-name="themeSwitcher.currentTheme" ok-text='{{ i18n "reset"}}'
  19. cancel-text='{{ i18n "cancel"}}'>
  20. <a-icon slot="icon" type="question-circle-o"
  21. :style="{ color: '#008771' }"></a-icon>
  22. <a-button icon="retweet"></a-button>
  23. </a-popconfirm>
  24. </a-button-group>
  25. </a-col>
  26. </a-row>
  27. <!-- Mobile: card list -->
  28. <template v-if="isMobile">
  29. <div v-if="outboundData.length === 0" class="outbound-card-empty">—</div>
  30. <div v-for="(outbound, index) in outboundData" :key="outbound.key" class="outbound-card">
  31. <!-- card header: number + tag + protocol pills + action menu -->
  32. <div class="outbound-card-header">
  33. <div class="outbound-card-identity">
  34. <div class="outbound-card-title">
  35. <span class="outbound-card-num">[[ index + 1 ]]</span>
  36. <a-tooltip :title="outbound.tag" :overlay-class-name="themeSwitcher.currentTheme">
  37. <span class="outbound-tag">[[ outbound.tag ]]</span>
  38. </a-tooltip>
  39. </div>
  40. <div class="outbound-protocol-cell">
  41. <span class="outbound-pill" :class="outboundProtocolTone(outbound.protocol)">
  42. [[ outbound.protocol ]]
  43. </span>
  44. <template v-if="[Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(outbound.protocol)">
  45. <span class="outbound-pill" :class="outboundNetworkTone(outbound.streamSettings.network)">
  46. [[ outbound.streamSettings.network ]]
  47. </span>
  48. <span class="outbound-pill" :class="outboundSecurityTone(outbound.streamSettings.security)"
  49. v-if="isOutboundSecurityVisible(outbound.streamSettings.security)">
  50. [[ outbound.streamSettings.security ]]
  51. </span>
  52. </template>
  53. </div>
  54. </div>
  55. <a-dropdown :trigger="['click']">
  56. <a-button shape="circle" size="small" class="outbound-action-btn"
  57. @click="e => e.preventDefault()">
  58. <a-icon type="more"></a-icon>
  59. </a-button>
  60. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  61. <a-menu-item v-if="index > 0" @click="setFirstOutbound(index)">
  62. <a-icon type="vertical-align-top"></a-icon>
  63. <span>{{ i18n "pages.xray.rules.first" }}</span>
  64. </a-menu-item>
  65. <a-menu-item @click="editOutbound(index)">
  66. <a-icon type="edit"></a-icon>
  67. <span>{{ i18n "edit" }}</span>
  68. </a-menu-item>
  69. <a-menu-item @click="resetOutboundTraffic(index)">
  70. <a-icon type="retweet"></a-icon>
  71. <span>{{ i18n "pages.inbounds.resetTraffic" }}</span>
  72. </a-menu-item>
  73. <a-menu-item @click="deleteOutbound(index)">
  74. <span :style="{ color: '#FF4D4F' }">
  75. <a-icon type="delete"></a-icon>
  76. <span>{{ i18n "delete" }}</span>
  77. </span>
  78. </a-menu-item>
  79. </a-menu>
  80. </a-dropdown>
  81. </div>
  82. <!-- address pills -->
  83. <div class="outbound-address-list" v-if="outboundAddresses(outbound).length > 0">
  84. <a-tooltip v-for="addr in outboundAddresses(outbound)" :key="addr"
  85. :title="addr" :overlay-class-name="themeSwitcher.currentTheme">
  86. <span class="outbound-address-pill">[[ addr ]]</span>
  87. </a-tooltip>
  88. </div>
  89. <!-- card footer: traffic + test -->
  90. <div class="outbound-card-footer">
  91. <div class="outbound-traffic-cell">
  92. <span class="outbound-traffic-up">
  93. <a-icon type="arrow-up"></a-icon>
  94. [[ SizeFormatter.sizeFormat(findOutboundUp(outbound)) ]]
  95. </span>
  96. <span class="outbound-traffic-sep" aria-hidden="true"></span>
  97. <span class="outbound-traffic-down">
  98. <a-icon type="arrow-down"></a-icon>
  99. [[ SizeFormatter.sizeFormat(findOutboundDown(outbound)) ]]
  100. </span>
  101. </div>
  102. <div class="outbound-card-test">
  103. <div v-if="outboundTestResult(index)">
  104. <span v-if="outboundTestResult(index).success"
  105. class="outbound-result-pill outbound-result-ok">
  106. <a-icon type="check-circle" theme="filled"></a-icon>
  107. [[ outboundTestResult(index).delay ]]&nbsp;ms
  108. </span>
  109. <a-tooltip v-else :title="outboundTestResult(index).error"
  110. :overlay-class-name="themeSwitcher.currentTheme">
  111. <span class="outbound-result-pill outbound-result-fail">
  112. <a-icon type="close-circle" theme="filled"></a-icon>
  113. {{ i18n "pages.xray.outbound.testFailed" }}
  114. </span>
  115. </a-tooltip>
  116. </div>
  117. <a-icon type="loading" class="outbound-result-loading"
  118. v-else-if="isOutboundTesting(index)"></a-icon>
  119. <a-button type="primary" shape="circle" size="small" icon="thunderbolt"
  120. class="outbound-test-btn"
  121. :loading="isOutboundTesting(index)"
  122. @click="testOutbound(index)"
  123. :disabled="isOutboundUntestable(outbound) || isOutboundTesting(index)">
  124. </a-button>
  125. </div>
  126. </div>
  127. </div>
  128. </template>
  129. <!-- Desktop: table -->
  130. <a-table v-if="!isMobile" :columns="outboundColumns" :row-key="r => r.key"
  131. :data-source="outboundData"
  132. :scroll="{}"
  133. :pagination="false"
  134. :indent-size="0"
  135. class="outbounds-table"
  136. :locale='{ filterConfirm: `{{ i18n "confirm" }}`, filterReset: `{{ i18n "reset" }}` }'>
  137. <template slot="action" slot-scope="text, outbound, index">
  138. <div class="outbound-action-cell">
  139. <span class="outbound-index">[[ index+1 ]]</span>
  140. <a-dropdown :trigger="['click']">
  141. <a-button shape="circle" size="small" class="outbound-action-btn"
  142. @click="e => e.preventDefault()">
  143. <a-icon type="more"></a-icon>
  144. </a-button>
  145. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  146. <a-menu-item v-if="index>0"
  147. @click="setFirstOutbound(index)">
  148. <a-icon type="vertical-align-top"></a-icon>
  149. <span>{{ i18n "pages.xray.rules.first"}}</span>
  150. </a-menu-item>
  151. <a-menu-item @click="editOutbound(index)">
  152. <a-icon type="edit"></a-icon>
  153. <span>{{ i18n "edit" }}</span>
  154. </a-menu-item>
  155. <a-menu-item @click="resetOutboundTraffic(index)">
  156. <a-icon type="retweet"></a-icon>
  157. <span>{{ i18n "pages.inbounds.resetTraffic"}}</span>
  158. </a-menu-item>
  159. <a-menu-item @click="deleteOutbound(index)">
  160. <span :style="{ color: '#FF4D4F' }">
  161. <a-icon type="delete"></a-icon>
  162. <span>{{ i18n "delete"}}</span>
  163. </span>
  164. </a-menu-item>
  165. </a-menu>
  166. </a-dropdown>
  167. </div>
  168. </template>
  169. <template slot="identity" slot-scope="text, outbound">
  170. <div class="outbound-identity-cell">
  171. <a-tooltip :title="outbound.tag" :overlay-class-name="themeSwitcher.currentTheme">
  172. <span class="outbound-tag">[[ outbound.tag ]]</span>
  173. </a-tooltip>
  174. <div class="outbound-protocol-cell">
  175. <span class="outbound-pill"
  176. :class="outboundProtocolTone(outbound.protocol)">
  177. [[ outbound.protocol ]]
  178. </span>
  179. <template
  180. v-if="[Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(outbound.protocol)">
  181. <span class="outbound-pill"
  182. :class="outboundNetworkTone(outbound.streamSettings.network)">
  183. [[ outbound.streamSettings.network ]]
  184. </span>
  185. <span class="outbound-pill"
  186. :class="outboundSecurityTone(outbound.streamSettings.security)"
  187. v-if="isOutboundSecurityVisible(outbound.streamSettings.security)">
  188. [[ outbound.streamSettings.security ]]
  189. </span>
  190. </template>
  191. </div>
  192. </div>
  193. </template>
  194. <template slot="address" slot-scope="text, outbound">
  195. <div class="outbound-address-list">
  196. <a-tooltip
  197. v-for="addr in outboundAddresses(outbound)"
  198. :key="addr"
  199. :title="addr"
  200. :overlay-class-name="themeSwitcher.currentTheme">
  201. <span class="outbound-address-pill">[[ addr ]]</span>
  202. </a-tooltip>
  203. <span class="outbound-address-empty"
  204. v-if="outboundAddresses(outbound).length === 0">—</span>
  205. </div>
  206. </template>
  207. <template slot="traffic" slot-scope="text, outbound">
  208. <div class="outbound-traffic-cell">
  209. <span class="outbound-traffic-up" :title='`{{ i18n "pages.index.upload" }}`'>
  210. <a-icon type="arrow-up"></a-icon>
  211. [[ SizeFormatter.sizeFormat(findOutboundUp(outbound)) ]]
  212. </span>
  213. <span class="outbound-traffic-sep" aria-hidden="true"></span>
  214. <span class="outbound-traffic-down" :title='`{{ i18n "pages.index.download" }}`'>
  215. <a-icon type="arrow-down"></a-icon>
  216. [[ SizeFormatter.sizeFormat(findOutboundDown(outbound)) ]]
  217. </span>
  218. </div>
  219. </template>
  220. <template slot="test" slot-scope="text, outbound, index">
  221. <a-tooltip>
  222. <template slot="title">{{ i18n "pages.xray.outbound.test" }}</template>
  223. <a-button
  224. type="primary"
  225. shape="circle"
  226. icon="thunderbolt"
  227. class="outbound-test-btn"
  228. :loading="isOutboundTesting(index)"
  229. @click="testOutbound(index)"
  230. :disabled="isOutboundUntestable(outbound) || isOutboundTesting(index)">
  231. </a-button>
  232. </a-tooltip>
  233. </template>
  234. <template slot="testResult" slot-scope="text, outbound, index">
  235. <div class="outbound-result-cell" v-if="outboundTestResult(index)">
  236. <span v-if="outboundTestResult(index).success"
  237. class="outbound-result-pill outbound-result-ok">
  238. <a-icon type="check-circle" theme="filled"></a-icon>
  239. [[ outboundTestResult(index).delay ]]&nbsp;ms
  240. <span class="outbound-result-status"
  241. v-if="outboundTestResult(index).statusCode">
  242. · [[ outboundTestResult(index).statusCode ]]
  243. </span>
  244. </span>
  245. <a-tooltip v-else
  246. :title="outboundTestResult(index).error"
  247. :overlay-class-name="themeSwitcher.currentTheme">
  248. <span class="outbound-result-pill outbound-result-fail">
  249. <a-icon type="close-circle" theme="filled"></a-icon>
  250. {{ i18n "pages.xray.outbound.testFailed" }}
  251. </span>
  252. </a-tooltip>
  253. </div>
  254. <span class="outbound-result-loading" v-else-if="isOutboundTesting(index)">
  255. <a-icon type="loading"></a-icon>
  256. </span>
  257. <span class="outbound-result-idle" v-else>—</span>
  258. </template>
  259. </a-table>
  260. </a-space>
  261. {{end}}