client_bulk_modal.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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="themeSwitcher.currentTheme"
  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="themeSwitcher.currentTheme">
  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="app.subSettings.enable">
  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 v-if="app.tgBotEnable">
  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. <br>
  61. <a-form-item>
  62. <span slot="label">
  63. <span>{{ i18n "pages.inbounds.IPLimit" }}</span>
  64. <a-tooltip>
  65. <template slot="title">
  66. <span>{{ i18n "pages.inbounds.IPLimitDesc" }}</span>
  67. </template>
  68. <a-icon type="question-circle" theme="filled"></a-icon>
  69. </a-tooltip>
  70. </span>
  71. <a-input-number v-model="clientsBulkModal.limitIp" min="0"></a-input-number>
  72. </a-form-item>
  73. <br>
  74. <a-form-item v-if="clientsBulkModal.inbound.xtls" label="Flow">
  75. <a-select v-model="clientsBulkModal.flow" style="width: 200px" :dropdown-class-name="themeSwitcher.currentTheme">
  76. <a-select-option value="">{{ i18n "none" }}</a-select-option>
  77. <a-select-option v-for="key in XTLS_FLOW_CONTROL" :value="key">[[ key ]]</a-select-option>
  78. </a-select>
  79. </a-form-item>
  80. <a-form-item v-if="clientsBulkModal.inbound.canEnableTlsFlow()" label="Flow" layout="inline">
  81. <a-select v-model="clientsBulkModal.flow" style="width: 200px" :dropdown-class-name="themeSwitcher.currentTheme">
  82. <a-select-option value="" selected>{{ i18n "none" }}</a-select-option>
  83. <a-select-option v-for="key in TLS_FLOW_CONTROL" :value="key">[[ key ]]</a-select-option>
  84. </a-select>
  85. </a-form-item>
  86. <a-form-item>
  87. <span slot="label">
  88. <span>{{ i18n "pages.inbounds.totalFlow" }}</span> (GB)
  89. <a-tooltip>
  90. <template slot="title">
  91. 0 <span>{{ i18n "pages.inbounds.meansNoLimit" }}</span>
  92. </template>
  93. <a-icon type="question-circle" theme="filled"></a-icon>
  94. </a-tooltip>
  95. </span>
  96. <a-input-number v-model="clientsBulkModal.totalGB" :min="0"></a-input-number>
  97. </a-form-item>
  98. <br>
  99. <a-form-item label='{{ i18n "pages.client.delayedStart" }}'>
  100. <a-switch v-model="clientsBulkModal.delayedStart" @click="clientsBulkModal.expiryTime=0"></a-switch>
  101. </a-form-item>
  102. <br>
  103. <a-form-item label='{{ i18n "pages.client.expireDays" }}' v-if="clientsBulkModal.delayedStart">
  104. <a-input-number v-model="delayedExpireDays" :min="0"></a-input-number>
  105. </a-form-item>
  106. <a-form-item v-else>
  107. <span slot="label">
  108. <span>{{ i18n "pages.inbounds.expireDate" }}</span>
  109. <a-tooltip>
  110. <template slot="title">
  111. <span>{{ i18n "pages.inbounds.leaveBlankToNeverExpire" }}</span>
  112. </template>
  113. <a-icon type="question-circle" theme="filled"></a-icon>
  114. </a-tooltip>
  115. </span>
  116. <a-date-picker :show-time="{ format: 'HH:mm:ss' }" format="YYYY-MM-DD HH:mm:ss"
  117. :dropdown-class-name="themeSwitcher.darkCardClass"
  118. v-model="clientsBulkModal.expiryTime" style="width: 300px;"></a-date-picker>
  119. </a-form-item>
  120. <a-form-item v-if="clientsBulkModal.expiryTime != 0">
  121. <span slot="label">
  122. <span>{{ i18n "pages.client.renew" }}</span>
  123. <a-tooltip>
  124. <template slot="title">
  125. <span>{{ i18n "pages.client.renewDesc" }}</span>
  126. </template>
  127. <a-icon type="question-circle" theme="filled"></a-icon>
  128. </a-tooltip>
  129. </span>
  130. <a-input-number v-model.number="clientsBulkModal.reset" :min="0"></a-input-number>
  131. </a-form-item>
  132. </a-form>
  133. </a-modal>
  134. <script>
  135. const clientsBulkModal = {
  136. visible: false,
  137. confirmLoading: false,
  138. title: '',
  139. okText: '',
  140. confirm: null,
  141. dbInbound: new DBInbound(),
  142. inbound: new Inbound(),
  143. quantity: 1,
  144. totalGB: 0,
  145. limitIp: 0,
  146. expiryTime: '',
  147. emailMethod: 0,
  148. firstNum: 1,
  149. lastNum: 1,
  150. emailPrefix: "",
  151. emailPostfix: "",
  152. subId: "",
  153. tgId: "",
  154. flow: "",
  155. delayedStart: false,
  156. reset: 0,
  157. ok() {
  158. clients = [];
  159. method = clientsBulkModal.emailMethod;
  160. if (method > 1) {
  161. start = clientsBulkModal.firstNum;
  162. end = clientsBulkModal.lastNum + 1;
  163. } else {
  164. start = 0;
  165. end = clientsBulkModal.quantity;
  166. }
  167. prefix = (method > 0 && clientsBulkModal.emailPrefix.length > 0) ? clientsBulkModal.emailPrefix : "";
  168. useNum = (method > 1);
  169. postfix = (method > 2 && clientsBulkModal.emailPostfix.length > 0) ? clientsBulkModal.emailPostfix : "";
  170. for (let i = start; i < end; i++) {
  171. newClient = clientsBulkModal.newClient(clientsBulkModal.dbInbound.protocol);
  172. if (method == 4) newClient.email = "";
  173. newClient.email += useNum ? prefix + i.toString() + postfix : prefix + postfix;
  174. if (clientsBulkModal.subId.length > 0) newClient.subId = clientsBulkModal.subId;
  175. if (clientsBulkModal.tgId.length > 0) newClient.tgId = clientsBulkModal.tgId;
  176. newClient.limitIp = clientsBulkModal.limitIp;
  177. newClient._totalGB = clientsBulkModal.totalGB;
  178. newClient._expiryTime = clientsBulkModal.expiryTime;
  179. if (clientsBulkModal.inbound.canEnableTlsFlow()) {
  180. newClient.flow = clientsBulkModal.flow;
  181. }
  182. if (clientsBulkModal.inbound.xtls) {
  183. newClient.flow = clientsBulkModal.flow;
  184. }
  185. newClient.reset = clientsBulkModal.reset;
  186. clients.push(newClient);
  187. }
  188. ObjectUtil.execute(clientsBulkModal.confirm, clients, clientsBulkModal.dbInbound.id);
  189. },
  190. show({
  191. title = '',
  192. okText = '{{ i18n "sure" }}',
  193. dbInbound = null,
  194. confirm = (inbound, dbInbound) => { }
  195. }) {
  196. this.visible = true;
  197. this.title = title;
  198. this.okText = okText;
  199. this.confirm = confirm;
  200. this.quantity = 1;
  201. this.totalGB = 0;
  202. this.expiryTime = 0;
  203. this.emailMethod = 0;
  204. this.limitIp = 0;
  205. this.firstNum = 1;
  206. this.lastNum = 1;
  207. this.emailPrefix = "";
  208. this.emailPostfix = "";
  209. this.subId = "";
  210. this.tgId = "";
  211. this.flow = "";
  212. this.dbInbound = new DBInbound(dbInbound);
  213. this.inbound = dbInbound.toInbound();
  214. this.delayedStart = false;
  215. this.reset = 0;
  216. },
  217. newClient(protocol) {
  218. switch (protocol) {
  219. case Protocols.VMESS: return new Inbound.VmessSettings.Vmess();
  220. case Protocols.VLESS: return new Inbound.VLESSSettings.VLESS();
  221. case Protocols.TROJAN: return new Inbound.TrojanSettings.Trojan();
  222. case Protocols.SHADOWSOCKS: return new Inbound.ShadowsocksSettings.Shadowsocks(clientsBulkModal.inbound.settings.shadowsockses[0].method);
  223. default: return null;
  224. }
  225. },
  226. close() {
  227. clientsBulkModal.visible = false;
  228. clientsBulkModal.loading(false);
  229. },
  230. loading(loading) {
  231. clientsBulkModal.confirmLoading = loading;
  232. },
  233. };
  234. const clientsBulkModalApp = new Vue({
  235. delimiters: ['[[', ']]'],
  236. el: '#client-bulk-modal',
  237. data: {
  238. clientsBulkModal,
  239. get inbound() {
  240. return this.clientsBulkModal.inbound;
  241. },
  242. get delayedExpireDays() {
  243. return this.clientsBulkModal.expiryTime < 0 ? this.clientsBulkModal.expiryTime / -86400000 : 0;
  244. },
  245. set delayedExpireDays(days) {
  246. this.clientsBulkModal.expiryTime = -86400000 * days;
  247. },
  248. },
  249. });
  250. </script>
  251. {{end}}