1
0

client_bulk_modal.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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">
  112. </persian-datepicker>
  113. </a-form-item>
  114. <a-form-item v-if="clientsBulkModal.expiryTime != 0">
  115. <template slot="label">
  116. <a-tooltip>
  117. <template slot="title">
  118. <span>{{ i18n "pages.client.renewDesc" }}</span>
  119. </template>
  120. {{ i18n "pages.client.renew" }}
  121. <a-icon type="question-circle"></a-icon>
  122. </a-tooltip>
  123. </template>
  124. <a-input-number v-model.number="clientsBulkModal.reset" :min="0"></a-input-number>
  125. </a-form-item>
  126. </a-form>
  127. </a-modal>
  128. <script>
  129. const clientsBulkModal = {
  130. visible: false,
  131. confirmLoading: false,
  132. title: '',
  133. okText: '',
  134. confirm: null,
  135. dbInbound: new DBInbound(),
  136. inbound: new Inbound(),
  137. quantity: 1,
  138. totalGB: 0,
  139. limitIp: 0,
  140. expiryTime: '',
  141. emailMethod: 0,
  142. firstNum: 1,
  143. lastNum: 1,
  144. emailPrefix: "",
  145. emailPostfix: "",
  146. subId: "",
  147. tgId: '',
  148. flow: "",
  149. delayedStart: false,
  150. reset: 0,
  151. ok() {
  152. clients = [];
  153. method = clientsBulkModal.emailMethod;
  154. if (method > 1) {
  155. start = clientsBulkModal.firstNum;
  156. end = clientsBulkModal.lastNum + 1;
  157. } else {
  158. start = 0;
  159. end = clientsBulkModal.quantity;
  160. }
  161. prefix = (method > 0 && clientsBulkModal.emailPrefix.length > 0) ? clientsBulkModal.emailPrefix : "";
  162. useNum = (method > 1);
  163. postfix = (method > 2 && clientsBulkModal.emailPostfix.length > 0) ? clientsBulkModal.emailPostfix : "";
  164. for (let i = start; i < end; i++) {
  165. newClient = clientsBulkModal.newClient(clientsBulkModal.dbInbound.protocol);
  166. if (method == 4) newClient.email = "";
  167. newClient.email += useNum ? prefix + i.toString() + postfix : prefix + postfix;
  168. if (clientsBulkModal.subId.length > 0) newClient.subId = clientsBulkModal.subId;
  169. newClient.tgId = clientsBulkModal.tgId;
  170. newClient.limitIp = clientsBulkModal.limitIp;
  171. newClient._totalGB = clientsBulkModal.totalGB;
  172. newClient._expiryTime = clientsBulkModal.expiryTime;
  173. if (clientsBulkModal.inbound.canEnableTlsFlow()) {
  174. newClient.flow = clientsBulkModal.flow;
  175. }
  176. if (clientsBulkModal.inbound.xtls) {
  177. newClient.flow = clientsBulkModal.flow;
  178. }
  179. newClient.reset = clientsBulkModal.reset;
  180. clients.push(newClient);
  181. }
  182. ObjectUtil.execute(clientsBulkModal.confirm, clients, clientsBulkModal.dbInbound.id);
  183. },
  184. show({
  185. title = '',
  186. okText = '{{ i18n "sure" }}',
  187. dbInbound = null,
  188. confirm = (inbound, dbInbound) => { }
  189. }) {
  190. this.visible = true;
  191. this.title = title;
  192. this.okText = okText;
  193. this.confirm = confirm;
  194. this.quantity = 1;
  195. this.totalGB = 0;
  196. this.expiryTime = 0;
  197. this.emailMethod = 0;
  198. this.limitIp = 0;
  199. this.firstNum = 1;
  200. this.lastNum = 1;
  201. this.emailPrefix = "";
  202. this.emailPostfix = "";
  203. this.subId = "";
  204. this.tgId = '';
  205. this.flow = "";
  206. this.dbInbound = new DBInbound(dbInbound);
  207. this.inbound = dbInbound.toInbound();
  208. this.delayedStart = false;
  209. this.reset = 0;
  210. },
  211. newClient(protocol) {
  212. switch (protocol) {
  213. case Protocols.VMESS: return new Inbound.VmessSettings.Vmess();
  214. case Protocols.VLESS: return new Inbound.VLESSSettings.VLESS();
  215. case Protocols.TROJAN: return new Inbound.TrojanSettings.Trojan();
  216. case Protocols.SHADOWSOCKS: return new Inbound.ShadowsocksSettings.Shadowsocks(clientsBulkModal.inbound.settings.shadowsockses[0].method);
  217. default: return null;
  218. }
  219. },
  220. close() {
  221. clientsBulkModal.visible = false;
  222. clientsBulkModal.loading(false);
  223. },
  224. loading(loading = true) {
  225. clientsBulkModal.confirmLoading = loading;
  226. },
  227. };
  228. const clientsBulkModalApp = new Vue({
  229. delimiters: ['[[', ']]'],
  230. el: '#client-bulk-modal',
  231. data: {
  232. clientsBulkModal,
  233. get inbound() {
  234. return this.clientsBulkModal.inbound;
  235. },
  236. get delayedExpireDays() {
  237. return this.clientsBulkModal.expiryTime < 0 ? this.clientsBulkModal.expiryTime / -86400000 : 0;
  238. },
  239. get datepicker() {
  240. return app.datepicker;
  241. },
  242. set delayedExpireDays(days) {
  243. this.clientsBulkModal.expiryTime = -86400000 * days;
  244. },
  245. },
  246. });
  247. </script>
  248. {{end}}