inbound_info_modal.html 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. {{define "inboundInfoModal"}}
  2. <a-modal id="inbound-info-modal"
  3. v-model="infoModal.visible" title='{{ i18n "pages.inbounds.details"}}'
  4. :closable="true"
  5. :mask-closable="true"
  6. :footer="null"
  7. width="600px"
  8. >
  9. <table style="margin-bottom: 10px; width: 100%;">
  10. <tr><td>
  11. <table>
  12. <tr><td>{{ i18n "protocol" }}</td><td><a-tag color="green">[[ dbInbound.protocol ]]</a-tag></td></tr>
  13. <tr><td>{{ i18n "pages.inbounds.address" }}</td><td><a-tag color="blue">[[ dbInbound.address ]]</a-tag></td></tr>
  14. <tr><td>{{ i18n "pages.inbounds.port" }}</td><td><a-tag color="green">[[ dbInbound.port ]]</a-tag></td></tr>
  15. </table>
  16. </td>
  17. <td v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
  18. <table>
  19. <tr>
  20. <td>{{ i18n "transmission" }}</td><td><a-tag color="green">[[ inbound.network ]]</a-tag></td>
  21. </tr>
  22. <template v-if="inbound.isTcp || inbound.isWs || inbound.isH2">
  23. <tr v-if="inbound.host"><td>{{ i18n "host" }}</td><td><a-tag color="green">[[ inbound.host ]]</a-tag></td></tr>
  24. <tr v-else><td>{{ i18n "host" }}</td><td><a-tag color="orange">{{ i18n "none" }}</a-tag></td></tr>
  25. <tr v-if="inbound.path"><td>{{ i18n "path" }}</td><td><a-tag color="green">[[ inbound.path ]]</a-tag></td></tr>
  26. <tr v-else><td>{{ i18n "path" }}</td><td><a-tag color="orange">{{ i18n "none" }}</a-tag></td></tr>
  27. </template>
  28. <template v-if="inbound.isQuic">
  29. <tr><td>quic {{ i18n "encryption" }}</td><td><a-tag color="green">[[ inbound.quicSecurity ]]</a-tag></td></tr>
  30. <tr><td>quic {{ i18n "password" }}</td><td><a-tag color="green">[[ inbound.quicKey ]]</a-tag></td></tr>
  31. <tr><td>quic {{ i18n "camouflage" }}</td><td><a-tag color="green">[[ inbound.quicType ]]</a-tag></td></tr>
  32. </template>
  33. <template v-if="inbound.isKcp">
  34. <tr><td>kcp {{ i18n "encryption" }}</td><td><a-tag color="green">[[ inbound.kcpType ]]</a-tag></td></tr>
  35. <tr><td>kcp {{ i18n "password" }}</td><td><a-tag color="green">[[ inbound.kcpSeed ]]</a-tag></td></tr>
  36. </template>
  37. <template v-if="inbound.isGrpc">
  38. <tr><td>grpc serviceName</td><td><a-tag color="green">[[ inbound.serviceName ]]</a-tag></td></tr>
  39. </template>
  40. </table>
  41. </td></tr>
  42. <tr colspan="2">
  43. <td v-if="inbound.tls">
  44. tls: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  45. tls {{ i18n "domainName" }}: <a-tag :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
  46. </td>
  47. <td v-else-if="inbound.xtls">
  48. xtls: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  49. xtls {{ i18n "domainName" }}: <a-tag :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
  50. </td>
  51. <td v-else>tls: <a-tag color="red">{{ i18n "disabled" }}</a-tag>
  52. </td>
  53. </tr>
  54. </table>
  55. <a-divider>{{ i18n "pages.inbounds.client" }}</a-divider>
  56. <table style="margin-bottom: 10px; width: 100%;">
  57. <tr><th>[[ Object.keys(infoModal.clientSettings)[0] ]]</th><th>[[ Object.keys(infoModal.clientSettings)[1] ]]</th><th>[[ Object.keys(infoModal.clientSettings)[2] ]]</th></tr>
  58. <tr>
  59. <td><a-tag color="green">[[ Object.values(infoModal.clientSettings)[0] ]]</a-tag></td>
  60. <td><a-tag color="green">[[ Object.values(infoModal.clientSettings)[1] ]]</a-tag></td>
  61. <td><a-tag color="green">[[ Object.values(infoModal.clientSettings)[2] ]]</a-tag></td>
  62. </tr>
  63. </table>
  64. <table style="margin-bottom: 10px; width: 100%;">
  65. <tr><th>{{ i18n "usage" }}</th><th>{{ i18n "pages.inbounds.totalFlow" }}</th><th>{{ i18n "pages.inbounds.expireDate" }}</th><th>{{ i18n "enable" }}</th></tr>
  66. <tr>
  67. <td>
  68. <a-tag :color="statsColor(infoModal.clientStats)">
  69. [[ sizeFormat(infoModal.clientStats['up']) ]] /
  70. [[ sizeFormat(infoModal.clientStats['down']) ]]
  71. ([[ sizeFormat(infoModal.clientStats['up'] + infoModal.clientStats['down']) ]])
  72. </a-tag>
  73. </td>
  74. <td>
  75. <a-tag v-if="infoModal.clientSettings.totalGB > 0" :color="statsColor(infoModal.clientStats)">[[ sizeFormat(infoModal.clientSettings.totalGB) ]]</a-tag>
  76. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  77. </td>
  78. <td>
  79. <template v-if="infoModal.clientSettings.expiryTime > 0">
  80. <a-tag :color="infoModal.isExpired ? 'red' : 'blue'">
  81. [[ DateUtil.formatMillis(infoModal.clientSettings.expiryTime) ]]
  82. </a-tag>
  83. </template>
  84. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  85. </td>
  86. <td>
  87. <a-tag v-if="infoModal.clientStats.enable" color="blue">{{ i18n "enabled" }}</a-tag>
  88. <a-tag v-else color="red">{{ i18n "disabled" }}</a-tag>
  89. </td>
  90. </tr>
  91. </table>
  92. <div v-if="dbInbound.hasLink()">
  93. <a-divider>URL</a-divider>
  94. <p>[[ infoModal.link ]]</p>
  95. <button class="ant-btn ant-btn-primary" id="copy-url-link"><a-icon type="snippets"></a-icon>{{ i18n "copy" }}</button>
  96. </div>
  97. </a-modal>
  98. <script>
  99. const infoModal = {
  100. visible: false,
  101. inbound: new Inbound(),
  102. dbInbound: new DBInbound(),
  103. clientSettings: new Inbound.Settings(),
  104. clientStats: [],
  105. upStats: 0,
  106. downStats: 0,
  107. clipboard: null,
  108. link: null,
  109. index: 0,
  110. isExpired: false,
  111. show(dbInbound, index=0) {
  112. this.index = index;
  113. this.inbound = dbInbound.toInbound();
  114. this.dbInbound = new DBInbound(dbInbound);
  115. this.link = dbInbound.genLink(index);
  116. this.clientSettings = Object.values(JSON.parse(this.inbound.settings).clients)[index];
  117. this.clientStats = dbInbound.clientStats;
  118. this.isExpired = this.inbound.isExpiry(index);
  119. if(dbInbound.clientStats.length > 0)
  120. {
  121. for (const key in dbInbound.clientStats) {
  122. if (Object.hasOwnProperty.call(dbInbound.clientStats, key)) {
  123. if(dbInbound.clientStats[key]['email'] == this.clientSettings.email)
  124. this.clientStats = dbInbound.clientStats[key];
  125. }
  126. }
  127. }
  128. this.visible = true;
  129. infoModalApp.$nextTick(() => {
  130. if (this.clipboard === null) {
  131. this.clipboard = new ClipboardJS('#copy-url-link', {
  132. text: () => this.link,
  133. });
  134. this.clipboard.on('success', () => app.$message.success('{{ i18n "copySuccess" }}'));
  135. }
  136. });
  137. },
  138. close() {
  139. infoModal.visible = false;
  140. },
  141. };
  142. const infoModalApp = new Vue({
  143. delimiters: ['[[', ']]'],
  144. el: '#inbound-info-modal',
  145. data: {
  146. infoModal,
  147. get dbInbound() {
  148. return this.infoModal.dbInbound;
  149. },
  150. get inbound() {
  151. return this.infoModal.inbound;
  152. }
  153. },
  154. methods: {
  155. setQrCode(elmentId,index) {
  156. content = infoModal.inbound.genLink(infoModal.dbInbound.address,infoModal.dbInbound.remark,index)
  157. new QRious({
  158. element: document.querySelector('#'+elmentId),
  159. size: 260,
  160. value: content,
  161. });
  162. },
  163. copyTextToClipboard(elmentId,content) {
  164. this.infoModal.clipboard = new ClipboardJS('#' + elmentId, {
  165. text: () => content,
  166. });
  167. this.infoModal.clipboard.on('success', () => {
  168. app.$message.success('{{ i18n "copySuccess" }}')
  169. this.infoModal.clipboard.destroy();
  170. });
  171. },
  172. statsColor(stats) {
  173. if(stats['total'] === 0) return 'blue'
  174. else if(stats['total'] > 0 && (stats['down']+stats['up']) < stats['total']) return 'cyan'
  175. else return 'red'
  176. }
  177. },
  178. });
  179. </script>
  180. {{end}}