client_bulk_modal.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. {{define "clientsBulkModal"}}
  2. <a-modal id="client-bulk-modal" v-model="clientsBulkModal.visible" :title="clientsBulkModal.title" @ok="clientsBulkModal.ok"
  3. :confirm-loading="clientsBulkModal.confirmLoading" :closable="true" :mask-closable="false"
  4. :class="siderDrawer.isDarkTheme ? darkClass : ''"
  5. :ok-text="clientsBulkModal.okText" cancel-text='{{ i18n "close" }}'>
  6. <a-form layout="inline">
  7. <a-form-item label='{{ i18n "pages.client.method" }}'>
  8. <a-select v-model="clientsBulkModal.emailMethod" buttonStyle="solid" style="width: 350px" :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''">
  9. <a-select-option :value="0">Random</a-select-option>
  10. <a-select-option :value="1">Random+Prefix</a-select-option>
  11. <a-select-option :value="2">Random+Prefix+Num</a-select-option>
  12. <a-select-option :value="3">Random+Prefix+Num+Postfix</a-select-option>
  13. <a-select-option :value="4">Prefix+Num+Postfix [ BE CAREFUL! ]</a-select-option>
  14. </a-select>
  15. </a-form-item><br />
  16. <a-form-item v-if="clientsBulkModal.emailMethod>1">
  17. <span slot="label">{{ i18n "pages.client.first" }}</span>
  18. <a-input-number v-model="clientsBulkModal.firstNum" :min="1"></a-input-number>
  19. </a-form-item>
  20. <a-form-item v-if="clientsBulkModal.emailMethod>1">
  21. <span slot="label">{{ i18n "pages.client.last" }}</span>
  22. <a-input-number v-model="clientsBulkModal.lastNum" :min="clientsBulkModal.firstNum"></a-input-number>
  23. </a-form-item>
  24. <a-form-item v-if="clientsBulkModal.emailMethod>0">
  25. <span slot="label">{{ i18n "pages.client.prefix" }}</span>
  26. <a-input v-model="clientsBulkModal.emailPrefix" style="width: 120px"></a-input>
  27. </a-form-item>
  28. <a-form-item v-if="clientsBulkModal.emailMethod>2">
  29. <span slot="label">{{ i18n "pages.client.postfix" }}</span>
  30. <a-input v-model="clientsBulkModal.emailPostfix" style="width: 120px"></a-input>
  31. </a-form-item>
  32. <a-form-item v-if="clientsBulkModal.emailMethod < 2">
  33. <span slot="label">{{ i18n "pages.client.clientCount" }}</span>
  34. <a-input-number v-model="clientsBulkModal.quantity" :min="1" :max="100"></a-input-number>
  35. </a-form-item>
  36. <a-form-item v-if="client.email">
  37. <span slot="label">
  38. Subscription
  39. <a-tooltip>
  40. <template slot="title">
  41. <span>{{ i18n "pages.inbounds.subscriptionDesc" }}</span>
  42. </template>
  43. <a-icon type="question-circle" theme="filled"></a-icon>
  44. </a-tooltip>
  45. </span>
  46. <a-input v-model.trim="clientsBulkModal.subId"></a-input>
  47. </a-form-item>
  48. <a-form-item>
  49. <span slot="label">
  50. Telegram ID
  51. <a-tooltip>
  52. <template slot="title">
  53. <span>{{ i18n "pages.inbounds.telegramDesc" }}</span>
  54. </template>
  55. <a-icon type="question-circle" theme="filled"></a-icon>
  56. </a-tooltip>
  57. </span>
  58. <a-input v-model.trim="clientsBulkModal.tgId"></a-input>
  59. </a-form-item>
  60. <a-form-item>
  61. <span slot="label">
  62. <span>{{ i18n "pages.inbounds.IPLimit" }}</span>
  63. <a-tooltip>
  64. <template slot="title">
  65. <span>{{ i18n "pages.inbounds.IPLimitDesc" }}</span>
  66. </template>
  67. <a-icon type="question-circle" theme="filled"></a-icon>
  68. </a-tooltip>
  69. </span>
  70. <a-input-number v-model="clientsBulkModal.limitIp" min="0"></a-input-number>
  71. </a-form-item>
  72. <br>
  73. <a-form-item v-if="clientsBulkModal.inbound.xtls" label="Flow">
  74. <a-select v-model="clientsBulkModal.flow" style="width: 200px" :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''">
  75. <a-select-option value="">{{ i18n "none" }}</a-select-option>
  76. <a-select-option v-for="key in XTLS_FLOW_CONTROL" :value="key">[[ key ]]</a-select-option>
  77. </a-select>
  78. </a-form-item>
  79. <a-form-item v-if="clientsBulkModal.inbound.canEnableTlsFlow()" label="Flow" layout="inline">
  80. <a-select v-model="clientsBulkModal.flow" style="width: 200px" :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''">
  81. <a-select-option value="" selected>{{ i18n "none" }}</a-select-option>
  82. <a-select-option v-for="key in TLS_FLOW_CONTROL" :value="key">[[ key ]]</a-select-option>
  83. </a-select>
  84. </a-form-item>
  85. <a-form-item>
  86. <span slot="label">
  87. <span >{{ i18n "pages.inbounds.totalFlow" }}</span> (GB)
  88. <a-tooltip>
  89. <template slot="title">
  90. 0 <span>{{ i18n "pages.inbounds.meansNoLimit" }}</span>
  91. </template>
  92. <a-icon type="question-circle" theme="filled"></a-icon>
  93. </a-tooltip>
  94. </span>
  95. <a-input-number v-model="clientsBulkModal.totalGB" :min="0"></a-input-number>
  96. </a-form-item>
  97. <br>
  98. <a-form-item label='{{ i18n "pages.client.delayedStart" }}'>
  99. <a-switch v-model="clientsBulkModal.delayedStart" @click="clientsBulkModal.expiryTime=0"></a-switch>
  100. </a-form-item>
  101. <br>
  102. <a-form-item label='{{ i18n "pages.client.expireDays" }}' v-if="clientsBulkModal.delayedStart">
  103. <a-input-number v-model="delayedExpireDays" :min="0"></a-input-number>
  104. </a-form-item>
  105. <a-form-item v-else>
  106. <span slot="label">
  107. <span >{{ i18n "pages.inbounds.expireDate" }}</span>
  108. <a-tooltip>
  109. <template slot="title">
  110. <span>{{ i18n "pages.inbounds.leaveBlankToNeverExpire" }}</span>
  111. </template>
  112. <a-icon type="question-circle" theme="filled"></a-icon>
  113. </a-tooltip>
  114. </span>
  115. <a-date-picker :show-time="{ format: 'HH:mm:ss' }" format="YYYY-MM-DD HH:mm:ss"
  116. :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''"
  117. v-model="clientsBulkModal.expiryTime" style="width: 300px;"></a-date-picker>
  118. </a-form-item>
  119. </a-form>
  120. </a-modal>
  121. <script>
  122. const clientsBulkModal = {
  123. visible: false,
  124. confirmLoading: false,
  125. title: '',
  126. okText: '',
  127. confirm: null,
  128. dbInbound: new DBInbound(),
  129. inbound: new Inbound(),
  130. quantity: 1,
  131. totalGB: 0,
  132. limitIp: 0,
  133. expiryTime: '',
  134. emailMethod: 0,
  135. firstNum: 1,
  136. lastNum: 1,
  137. emailPrefix: "",
  138. emailPostfix: "",
  139. subId: "",
  140. tgId: "",
  141. flow: "",
  142. delayedStart: false,
  143. ok() {
  144. clients = [];
  145. method=clientsBulkModal.emailMethod;
  146. if(method>1){
  147. start=clientsBulkModal.firstNum;
  148. end=clientsBulkModal.lastNum + 1;
  149. } else {
  150. start=0;
  151. end=clientsBulkModal.quantity;
  152. }
  153. prefix = (method>0 && clientsBulkModal.emailPrefix.length>0) ? clientsBulkModal.emailPrefix : "";
  154. useNum=(method>1);
  155. postfix = (method>2 && clientsBulkModal.emailPostfix.length>0) ? clientsBulkModal.emailPostfix : "";
  156. for (let i = start; i < end; i++) {
  157. newClient = clientsBulkModal.newClient(clientsBulkModal.dbInbound.protocol);
  158. if(method==4) newClient.email = "";
  159. newClient.email += useNum ? prefix + i.toString() + postfix : prefix + postfix;
  160. newClient.subId = clientsBulkModal.subId;
  161. newClient.tgId = clientsBulkModal.tgId;
  162. newClient.limitIp = clientsBulkModal.limitIp;
  163. newClient._totalGB = clientsBulkModal.totalGB;
  164. newClient._expiryTime = clientsBulkModal.expiryTime;
  165. if(clientsBulkModal.inbound.canEnableTlsFlow()){
  166. newClient.flow = clientsBulkModal.flow;
  167. }
  168. if(clientsBulkModal.inbound.xtls){
  169. newClient.flow = clientsBulkModal.flow;
  170. }
  171. clients.push(newClient);
  172. }
  173. ObjectUtil.execute(clientsBulkModal.confirm, clients, clientsBulkModal.dbInbound.id);
  174. },
  175. show({ title='', okText='{{ i18n "sure" }}', dbInbound=null, confirm=(inbound, dbInbound)=>{} }) {
  176. this.visible = true;
  177. this.title = title;
  178. this.okText = okText;
  179. this.confirm = confirm;
  180. this.quantity = 1;
  181. this.totalGB = 0;
  182. this.expiryTime = 0;
  183. this.emailMethod= 0;
  184. this.limitIp= 0;
  185. this.firstNum= 1;
  186. this.lastNum= 1;
  187. this.emailPrefix= "";
  188. this.emailPostfix= "";
  189. this.subId= "";
  190. this.tgId= "";
  191. this.flow= "";
  192. this.dbInbound = new DBInbound(dbInbound);
  193. this.inbound = dbInbound.toInbound();
  194. this.delayedStart = false;
  195. },
  196. getClients(protocol, clientSettings) {
  197. switch(protocol){
  198. case Protocols.VMESS: return clientSettings.vmesses;
  199. case Protocols.VLESS: return clientSettings.vlesses;
  200. case Protocols.TROJAN: return clientSettings.trojans;
  201. default: return null;
  202. }
  203. },
  204. newClient(protocol) {
  205. switch (protocol) {
  206. case Protocols.VMESS: return new Inbound.VmessSettings.Vmess();
  207. case Protocols.VLESS: return new Inbound.VLESSSettings.VLESS();
  208. case Protocols.TROJAN: return new Inbound.TrojanSettings.Trojan();
  209. default: return null;
  210. }
  211. },
  212. close() {
  213. clientsBulkModal.visible = false;
  214. clientsBulkModal.loading(false);
  215. },
  216. loading(loading) {
  217. clientsBulkModal.confirmLoading = loading;
  218. },
  219. };
  220. const clientsBulkModalApp = new Vue({
  221. delimiters: ['[[', ']]'],
  222. el: '#client-bulk-modal',
  223. data: {
  224. clientsBulkModal,
  225. get inbound() {
  226. return this.clientsBulkModal.inbound;
  227. },
  228. get delayedExpireDays() {
  229. return this.clientsBulkModal.expiryTime < 0 ? this.clientsBulkModal.expiryTime / -86400000 : 0;
  230. },
  231. set delayedExpireDays(days){
  232. this.clientsBulkModal.expiryTime = -86400000 * days;
  233. },
  234. },
  235. });
  236. </script>
  237. {{end}}