client_bulk_modal.html 11 KB

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