client_bulk_modal.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. {{define "modals/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 :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
  6. <a-form-item label='{{ i18n "pages.client.method" }}'>
  7. <a-select v-model="clientsBulkModal.emailMethod" buttonStyle="solid"
  8. :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</a-select-option>
  14. </a-select>
  15. </a-form-item>
  16. <a-form-item label='{{ i18n "pages.client.first" }}' v-if="clientsBulkModal.emailMethod>1">
  17. <a-input-number v-model.number="clientsBulkModal.firstNum" :min="1"></a-input-number>
  18. </a-form-item>
  19. <a-form-item label='{{ i18n "pages.client.last" }}' v-if="clientsBulkModal.emailMethod>1">
  20. <a-input-number v-model.number="clientsBulkModal.lastNum" :min="clientsBulkModal.firstNum"></a-input-number>
  21. </a-form-item>
  22. <a-form-item label='{{ i18n "pages.client.prefix" }}' v-if="clientsBulkModal.emailMethod>0">
  23. <a-input v-model.trim="clientsBulkModal.emailPrefix"></a-input>
  24. </a-form-item>
  25. <a-form-item label='{{ i18n "pages.client.postfix" }}' v-if="clientsBulkModal.emailMethod>2">
  26. <a-input v-model.trim="clientsBulkModal.emailPostfix"></a-input>
  27. </a-form-item>
  28. <a-form-item label='{{ i18n "pages.client.clientCount" }}' v-if="clientsBulkModal.emailMethod < 2">
  29. <a-input-number v-model.number="clientsBulkModal.quantity" :min="1" :max="500"></a-input-number>
  30. </a-form-item>
  31. <a-form-item label='{{ i18n "security" }}' v-if="inbound.protocol === Protocols.VMESS">
  32. <a-select v-model="clientsBulkModal.security" :dropdown-class-name="themeSwitcher.currentTheme">
  33. <a-select-option v-for="key in USERS_SECURITY" :value="key">[[
  34. key ]]</a-select-option>
  35. </a-select>
  36. </a-form-item>
  37. <a-form-item label='Flow' v-if="clientsBulkModal.inbound.canEnableTlsFlow()">
  38. <a-select v-model="clientsBulkModal.flow" :dropdown-class-name="themeSwitcher.currentTheme">
  39. <a-select-option value selected>{{ i18n "none"
  40. }}</a-select-option>
  41. <a-select-option v-for="key in TLS_FLOW_CONTROL" :value="key">[[
  42. key ]]</a-select-option>
  43. </a-select>
  44. </a-form-item>
  45. <a-form-item v-if="app.subSettings?.enable">
  46. <template slot="label">
  47. <a-tooltip>
  48. <template slot="title">
  49. <span>{{ i18n "pages.inbounds.subscriptionDesc"
  50. }}</span>
  51. </template>
  52. Subscription
  53. <a-icon @click="clientsBulkModal.subId = RandomUtil.randomLowerAndNum(16)" type="sync"></a-icon>
  54. </a-tooltip>
  55. </template>
  56. <a-input v-model.trim="clientsBulkModal.subId"></a-input>
  57. </a-form-item>
  58. <a-form-item v-if="app.tgBotEnable">
  59. <template slot="label">
  60. <a-tooltip>
  61. <template slot="title">
  62. <span>{{ i18n "pages.inbounds.telegramDesc" }}</span>
  63. </template>
  64. Telegram ChatID
  65. <a-icon type="question-circle"></a-icon>
  66. </a-tooltip>
  67. </template>
  68. <a-input-number :style="{ width: '50%' }" v-model.number="clientsBulkModal.tgId" min="0"></a-input-number>
  69. </a-form-item>
  70. <a-form-item v-if="app.ipLimitEnable">
  71. <template slot="label">
  72. <a-tooltip>
  73. <template slot="title">
  74. <span>{{ i18n "pages.inbounds.IPLimitDesc" }}</span>
  75. </template>
  76. <span>{{ i18n "pages.inbounds.IPLimit" }} </span>
  77. <a-icon type="question-circle"></a-icon>
  78. </a-tooltip>
  79. </template>
  80. <a-input-number v-model.number="clientsBulkModal.limitIp" min="0"></a-input-number>
  81. </a-form-item>
  82. <a-form-item>
  83. <template slot="label">
  84. <a-tooltip>
  85. <template slot="title">
  86. 0 <span>{{ i18n "pages.inbounds.meansNoLimit" }}</span>
  87. </template>
  88. {{ i18n "pages.inbounds.totalFlow" }}
  89. <a-icon type="question-circle"></a-icon>
  90. </a-tooltip>
  91. </template>
  92. <a-input-number v-model.number="clientsBulkModal.totalGB" :min="0"></a-input-number>
  93. </a-form-item>
  94. <a-form-item label='{{ i18n "pages.client.delayedStart" }}'>
  95. <a-switch v-model="clientsBulkModal.delayedStart" @click="clientsBulkModal.expiryTime=0"></a-switch>
  96. </a-form-item>
  97. <a-form-item label='{{ i18n "pages.client.expireDays" }}' v-if="clientsBulkModal.delayedStart">
  98. <a-input-number v-model.number="delayedExpireDays" :min="0"></a-input-number>
  99. </a-form-item>
  100. <a-form-item v-else>
  101. <template slot="label">
  102. <a-tooltip>
  103. <template slot="title">
  104. <span>{{ i18n "pages.inbounds.leaveBlankToNeverExpire"
  105. }}</span>
  106. </template>
  107. {{ i18n "pages.inbounds.expireDate" }}
  108. <a-icon type="question-circle"></a-icon>
  109. </a-tooltip>
  110. </template>
  111. <a-date-picker v-if="datepicker == 'gregorian'" :show-time="{ format: 'HH:mm:ss' }"
  112. format="YYYY-MM-DD HH:mm:ss" :dropdown-class-name="themeSwitcher.currentTheme"
  113. v-model="clientsBulkModal.expiryTime"></a-date-picker>
  114. <a-persian-datepicker v-else placeholder='{{ i18n "pages.settings.datepickerPlaceholder" }}'
  115. value="clientsBulkModal.expiryTime" v-model="clientsBulkModal.expiryTime">
  116. </a-persian-datepicker>
  117. </a-form-item>
  118. <a-form-item v-if="clientsBulkModal.expiryTime != 0">
  119. <template slot="label">
  120. <a-tooltip>
  121. <template slot="title">
  122. <span>{{ i18n "pages.client.renewDesc" }}</span>
  123. </template>
  124. {{ i18n "pages.client.renew" }}
  125. <a-icon type="question-circle"></a-icon>
  126. </a-tooltip>
  127. </template>
  128. <a-input-number v-model.number="clientsBulkModal.reset" :min="0"></a-input-number>
  129. </a-form-item>
  130. </a-form>
  131. </a-modal>
  132. <script>
  133. const clientsBulkModal = {
  134. visible: false,
  135. confirmLoading: false,
  136. title: '',
  137. okText: '',
  138. confirm: null,
  139. dbInbound: new DBInbound(),
  140. inbound: new Inbound(),
  141. quantity: 1,
  142. totalGB: 0,
  143. limitIp: 0,
  144. expiryTime: '',
  145. emailMethod: 0,
  146. firstNum: 1,
  147. lastNum: 1,
  148. emailPrefix: "",
  149. emailPostfix: "",
  150. subId: "",
  151. tgId: '',
  152. security: "auto",
  153. flow: "",
  154. delayedStart: false,
  155. reset: 0,
  156. ok() {
  157. clients = [];
  158. method = clientsBulkModal.emailMethod;
  159. if (method > 1) {
  160. start = clientsBulkModal.firstNum;
  161. end = clientsBulkModal.lastNum + 1;
  162. } else {
  163. start = 0;
  164. end = clientsBulkModal.quantity;
  165. }
  166. prefix = (method > 0 && clientsBulkModal.emailPrefix.length > 0) ? clientsBulkModal.emailPrefix : "";
  167. useNum = (method > 1);
  168. postfix = (method > 2 && clientsBulkModal.emailPostfix.length > 0) ? clientsBulkModal.emailPostfix : "";
  169. for (let i = start; i < end; i++) {
  170. newClient = clientsBulkModal.newClient(clientsBulkModal.dbInbound.protocol);
  171. if (method == 4) newClient.email = "";
  172. newClient.email += useNum ? prefix + i.toString() + postfix : prefix + postfix;
  173. if (clientsBulkModal.subId.length > 0) newClient.subId = clientsBulkModal.subId;
  174. newClient.tgId = clientsBulkModal.tgId;
  175. newClient.security = clientsBulkModal.security;
  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. newClient.reset = clientsBulkModal.reset;
  183. clients.push(newClient);
  184. }
  185. ObjectUtil.execute(clientsBulkModal.confirm, clients, clientsBulkModal.dbInbound.id);
  186. },
  187. show({
  188. title = '',
  189. okText = '{{ i18n "sure" }}',
  190. dbInbound = null,
  191. confirm = (inbound, dbInbound) => {}
  192. }) {
  193. this.visible = true;
  194. this.title = title;
  195. this.okText = okText;
  196. this.confirm = confirm;
  197. this.quantity = 1;
  198. this.totalGB = 0;
  199. this.expiryTime = 0;
  200. this.emailMethod = 0;
  201. this.limitIp = 0;
  202. this.firstNum = 1;
  203. this.lastNum = 1;
  204. this.emailPrefix = "";
  205. this.emailPostfix = "";
  206. this.subId = "";
  207. this.tgId = '';
  208. this.security = "auto";
  209. this.flow = "";
  210. this.dbInbound = new DBInbound(dbInbound);
  211. this.inbound = Inbound.fromJson(dbInbound.toInbound().toJson());
  212. this.delayedStart = false;
  213. this.reset = 0;
  214. },
  215. newClient(protocol) {
  216. switch (protocol) {
  217. case Protocols.VMESS:
  218. return new Inbound.VmessSettings.VMESS();
  219. case Protocols.VLESS:
  220. return new Inbound.VLESSSettings.VLESS();
  221. case Protocols.TROJAN:
  222. return new Inbound.TrojanSettings.Trojan();
  223. case Protocols.SHADOWSOCKS:
  224. return new Inbound.ShadowsocksSettings.Shadowsocks(clientsBulkModal.inbound.settings
  225. .shadowsockses[0].method);
  226. case Protocols.HYSTERIA:
  227. return new Inbound.HysteriaSettings.Hysteria();
  228. default:
  229. return null;
  230. }
  231. },
  232. close() {
  233. clientsBulkModal.visible = false;
  234. clientsBulkModal.loading(false);
  235. },
  236. loading(loading = true) {
  237. clientsBulkModal.confirmLoading = loading;
  238. },
  239. };
  240. const clientsBulkModalApp = new Vue({
  241. delimiters: ['[[', ']]'],
  242. el: '#client-bulk-modal',
  243. data: {
  244. clientsBulkModal,
  245. get inbound() {
  246. return this.clientsBulkModal.inbound;
  247. },
  248. get delayedExpireDays() {
  249. return this.clientsBulkModal.expiryTime < 0 ? this.clientsBulkModal.expiryTime / -86400000 :
  250. 0;
  251. },
  252. get datepicker() {
  253. return app.datepicker;
  254. },
  255. set delayedExpireDays(days) {
  256. this.clientsBulkModal.expiryTime = -86400000 * days;
  257. },
  258. },
  259. });
  260. </script>
  261. {{end}}