client_bulk_modal.html 10.0 KB

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