1
0

client_bulk_modal.html 12 KB

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