client_bulk_modal.html 10 KB

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