aClientTable.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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" style="flex-wrap:nowrap;min-width:0">
  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" style="min-width:0;overflow:hidden">
  69. <a-tooltip :title="client.email" :overlay-class-name="themeSwitcher.currentTheme">
  70. <span class="client-email">[[ client.email ]]</span>
  71. </a-tooltip>
  72. <template v-if="client.comment && client.comment.trim()">
  73. <a-tooltip v-if="client.comment.length > 50" :overlay-class-name="themeSwitcher.currentTheme">
  74. <template slot="title">
  75. [[ client.comment ]]
  76. </template>
  77. <span class="client-comment">[[ client.comment.substring(0, 47) + '...' ]]</span>
  78. </a-tooltip>
  79. <span v-else class="client-comment">[[ client.comment ]]</span>
  80. </template>
  81. </a-space>
  82. </a-space>
  83. </template>
  84. <template slot="traffic" slot-scope="text, client">
  85. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  86. <template slot="content" v-if="client.email">
  87. <table cellpadding="2" width="100%">
  88. <tr>
  89. <td>↑[[ SizeFormatter.sizeFormat(getUpStats(record, client.email)) ]]</td>
  90. <td>↓[[ SizeFormatter.sizeFormat(getDownStats(record, client.email)) ]]</td>
  91. </tr>
  92. <tr v-if="client.totalGB > 0">
  93. <td>{{ i18n "remained" }}</td>
  94. <td>[[ SizeFormatter.sizeFormat(getRemStats(record, client.email)) ]]</td>
  95. </tr>
  96. </table>
  97. </template>
  98. <div class="tr-table-box">
  99. <div class="tr-table-rt">[[ SizeFormatter.sizeFormat(getSumStats(record, client.email)) ]]</div>
  100. <div class="tr-table-bar" v-if="!client.enable">
  101. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false" :percent="statsProgress(record, client.email)" />
  102. </div>
  103. <div class="tr-table-bar" v-else-if="client.totalGB > 0">
  104. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="statsProgress(record, client.email)" />
  105. </div>
  106. <div v-else class="infinite-bar tr-table-bar">
  107. <a-progress :show-info="false" :percent="100"></a-progress>
  108. </div>
  109. <div class="tr-table-rt">
  110. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  111. <span v-else class="tr-infinity-ch">&infin;</span>
  112. </div>
  113. </div>
  114. </a-popover>
  115. </template>
  116. <template slot="allTime" slot-scope="text, client">
  117. <a-tag>[[ SizeFormatter.sizeFormat(getAllTimeClient(record, client.email)) ]]</a-tag>
  118. </template>
  119. <template slot="expiryTime" slot-scope="text, client, index">
  120. <template v-if="client.expiryTime !=0 && client.reset >0">
  121. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  122. <template slot="content">
  123. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
  124. <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
  125. </template>
  126. <div class="tr-table-box">
  127. <div class="tr-table-rt">[[ IntlUtil.formatRelativeTime(client.expiryTime) ]]</div>
  128. <div class="infinite-bar tr-table-bar">
  129. <a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" />
  130. </div>
  131. <div class="tr-table-lt">[[ client.reset + "d" ]]</div>
  132. </div>
  133. </a-popover>
  134. </template>
  135. <template v-else>
  136. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  137. <template slot="content">
  138. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
  139. <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
  140. </template>
  141. <a-tag :style="{ minWidth: '50px', border: 'none' }"
  142. :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[
  143. IntlUtil.formatRelativeTime(client.expiryTime) ]] </a-tag>
  144. </a-popover>
  145. <a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"
  146. :style="{ border: 'none' }" class="infinite-tag">
  147. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  148. <path
  149. 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"
  150. fill="currentColor"></path>
  151. </svg>
  152. </a-tag>
  153. </template>
  154. </template>
  155. <template slot="actionMenu" slot-scope="text, client, index">
  156. <a-dropdown :trigger="['click']">
  157. <a-icon @click="e => e.preventDefault()" type="ellipsis" :style="{ fontSize: '20px' }"></a-icon>
  158. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  159. <a-menu-item v-if="record.hasLink()" @click="showQrcode(record.id,client);">
  160. <a-icon :style="{ fontSize: '14px' }" type="qrcode"></a-icon>
  161. {{ i18n "qrCode" }}
  162. </a-menu-item>
  163. <a-menu-item @click="openEditClient(record.id,client);">
  164. <a-icon :style="{ fontSize: '14px' }" type="edit"></a-icon>
  165. {{ i18n "pages.client.edit" }}
  166. </a-menu-item>
  167. <a-menu-item @click="showInfo(record.id,client);">
  168. <a-icon :style="{ fontSize: '14px' }" type="info-circle"></a-icon>
  169. {{ i18n "info" }}
  170. </a-menu-item>
  171. <a-menu-item @click="resetClientTraffic(client,record.id)" v-if="client.email.length > 0">
  172. <a-icon :style="{ fontSize: '14px' }" type="retweet"></a-icon>
  173. {{ i18n "pages.inbounds.resetTraffic" }}
  174. </a-menu-item>
  175. <a-menu-item v-if="isRemovable(record.id)" @click="delClient(record.id,client)">
  176. <a-icon :style="{ fontSize: '14px' }" type="delete"></a-icon>
  177. <span :style="{ color: '#FF4D4F' }"> {{ i18n "delete"}}</span>
  178. </a-menu-item>
  179. <a-menu-item>
  180. <a-switch v-model="client.enable" size="small"
  181. @change="switchEnableClient(record.id, client, $event)"></a-switch>
  182. {{ i18n "enable"}}
  183. </a-menu-item>
  184. </a-menu>
  185. </a-dropdown>
  186. </template>
  187. <template slot="info" slot-scope="text, client, index">
  188. <a-popover :placement="isMobile ? 'bottomLeft' : 'bottomRight'" :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  189. <template slot="content">
  190. <table>
  191. <tr>
  192. <td colspan="3" :style="{ textAlign: 'center' }">{{ i18n "pages.inbounds.traffic" }}</td>
  193. </tr>
  194. <tr>
  195. <td width="65px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[
  196. SizeFormatter.sizeFormat(getUpStats(record, client.email) + getDownStats(record, client.email)) ]] </td>
  197. <td width="90px" v-if="!client.enable">
  198. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? 'rgb(72 84 105)' : '#bcbcbc'" :show-info="false"
  199. :percent="statsProgress(record, client.email)" />
  200. </td>
  201. <td width="90px" v-else-if="client.totalGB > 0">
  202. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  203. <template slot="content" v-if="client.email">
  204. <table cellpadding="2" width="100%">
  205. <tr>
  206. <td>↑[[ SizeFormatter.sizeFormat(getUpStats(record, client.email)) ]]</td>
  207. <td>↓[[ SizeFormatter.sizeFormat(getDownStats(record, client.email)) ]]</td>
  208. </tr>
  209. <tr>
  210. <td>{{ i18n "remained" }}</td>
  211. <td>[[ SizeFormatter.sizeFormat(getRemStats(record, client.email)) ]]</td>
  212. </tr>
  213. </table>
  214. </template>
  215. <a-progress :stroke-color="clientStatsColor(record, client.email)" :show-info="false"
  216. :status="isClientDepleted(record, client.email)? 'exception' : ''"
  217. :percent="statsProgress(record, client.email)" />
  218. </a-popover>
  219. </td>
  220. <td width="90px" v-else class="infinite-bar">
  221. <a-progress :stroke-color="themeSwitcher.isDarkTheme ? '#2c1e32':'#F2EAF1'" :show-info="false"
  222. :percent="100"></a-progress>
  223. </td>
  224. <td width="60px">
  225. <template v-if="client.totalGB > 0">[[ client._totalGB + "GB" ]]</template>
  226. <span v-else class="tr-infinity-ch">&infin;</span>
  227. </td>
  228. </tr>
  229. <tr>
  230. <td colspan="3" :style="{ textAlign: 'center' }">
  231. <a-divider :style="{ margin: '0', borderCollapse: 'separate' }"></a-divider>
  232. {{ i18n "pages.inbounds.expireDate" }}
  233. </td>
  234. </tr>
  235. <tr>
  236. <template v-if="client.expiryTime !=0 && client.reset >0">
  237. <td width="65px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[
  238. IntlUtil.formatRelativeTime(client.expiryTime) ]] </td>
  239. <td width="90px" class="infinite-bar">
  240. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  241. <template slot="content">
  242. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
  243. <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
  244. </template>
  245. <a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''"
  246. :percent="expireProgress(client.expiryTime, client.reset)" />
  247. </a-popover>
  248. </td>
  249. <td width="50px">[[ client.reset + "d" ]]</td>
  250. </template>
  251. <template v-else>
  252. <td colspan="3" :style="{ textAlign: 'center' }">
  253. <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme">
  254. <template slot="content">
  255. <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span>
  256. <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span>
  257. </template>
  258. <a-tag :style="{ minWidth: '50px', border: 'none' }"
  259. :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[
  260. IntlUtil.formatRelativeTime(client.expiryTime) ]] </a-tag>
  261. </a-popover>
  262. <a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'"
  263. class="infinite-tag">
  264. <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor">
  265. <path
  266. 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"
  267. fill="currentColor"></path>
  268. </svg>
  269. </a-tag>
  270. </template>
  271. </td>
  272. </tr>
  273. </table>
  274. </template>
  275. <a-badge>
  276. <a-icon v-if="!client.enable" slot="count" type="pause-circle" theme="filled"
  277. :style="{ color: themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc' }"></a-icon>
  278. <a-button shape="round" size="small" :style="{ fontSize: '14px', padding: '0 10px' }">
  279. <a-icon type="solution"></a-icon>
  280. </a-button>
  281. </a-badge>
  282. </a-popover>
  283. </template>
  284. <template slot="createdAt" slot-scope="text, client, index">
  285. <template v-if="client.created_at">
  286. [[ IntlUtil.formatDate(client.created_at) ]]
  287. </template>
  288. <template v-else>
  289. -
  290. </template>
  291. </template>
  292. <template slot="updatedAt" slot-scope="text, client, index">
  293. <template v-if="client.updated_at">
  294. [[ IntlUtil.formatDate(client.updated_at) ]]
  295. </template>
  296. <template v-else>
  297. -
  298. </template>
  299. </template>
  300. {{end}}