1
0

client_bulk_modal.html 12 KB

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