1
0

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='{{ 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 v-if="app.subSettings.enable">
  43. <template slot="label">
  44. <a-tooltip>
  45. <template slot="title">
  46. <span>{{ i18n "pages.inbounds.subscriptionDesc" }}</span>
  47. </template>
  48. Subscription
  49. <a-icon @click="clientsBulkModal.subId = RandomUtil.randomLowerAndNum(16)" type="sync"></a-icon>
  50. </a-tooltip>
  51. </template>
  52. <a-input v-model.trim="clientsBulkModal.subId"></a-input>
  53. </a-form-item>
  54. <a-form-item v-if="app.tgBotEnable">
  55. <template slot="label">
  56. <a-tooltip>
  57. <template slot="title">
  58. <span>{{ i18n "pages.inbounds.telegramDesc" }}</span>
  59. </template>
  60. Telegram ChatID
  61. <a-icon type="question-circle"></a-icon>
  62. </a-tooltip>
  63. </template>
  64. <a-input-number style="width: 50%" v-model="clientsBulkModal.tgId" min="0"></a-input-number>
  65. </a-form-item>
  66. <a-form-item v-if="app.ipLimitEnable">
  67. <template slot="label">
  68. <a-tooltip>
  69. <template slot="title">
  70. <span>{{ i18n "pages.inbounds.IPLimitDesc" }}</span>
  71. </template>
  72. <span>{{ i18n "pages.inbounds.IPLimit" }} </span>
  73. <a-icon type="question-circle"></a-icon>
  74. </a-tooltip>
  75. </template>
  76. <a-input-number v-model="clientsBulkModal.limitIp" min="0"></a-input-number>
  77. </a-form-item>
  78. <a-form-item>
  79. <template slot="label">
  80. <a-tooltip>
  81. <template slot="title">
  82. 0 <span>{{ i18n "pages.inbounds.meansNoLimit" }}</span>
  83. </template>
  84. {{ i18n "pages.inbounds.totalFlow" }}
  85. <a-icon type="question-circle"></a-icon>
  86. </a-tooltip>
  87. </template>
  88. <a-input-number v-model="clientsBulkModal.totalGB" :min="0"></a-input-number>
  89. </a-form-item>
  90. <a-form-item label='{{ i18n "pages.client.delayedStart" }}'>
  91. <a-switch v-model="clientsBulkModal.delayedStart" @click="clientsBulkModal.expiryTime=0"></a-switch>
  92. </a-form-item>
  93. <a-form-item label='{{ i18n "pages.client.expireDays" }}' v-if="clientsBulkModal.delayedStart">
  94. <a-input-number v-model.number="delayedExpireDays" :min="0"></a-input-number>
  95. </a-form-item>
  96. <a-form-item v-else>
  97. <template slot="label">
  98. <a-tooltip>
  99. <template slot="title">
  100. <span>{{ i18n "pages.inbounds.leaveBlankToNeverExpire" }}</span>
  101. </template>
  102. {{ i18n "pages.inbounds.expireDate" }}
  103. <a-icon type="question-circle"></a-icon>
  104. </a-tooltip>
  105. </template>
  106. <a-date-picker v-if="datepicker == 'gregorian'" :show-time="{ format: 'HH:mm:ss' }"
  107. format="YYYY-MM-DD HH:mm:ss" :dropdown-class-name="themeSwitcher.currentTheme"
  108. v-model="clientsBulkModal.expiryTime"></a-date-picker>
  109. <persian-datepicker v-else placeholder='{{ i18n "pages.settings.datepickerPlaceholder" }}'
  110. value="clientsBulkModal.expiryTime" v-model="clientsBulkModal.expiryTime">
  111. </persian-datepicker>
  112. </a-form-item>
  113. <a-form-item v-if="clientsBulkModal.expiryTime != 0">
  114. <template slot="label">
  115. <a-tooltip>
  116. <template slot="title">
  117. <span>{{ i18n "pages.client.renewDesc" }}</span>
  118. </template>
  119. {{ i18n "pages.client.renew" }}
  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. security: "auto",
  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.security = clientsBulkModal.security;
  171. newClient.limitIp = clientsBulkModal.limitIp;
  172. newClient._totalGB = clientsBulkModal.totalGB;
  173. newClient._expiryTime = clientsBulkModal.expiryTime;
  174. if (clientsBulkModal.inbound.canEnableTlsFlow()) {
  175. newClient.flow = clientsBulkModal.flow;
  176. }
  177. newClient.reset = clientsBulkModal.reset;
  178. clients.push(newClient);
  179. }
  180. ObjectUtil.execute(clientsBulkModal.confirm, clients, clientsBulkModal.dbInbound.id);
  181. },
  182. show({
  183. title = '',
  184. okText = '{{ i18n "sure" }}',
  185. dbInbound = null,
  186. confirm = (inbound, dbInbound) => { }
  187. }) {
  188. this.visible = true;
  189. this.title = title;
  190. this.okText = okText;
  191. this.confirm = confirm;
  192. this.quantity = 1;
  193. this.totalGB = 0;
  194. this.expiryTime = 0;
  195. this.emailMethod = 0;
  196. this.limitIp = 0;
  197. this.firstNum = 1;
  198. this.lastNum = 1;
  199. this.emailPrefix = "";
  200. this.emailPostfix = "";
  201. this.subId = "";
  202. this.tgId = '';
  203. this.security = "auto";
  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}}