client_bulk_modal.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. {{define "clientsBulkModal"}}
  2. <a-modal id="client-bulk-modal" v-model="clientsBulkModal.visible" :title="clientsBulkModal.title"
  3. @ok="clientsBulkModal.ok" :confirm-loading="clientsBulkModal.confirmLoading" :closable="true" :mask-closable="false"
  4. :ok-text="clientsBulkModal.okText" cancel-text='{{ i18n "close" }}' :class="themeSwitcher.currentTheme">
  5. <a-form layout="inline">
  6. <table width="100%" class="ant-table-tbody">
  7. <tr>
  8. <td>{{ i18n "pages.client.method" }}</td>
  9. <td>
  10. <a-form-item>
  11. <a-select v-model="clientsBulkModal.emailMethod" buttonStyle="solid" style="width: 250px"
  12. :dropdown-class-name="themeSwitcher.currentTheme">
  13. <a-select-option :value="0">Random</a-select-option>
  14. <a-select-option :value="1">Random+Prefix</a-select-option>
  15. <a-select-option :value="2">Random+Prefix+Num</a-select-option>
  16. <a-select-option :value="3">Random+Prefix+Num+Postfix</a-select-option>
  17. <a-select-option :value="4">Prefix+Num+Postfix</a-select-option>
  18. </a-select>
  19. </a-form-item>
  20. </td>
  21. </tr>
  22. <tr v-if="clientsBulkModal.emailMethod>1">
  23. <td>{{ i18n "pages.client.first" }}</td>
  24. <td>
  25. <a-form-item>
  26. <a-input-number v-model="clientsBulkModal.firstNum" :min="1"></a-input-number>
  27. </a-form-item>
  28. </td>
  29. </tr>
  30. <tr v-if="clientsBulkModal.emailMethod>1">
  31. <td>{{ i18n "pages.client.last" }}</td>
  32. <td>
  33. <a-form-item>
  34. <a-input-number v-model="clientsBulkModal.lastNum"
  35. :min="clientsBulkModal.firstNum"></a-input-number>
  36. </a-form-item>
  37. </td>
  38. </tr>
  39. <tr v-if="clientsBulkModal.emailMethod>0">
  40. <td>{{ i18n "pages.client.prefix" }}</td>
  41. <td>
  42. <a-form-item>
  43. <a-input v-model="clientsBulkModal.emailPrefix" style="width: 250px"></a-input>
  44. </a-form-item>
  45. </td>
  46. </tr>
  47. <tr v-if="clientsBulkModal.emailMethod>2">
  48. <td>{{ i18n "pages.client.postfix" }}</td>
  49. <td>
  50. <a-form-item>
  51. <a-input v-model="clientsBulkModal.emailPostfix" style="width: 250px"></a-input>
  52. </a-form-item>
  53. </td>
  54. </tr>
  55. <tr v-if="clientsBulkModal.emailMethod < 2">
  56. <td>{{ i18n "pages.client.clientCount" }}</td>
  57. <td>
  58. <a-form-item>
  59. <a-input-number v-model="clientsBulkModal.quantity" :min="1" :max="100"></a-input-number>
  60. </a-form-item>
  61. </td>
  62. </tr>
  63. <tr v-if="clientsBulkModal.inbound.canEnableTlsFlow()">
  64. <td>Flow</td>
  65. <td>
  66. <a-form-item>
  67. <a-select v-model="clientsBulkModal.flow" style="width: 250px"
  68. :dropdown-class-name="themeSwitcher.currentTheme">
  69. <a-select-option value="" selected>{{ i18n "none" }}</a-select-option>
  70. <a-select-option v-for="key in TLS_FLOW_CONTROL" :value="key">[[ key ]]</a-select-option>
  71. </a-select>
  72. </a-form-item>
  73. </td>
  74. </tr>
  75. <tr v-if="app.subSettings.enable">
  76. <td>Subscription
  77. <a-tooltip>
  78. <template slot="title">
  79. <span>{{ i18n "pages.inbounds.subscriptionDesc" }}</span>
  80. </template>
  81. <a-icon @click="client.subId = RandomUtil.randomLowerAndNum(16)" type="sync"></a-icon>
  82. </a-tooltip>
  83. </td>
  84. <td>
  85. <a-form-item>
  86. <a-input v-model.trim="clientsBulkModal.subId" style="width: 250px"></a-input>
  87. </a-form-item>
  88. </td>
  89. </tr>
  90. <tr v-if="app.tgBotEnable">
  91. <td>Telegram ID
  92. <a-tooltip>
  93. <template slot="title">
  94. <span>{{ i18n "pages.inbounds.telegramDesc" }}</span>
  95. </template>
  96. <a-icon type="question-circle" theme="filled"></a-icon>
  97. </a-tooltip>
  98. </td>
  99. <td>
  100. <a-form-item>
  101. <a-input v-model.trim="clientsBulkModal.tgId" style="width: 250px"></a-input>
  102. </a-form-item>
  103. </td>
  104. </tr>
  105. <tr>
  106. <td>
  107. <label>
  108. <span>{{ i18n "pages.inbounds.IPLimit" }}</span>
  109. <a-tooltip>
  110. <template slot="title">
  111. <span>{{ i18n "pages.inbounds.IPLimitDesc" }}</span>
  112. </template>
  113. <a-icon type="question-circle" theme="filled"></a-icon>
  114. </a-tooltip>
  115. </label>
  116. </td>
  117. <td>
  118. <a-form-item>
  119. <a-input-number v-model="clientsBulkModal.limitIp" min="0"></a-input-number>
  120. </a-form-item>
  121. </td>
  122. </tr>
  123. <tr>
  124. <td v-if="clientsBulkModal.inbound.xtls">
  125. <label>Flow</label>
  126. </td>
  127. <td v-if="clientsBulkModal.inbound.xtls">
  128. <a-form-item>
  129. <a-select v-model="clientsBulkModal.flow" style="width: 200px"
  130. :dropdown-class-name="themeSwitcher.currentTheme">
  131. <a-select-option value="">{{ i18n "none" }}</a-select-option>
  132. <a-select-option v-for="key in XTLS_FLOW_CONTROL" :value="key">[[ key ]]</a-select-option>
  133. </a-select>
  134. </a-form-item>
  135. </td>
  136. </tr>
  137. <tr>
  138. <td>
  139. <span>{{ i18n "pages.inbounds.totalFlow" }}</span>(GB)
  140. <a-tooltip>
  141. <template slot="title">
  142. 0 <span>{{ i18n "pages.inbounds.meansNoLimit" }}</span>
  143. </template>
  144. <a-icon type="question-circle" theme="filled"></a-icon>
  145. </a-tooltip>
  146. </td>
  147. <td>
  148. <a-form-item>
  149. <a-input-number v-model="clientsBulkModal.totalGB" :min="0"></a-input-number>
  150. </a-form-item>
  151. </td>
  152. </tr>
  153. <tr>
  154. <td>{{ i18n "pages.client.delayedStart" }}</td>
  155. <td>
  156. <a-form-item>
  157. <a-switch v-model="clientsBulkModal.delayedStart"
  158. @click="clientsBulkModal.expiryTime=0"></a-switch>
  159. </a-form-item>
  160. </td>
  161. </tr>
  162. <tr v-if="clientsBulkModal.delayedStart">
  163. <td>{{ i18n "pages.client.expireDays" }}</td>
  164. <td>
  165. <a-form-item>
  166. <a-input-number v-model.number="delayedExpireDays" :min="0"></a-input-number>
  167. </a-form-item>
  168. </td>
  169. </tr>
  170. <tr v-else>
  171. <td>
  172. <span>{{ i18n "pages.inbounds.expireDate" }}</span>
  173. <a-tooltip>
  174. <template slot="title">
  175. <span>{{ i18n "pages.inbounds.leaveBlankToNeverExpire" }}</span>
  176. </template>
  177. <a-icon type="question-circle" theme="filled"></a-icon>
  178. </a-tooltip>
  179. </td>
  180. <td>
  181. <a-form-item>
  182. <a-date-picker :show-time="{ format: 'HH:mm:ss' }" format="YYYY-MM-DD HH:mm:ss"
  183. :dropdown-class-name="themeSwitcher.currentTheme" v-model="clientsBulkModal.expiryTime"
  184. style="width: 250px;"></a-date-picker>
  185. </a-form-item>
  186. </td>
  187. </tr>
  188. <tr v-if="clientsBulkModal.expiryTime != 0">
  189. <td>
  190. <span>{{ i18n "pages.client.renew" }}</span>
  191. <a-tooltip>
  192. <template slot="title">
  193. <span>{{ i18n "pages.client.renewDesc" }}</span>
  194. </template>
  195. <a-icon type="question-circle" theme="filled"></a-icon>
  196. </a-tooltip>
  197. </td>
  198. <td>
  199. <a-form-item>
  200. <a-input-number v-model.number="clientsBulkModal.reset" :min="0"></a-input-number>
  201. </a-form-item>
  202. </td>
  203. </tr>
  204. </table>
  205. </a-form>
  206. </a-modal>
  207. <script>
  208. const clientsBulkModal = {
  209. visible: false,
  210. confirmLoading: false,
  211. title: '',
  212. okText: '',
  213. confirm: null,
  214. dbInbound: new DBInbound(),
  215. inbound: new Inbound(),
  216. quantity: 1,
  217. totalGB: 0,
  218. limitIp: 0,
  219. expiryTime: '',
  220. emailMethod: 0,
  221. firstNum: 1,
  222. lastNum: 1,
  223. emailPrefix: "",
  224. emailPostfix: "",
  225. subId: "",
  226. tgId: "",
  227. flow: "",
  228. delayedStart: false,
  229. reset: 0,
  230. ok() {
  231. clients = [];
  232. method = clientsBulkModal.emailMethod;
  233. if (method > 1) {
  234. start = clientsBulkModal.firstNum;
  235. end = clientsBulkModal.lastNum + 1;
  236. } else {
  237. start = 0;
  238. end = clientsBulkModal.quantity;
  239. }
  240. prefix = (method > 0 && clientsBulkModal.emailPrefix.length > 0) ? clientsBulkModal.emailPrefix : "";
  241. useNum = (method > 1);
  242. postfix = (method > 2 && clientsBulkModal.emailPostfix.length > 0) ? clientsBulkModal.emailPostfix : "";
  243. for (let i = start; i < end; i++) {
  244. newClient = clientsBulkModal.newClient(clientsBulkModal.dbInbound.protocol);
  245. if (method == 4) newClient.email = "";
  246. newClient.email += useNum ? prefix + i.toString() + postfix : prefix + postfix;
  247. if (clientsBulkModal.subId.length > 0) newClient.subId = clientsBulkModal.subId;
  248. if (clientsBulkModal.tgId.length > 0) newClient.tgId = clientsBulkModal.tgId;
  249. newClient.limitIp = clientsBulkModal.limitIp;
  250. newClient._totalGB = clientsBulkModal.totalGB;
  251. newClient._expiryTime = clientsBulkModal.expiryTime;
  252. if (clientsBulkModal.inbound.canEnableTlsFlow()) {
  253. newClient.flow = clientsBulkModal.flow;
  254. }
  255. if (clientsBulkModal.inbound.xtls) {
  256. newClient.flow = clientsBulkModal.flow;
  257. }
  258. newClient.reset = clientsBulkModal.reset;
  259. clients.push(newClient);
  260. }
  261. ObjectUtil.execute(clientsBulkModal.confirm, clients, clientsBulkModal.dbInbound.id);
  262. },
  263. show({
  264. title = '',
  265. okText = '{{ i18n "sure" }}',
  266. dbInbound = null,
  267. confirm = (inbound, dbInbound) => { }
  268. }) {
  269. this.visible = true;
  270. this.title = title;
  271. this.okText = okText;
  272. this.confirm = confirm;
  273. this.quantity = 1;
  274. this.totalGB = 0;
  275. this.expiryTime = 0;
  276. this.emailMethod = 0;
  277. this.limitIp = 0;
  278. this.firstNum = 1;
  279. this.lastNum = 1;
  280. this.emailPrefix = "";
  281. this.emailPostfix = "";
  282. this.subId = "";
  283. this.tgId = "";
  284. this.flow = "";
  285. this.dbInbound = new DBInbound(dbInbound);
  286. this.inbound = dbInbound.toInbound();
  287. this.delayedStart = false;
  288. this.reset = 0;
  289. },
  290. newClient(protocol) {
  291. switch (protocol) {
  292. case Protocols.VMESS: return new Inbound.VmessSettings.Vmess();
  293. case Protocols.VLESS: return new Inbound.VLESSSettings.VLESS();
  294. case Protocols.TROJAN: return new Inbound.TrojanSettings.Trojan();
  295. case Protocols.SHADOWSOCKS: return new Inbound.ShadowsocksSettings.Shadowsocks(clientsBulkModal.inbound.settings.shadowsockses[0].method);
  296. default: return null;
  297. }
  298. },
  299. close() {
  300. clientsBulkModal.visible = false;
  301. clientsBulkModal.loading(false);
  302. },
  303. loading(loading) {
  304. clientsBulkModal.confirmLoading = loading;
  305. },
  306. };
  307. const clientsBulkModalApp = new Vue({
  308. delimiters: ['[[', ']]'],
  309. el: '#client-bulk-modal',
  310. data: {
  311. clientsBulkModal,
  312. get inbound() {
  313. return this.clientsBulkModal.inbound;
  314. },
  315. get delayedExpireDays() {
  316. return this.clientsBulkModal.expiryTime < 0 ? this.clientsBulkModal.expiryTime / -86400000 : 0;
  317. },
  318. set delayedExpireDays(days) {
  319. this.clientsBulkModal.expiryTime = -86400000 * days;
  320. },
  321. },
  322. });
  323. </script>
  324. {{end}}