aClientTable.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. {{define "component/aClientTable"}}
  2. <template slot="actions" slot-scope="text, client, index">
  3. <a-tooltip>
  4. <template slot="title">{{ i18n "qrCode" }}</template>
  5. <a-icon :style="{ fontSize: '22px', marginInlineStart: '14px' }" class="normal-icon" type="qrcode"
  6. v-if="record.hasLink()" @click="showQrcode(record.id,client);"></a-icon>
  7. </a-tooltip>
  8. <a-tooltip>
  9. <template slot="title">{{ i18n "pages.client.edit" }}</template>
  10. <a-icon :style="{ fontSize: '22px' }" class="normal-icon" type="edit"
  11. @click="openEditClient(record.id,client);"></a-icon>
  12. </a-tooltip>
  13. <a-tooltip>
  14. <template slot="title">{{ i18n "info" }}</template>
  15. <a-icon :style="{ fontSize: '22px' }" class="normal-icon" type="info-circle"
  16. @click="showInfo(record.id,client);"></a-icon>
  17. </a-tooltip>
  18. <a-tooltip>
  19. <template slot="title">{{ i18n "pages.inbounds.resetTraffic" }}</template>
  20. <a-popconfirm @confirm="resetClientTraffic(client,record.id,false)"
  21. title='{{ i18n "pages.inbounds.resetTrafficContent"}}' :overlay-class-name="themeSwitcher.currentTheme"
  22. ok-text='{{ i18n "reset"}}' cancel-text='{{ i18n "cancel"}}'>
  23. <a-icon slot="icon" type="question-circle-o" :style="{ color: 'var(--color-primary-100)'}"></a-icon>
  24. <a-icon :style="{ fontSize: '22px', cursor: 'pointer' }" class="normal-icon" type="retweet"
  25. v-if="client.email.length > 0"></a-icon>
  26. </a-popconfirm>
  27. </a-tooltip>
  28. <a-tooltip>
  29. <template slot="title">
  30. <span :style="{ color: '#FF4D4F' }"> {{ i18n "delete"}}</span>
  31. </template>
  32. <a-popconfirm @confirm="delClient(record.id,client,false)" title='{{ i18n "pages.inbounds.deleteClientContent"}}'
  33. :overlay-class-name="themeSwitcher.currentTheme" ok-text='{{ i18n "delete"}}' ok-type="danger"
  34. cancel-text='{{ i18n "cancel"}}'>
  35. <a-icon slot="icon" type="question-circle-o" :style="{ color: '#e04141' }"></a-icon>
  36. <a-icon :style="{ fontSize: '22px', cursor: 'pointer' }" class="delete-icon" type="delete"
  37. v-if="isRemovable(record.id)"></a-icon>
  38. </a-popconfirm>
  39. </a-tooltip>
  40. </template>
  41. <template slot="enable" slot-scope="text, client, index">
  42. <a-switch v-model="client.enable" @change="switchEnableClient(record.id, client, $event)"></a-switch>
  43. </template>
  44. <template slot="online" slot-scope="text, client, index">
  45. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  46. <template slot="content">
  47. {{ i18n "lastOnline" }}: [[ formatLastOnline(client.email) ]]
  48. </template>
  49. <template v-if="client.enable && isClientOnline(client.email)">
  50. <a-tag color="green">{{ i18n "online" }}</a-tag>
  51. </template>
  52. <template v-else>
  53. <a-tag>{{ i18n "offline" }}</a-tag>
  54. </template>
  55. </a-popover>
  56. </template>
  57. <template slot="client" slot-scope="text, client">
  58. <a-space direction="horizontal" :size="2">
  59. <a-tooltip>
  60. <template slot="title">
  61. <template v-if="isClientDepleted(record, client.email)">{{ i18n "depleted" }}</template>
  62. <template v-else-if="!client.enable">{{ i18n "disabled" }}</template>
  63. <template v-else-if="client.enable && isClientOnline(client.email)">{{ i18n "online" }}</template>
  64. </template>
  65. <a-badge :class="isClientOnline(client.email)? 'online-animation' : ''"
  66. :color="client.enable ? statsExpColor(record, client.email) : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"></a-badge>
  67. </a-tooltip>
  68. <a-space direction="vertical" :size="2">
  69. <span class="client-email">[[ client.email ]]</span>
  70. <template v-if="client.comment && client.comment.trim()">
  71. <a-tooltip v-if="client.comment.length > 50" :overlay-class-name="themeSwitcher.currentTheme">
  72. <template slot="title">
  73. [[ client.comment ]]
  74. </template>
  75. <span class="client-comment">[[ client.comment.substring(0, 47) + '...' ]]</span>
  76. </a-tooltip>
  77. <span v-else class="client-comment">[[ client.comment ]]</span>
  78. </template>
  79. </a-space>
  80. </a-space>
  81. </template>
  82. <template slot="traffic" slot-scope="text, client">
  83. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  84. <template slot="content" v-if="client.email">
  85. <table cellpadding="2" width="100%">
  86. <tr>
  87. <td>↑[[ SizeFormatter.sizeFormat(getUpStats(record, client.email)) ]]</td>
  88. <td>↓[[ SizeFormatter.sizeFormat(getDownStats(record, client.email)) ]]</td>
  89. </tr>
  90. <tr v-if="client.totalGB > 0">
  91. <td>{{ i18n "remained" }}</td>
  92. <td>[[ SizeFormatter.sizeFormat(getRemStats(record, client.email)) ]]</td>
  93. </tr>
  94. </table>
  95. </template>
  96. <div class="tr-table-box">
  97. <div class="tr-table-lt">[[ SizeFormatter.sizeFormat(getSumStats(record, client.email)) ]]</div>
  98. <div class="tr-table-bar" v-if="!client.enable">
  99. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false" :percent="statsProgress(record, client.email)" />
  100. </div>
  101. <div class="tr-table-bar" v-else-if="client.totalGB > 0">
  102. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="statsProgress(record, client.email)" />
  103. </div>
  104. <div v-else class="infinite-bar tr-table-bar">
  105. <a-progress :show-info="false" :percent="100"></a-progress>
  106. </div>
  107. <div class="tr-table-rt">
  108. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  109. <span v-else class="tr-infinity-ch">&infin;</span>
  110. </div>
  111. </div>
  112. </a-popover>
  113. </template>
  114. <template slot="allTime" slot-scope="text, client">
  115. <a-tag>[[ SizeFormatter.sizeFormat(getAllTimeClient(record, client.email)) ]]</a-tag>
  116. </template>
  117. <template slot="expiryTime" slot-scope="text, client, index">
  118. <template v-if="client.expiryTime !=0 && client.reset >0">
  119. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  120. <template slot="content">
  121. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
  122. <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
  123. </template>
  124. <div class="tr-table-box">
  125. <div class="tr-table-rt">[[ IntlUtil.formatRelativeTime(client.expiryTime) ]]</div>
  126. <div class="infinite-bar tr-table-bar">
  127. <a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  128. </div>
  129. <div class="tr-table-lt">[[ client.reset + "d" ]]</div>
  130. </div>
  131. </a-popover>
  132. </template>
  133. <template v-else>
  134. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  135. <template slot="content">
  136. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
  137. <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
  138. </template>
  139. <a-tag :style="{ minWidth: '50px', border: 'none' }"
  140. :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[
  141. IntlUtil.formatRelativeTime(client.expiryTime) ]] </a-tag>
  142. </a-popover>
  143. <a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"
  144. :style="{ border: 'none' }" class="infinite-tag">
  145. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  146. <path
  147. d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z"
  148. fill="currentColor"></path>
  149. </svg>
  150. </a-tag>
  151. </template>
  152. </template>
  153. <template slot="actionMenu" slot-scope="text, client, index">
  154. <a-dropdown :trigger="['click']">
  155. <a-icon @click="e => e.preventDefault()" type="ellipsis" :style="{ fontSize: '20px' }"></a-icon>
  156. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  157. <a-menu-item v-if="record.hasLink()" @click="showQrcode(record.id,client);">
  158. <a-icon :style="{ fontSize: '14px' }" type="qrcode"></a-icon>
  159. {{ i18n "qrCode" }}
  160. </a-menu-item>
  161. <a-menu-item @click="openEditClient(record.id,client);">
  162. <a-icon :style="{ fontSize: '14px' }" type="edit"></a-icon>
  163. {{ i18n "pages.client.edit" }}
  164. </a-menu-item>
  165. <a-menu-item @click="showInfo(record.id,client);">
  166. <a-icon :style="{ fontSize: '14px' }" type="info-circle"></a-icon>
  167. {{ i18n "info" }}
  168. </a-menu-item>
  169. <a-menu-item @click="resetClientTraffic(client,record.id)" v-if="client.email.length > 0">
  170. <a-icon :style="{ fontSize: '14px' }" type="retweet"></a-icon>
  171. {{ i18n "pages.inbounds.resetTraffic" }}
  172. </a-menu-item>
  173. <a-menu-item v-if="isRemovable(record.id)" @click="delClient(record.id,client)">
  174. <a-icon :style="{ fontSize: '14px' }" type="delete"></a-icon>
  175. <span :style="{ color: '#FF4D4F' }"> {{ i18n "delete"}}</span>
  176. </a-menu-item>
  177. <a-menu-item>
  178. <a-switch v-model="client.enable" size="small"
  179. @change="switchEnableClient(record.id, client, $event)"></a-switch>
  180. {{ i18n "enable"}}
  181. </a-menu-item>
  182. </a-menu>
  183. </a-dropdown>
  184. </template>
  185. <template slot="info" slot-scope="text, client, index">
  186. <a-popover placement="bottomRight" :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  187. <template slot="content">
  188. <table>
  189. <tr>
  190. <td colspan="3" :style="{ textAlign: 'center' }">{{ i18n "pages.inbounds.traffic" }}</td>
  191. </tr>
  192. <tr>
  193. <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[
  194. SizeFormatter.sizeFormat(getUpStats(record, client.email) + getDownStats(record, client.email)) ]] </td>
  195. <td width="120px" v-if="!client.enable">
  196. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false"
  197. :percent="statsProgress(record, client.email)" />
  198. </td>
  199. <td width="120px" v-else-if="client.totalGB > 0">
  200. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  201. <template slot="content" v-if="client.email">
  202. <table cellpadding="2" width="100%">
  203. <tr>
  204. <td>↑[[ SizeFormatter.sizeFormat(getUpStats(record, client.email)) ]]</td>
  205. <td>↓[[ SizeFormatter.sizeFormat(getDownStats(record, client.email)) ]]</td>
  206. </tr>
  207. <tr>
  208. <td>{{ i18n "remained" }}</td>
  209. <td>[[ SizeFormatter.sizeFormat(getRemStats(record, client.email)) ]]</td>
  210. </tr>
  211. </table>
  212. </template>
  213. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false"
  214. :status="isClientDepleted(record, client.email)? 'exception' : ''"
  215. :percent="statsProgress(record, client.email)" />
  216. </a-popover>
  217. </td>
  218. <td width="120px" v-else class="infinite-bar">
  219. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? '#2c1e32':'#F2EAF1'" :show-info="false"
  220. :percent="100"></a-progress>
  221. </td>
  222. <td width="80px">
  223. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  224. <span v-else class="tr-infinity-ch">&infin;</span>
  225. </td>
  226. </tr>
  227. <tr>
  228. <td colspan="3" :style="{ textAlign: 'center' }">
  229. <a-divider :style="{ margin: '0', borderCollapse: 'separate' }"></a-divider>
  230. {{ i18n "pages.inbounds.expireDate" }}
  231. </td>
  232. </tr>
  233. <tr>
  234. <template v-if="client.expiryTime !=0 && client.reset >0">
  235. <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[
  236. IntlUtil.formatRelativeTime(client.expiryTime) ]] </td>
  237. <td width="120px" class="infinite-bar">
  238. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  239. <template slot="content">
  240. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
  241. <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
  242. </template>
  243. <a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''"
  244. :percent="expireProgress(client.expiryTime, client.reset)" />
  245. </a-popover>
  246. </td>
  247. <td width="60px">[[ client.reset + "d" ]]</td>
  248. </template>
  249. <template v-else>
  250. <td colspan="3" :style="{ textAlign: 'center' }">
  251. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  252. <template slot="content">
  253. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
  254. <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
  255. </template>
  256. <a-tag :style="{ minWidth: '50px', border: 'none' }"
  257. :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[
  258. IntlUtil.formatRelativeTime(client.expiryTime) ]] </a-tag>
  259. </a-popover>
  260. <a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"
  261. class="infinite-tag">
  262. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  263. <path
  264. d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z"
  265. fill="currentColor"></path>
  266. </svg>
  267. </a-tag>
  268. </template>
  269. </td>
  270. </tr>
  271. </table>
  272. </template>
  273. <a-badge>
  274. <a-icon v-if="!client.enable" slot="count" type="pause-circle" theme="filled"
  275. :style="{ color: themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc' }"></a-icon>
  276. <a-button shape="round" size="small" :style="{ fontSize: '14px', padding: '0 10px' }">
  277. <a-icon type="solution"></a-icon>
  278. </a-button>
  279. </a-badge>
  280. </a-popover>
  281. </template>
  282. <template slot="createdAt" slot-scope="text, client, index">
  283. <template v-if="client.created_at">
  284. [[ IntlUtil.formatDate(client.created_at) ]]
  285. </template>
  286. <template v-else>
  287. -
  288. </template>
  289. </template>
  290. <template slot="updatedAt" slot-scope="text, client, index">
  291. <template v-if="client.updated_at">
  292. [[ IntlUtil.formatDate(client.updated_at) ]]
  293. </template>
  294. <template v-else>
  295. -
  296. </template>
  297. </template>
  298. {{end}}