diff options
Diffstat (limited to 'web/html')
| -rw-r--r-- | web/html/common/qrcode_modal.html | 17 | ||||
| -rw-r--r-- | web/html/xui/client_modal.html | 154 | ||||
| -rw-r--r-- | web/html/xui/form/client.html | 16 | ||||
| -rw-r--r-- | web/html/xui/inbound_modal.html | 4 | ||||
| -rw-r--r-- | web/html/xui/inbounds.html | 82 |
5 files changed, 38 insertions, 235 deletions
diff --git a/web/html/common/qrcode_modal.html b/web/html/common/qrcode_modal.html index 31b3450c..3c4fd929 100644 --- a/web/html/common/qrcode_modal.html +++ b/web/html/common/qrcode_modal.html @@ -11,12 +11,10 @@ <a-divider>Subscription</a-divider> <div class="qr-bg"><canvas @click="copyToClipboard('qrCode-sub',genSubLink(qrModal.client.subId))" id="qrCode-sub" style="width: 100%; height: 100%;"></canvas></div> </template> - <a-divider v-if="!isJustSub">{{ i18n "pages.inbounds.client" }}</a-divider> - <template v-if="!isJustSub"> - <template v-for="(row, index) in qrModal.qrcodes"> - <a-tag color="green" style="margin: 10px 0; display: block; text-align: center;">[[ row.remark ]]</a-tag> - <div class="qr-bg"><canvas @click="copyToClipboard('qrCode-'+index, row.link)" :id="'qrCode-'+index" style="width: 100%; height: 100%;"></canvas></div> - </template> + <a-divider>{{ i18n "pages.inbounds.client" }}</a-divider> + <template v-for="(row, index) in qrModal.qrcodes"> + <a-tag color="green" style="margin: 10px 0; display: block; text-align: center;">[[ row.remark ]]</a-tag> + <div class="qr-bg"><canvas @click="copyToClipboard('qrCode-'+index, row.link)" :id="'qrCode-'+index" style="width: 100%; height: 100%;"></canvas></div> </template> </a-modal> @@ -29,14 +27,12 @@ qrcodes: [], clipboard: null, visible: false, - isJustSub: false, subId: '', - show: function (title = '', dbInbound, client, isJustSub = false) { + show: function (title = '', dbInbound, client) { this.title = title; this.dbInbound = dbInbound; this.inbound = dbInbound.toInbound(); this.client = client; - this.isJustSub = isJustSub; this.subId = ''; this.qrcodes = []; this.inbound.genAllLinks(this.dbInbound.remark, app.remarkModel, client).forEach(l => { @@ -57,9 +53,6 @@ el: '#qrcode-modal', data: { qrModal: qrModal, - get isJustSub(){ - return qrModal.isJustSub - } }, methods: { copyToClipboard(elmentId, content) { diff --git a/web/html/xui/client_modal.html b/web/html/xui/client_modal.html index cb15e1e7..4b270607 100644 --- a/web/html/xui/client_modal.html +++ b/web/html/xui/client_modal.html @@ -15,16 +15,8 @@ confirmLoading: false, title: '', okText: '', - group: { - canGroup: true, - isGroup: false, - currentClient: null, - inbounds: [], - clients: [], - editIds: [] - }, + isEdit: false, dbInbound: new DBInbound(), - dbInbounds: null, inbound: new Inbound(), clients: [], clientStats: [], @@ -33,137 +25,33 @@ clientIps: null, delayedStart: false, ok() { - if (clientModal.group.isGroup && clientModal.group.canGroup) { - const currentClient = clientModal.group.currentClient; - - clientModal.group.clients.forEach((client, index) => { - const { email, limitIp, totalGB, expiryTime, reset, enable, subId, tgId, flow } = currentClient; - - const match = email.match(/^(.*?)__/); - const new_email = match ? match[1] : email; - - client.email = `${new_email}__${index + 1}`; - client.limitIp = limitIp; - client.totalGB = totalGB; - client.expiryTime = expiryTime; - client.reset = reset; - client.enable = enable; - - if (subId) { - client.subId = subId; - } - if (tgId) { - client.tgId = tgId; - } - if (flow) { - client.flow = flow; - } - }); - - if (clientModal.isEdit) { - ObjectUtil.execute(clientModal.confirm, clientModal.group.clients, clientModal.group.inbounds, clientModal.group.editIds); - }else{ - ObjectUtil.execute(clientModal.confirm, clientModal.group.clients, clientModal.group.inbounds); - } + if (clientModal.isEdit) { + ObjectUtil.execute(clientModal.confirm, clientModalApp.client, clientModal.dbInbound.id, clientModal.oldClientId); } else { - if (clientModal.isEdit){ - ObjectUtil.execute(clientModal.confirm, clientModalApp.client, clientModal.dbInbound.id, clientModal.oldClientId); - }else{ - ObjectUtil.execute(clientModal.confirm, clientModalApp.client, clientModal.dbInbound.id); - } + ObjectUtil.execute(clientModal.confirm, clientModalApp.client, clientModal.dbInbound.id); } }, - show({ title = '', okText = '{{ i18n "sure" }}', index = null, dbInbound = null, dbInbounds = null, confirm = () => { }, isEdit = false }) { - this.group = { - canGroup: true, - isGroup: false, - currentClient: null, - inbounds: [], - clients: [], - editIds: [] - } - this.dbInbounds = dbInbounds; + show({ title = '', okText = '{{ i18n "sure" }}', index = null, dbInbound = null, confirm = () => { }, isEdit = false }) { this.visible = true; this.title = title; this.okText = okText; this.isEdit = isEdit; - if (dbInbounds !== null && Array.isArray(dbInbounds)) { - if (isEdit) { - this.showProcess(dbInbound, index); - let processSingleEdit = true - if (this.group.canGroup){ - this.group.currentClient = this.clients[this.index] - const response = this.getGroupInboundsClients(dbInbounds,this.group.currentClient) - if (response.clients.length > 1){ - this.group.isGroup = true; - this.group.inbounds = response.inbounds - this.group.clients = response.clients - this.group.editIds = response.editIds - if (this.clients[index].expiryTime < 0) { - this.delayedStart = true; - } - processSingleEdit = false - } - } - if(processSingleEdit){ - this.singleEditClientProcess(index) - } - } else { - this.group.isGroup = true; - dbInbounds.forEach((dbInboundItem) => { - this.showProcess(dbInboundItem); - this.addClient(this.inbound.protocol, this.clients); - this.group.inbounds.push(dbInboundItem.id) - this.group.clients.push(this.clients[this.index]) - }) - this.group.currentClient = this.clients[this.index] - } - } else { - this.showProcess(dbInbound, index); - if (isEdit) { - this.singleEditClientProcess(index) - } else { - this.addClient(this.inbound.protocol, this.clients); - } - } - this.clientStats = this.dbInbound.clientStats.find(row => row.email === this.clients[this.index].email); - this.confirm = confirm; - }, - showProcess(dbInbound, index = null) { this.dbInbound = new DBInbound(dbInbound); this.inbound = dbInbound.toInbound(); this.clients = this.inbound.clients; this.index = index === null ? this.clients.length : index; this.delayedStart = false; - }, - singleEditClientProcess(index) { - if (this.clients[index].expiryTime < 0) { - this.delayedStart = true; - } - this.oldClientId = this.getClientId(this.dbInbound.protocol, this.clients[index]); - }, - getGroupInboundsClients(dbInbounds, currentClient) { - const response = { - inbounds: [], - clients: [], - editIds: [] - } - dbInbounds.forEach((dbInboundItem) => { - const dbInbound = new DBInbound(dbInboundItem); - const inbound = dbInbound.toInbound(); - const clients = inbound.clients; - if (clients.length > 0){ - clients.forEach((client) => { - if (client['subId'] === currentClient['subId']){ - response.inbounds.push(dbInboundItem.id) - response.clients.push(client) - response.editIds.push(this.getClientId(dbInbound.protocol, client)) - } - }) + if (isEdit) { + if (this.clients[index].expiryTime < 0) { + this.delayedStart = true; } - }) - return response; - }, + this.oldClientId = this.getClientId(dbInbound.protocol, clients[index]); + } else { + this.addClient(this.inbound.protocol, this.clients); + } + this.clientStats = this.dbInbound.clientStats.find(row => row.email === this.clients[this.index].email); + this.confirm = confirm; + }, getClientId(protocol, client) { switch (protocol) { case Protocols.TROJAN: return client.password; @@ -206,18 +94,6 @@ get isEdit() { return this.clientModal.isEdit; }, - get isGroup() { - return this.clientModal.group.isGroup; - }, - get isGroupEdit() { - return this.clientModal.group.canGroup; - }, - set isGroupEdit(value) { - this.clientModal.group.canGroup = value; - if (!value){ - this.clientModal.singleEditClientProcess(this.clientModal.index) - } - }, get datepicker() { return app.datepicker; }, diff --git a/web/html/xui/form/client.html b/web/html/xui/form/client.html index 526bbb8b..63cb8aef 100644 --- a/web/html/xui/form/client.html +++ b/web/html/xui/form/client.html @@ -3,18 +3,6 @@ <a-form-item label='{{ i18n "pages.inbounds.enable" }}'> <a-switch v-model="client.enable"></a-switch> </a-form-item> - <a-form-item v-if="isEdit && app.subSettings.enable && isGroup"> - <template slot="label"> - <a-tooltip> - <template slot="title"> - <span>{{ i18n "pages.inbounds.isGroupEditDesc" }}</span> - </template> - {{ i18n "pages.inbounds.isGroupEdit" }} - <a-icon type="question-circle"></a-icon> - </a-tooltip> - </template> - <a-switch v-model="isGroupEdit"></a-switch> - </a-form-item> <a-form-item> <template slot="label"> <a-tooltip> @@ -27,7 +15,7 @@ </template> <a-input v-model.trim="client.email"></a-input> </a-form-item> - <a-form-item v-if="(inbound.protocol === Protocols.TROJAN || inbound.protocol === Protocols.SHADOWSOCKS) && !isGroup"> + <a-form-item v-if="inbound.protocol === Protocols.TROJAN || inbound.protocol === Protocols.SHADOWSOCKS"> <template slot="label"> <a-tooltip> <template slot="title"> @@ -40,7 +28,7 @@ </template> <a-input v-model.trim="client.password"></a-input> </a-form-item> - <a-form-item v-if="(inbound.protocol === Protocols.VMESS || inbound.protocol === Protocols.VLESS) && !isGroup"> + <a-form-item v-if="inbound.protocol === Protocols.VMESS || inbound.protocol === Protocols.VLESS"> <template slot="label"> <a-tooltip> <template slot="title"> diff --git a/web/html/xui/inbound_modal.html b/web/html/xui/inbound_modal.html index 7f9ed740..ab42e09c 100644 --- a/web/html/xui/inbound_modal.html +++ b/web/html/xui/inbound_modal.html @@ -13,7 +13,6 @@ confirmLoading: false, okText: '{{ i18n "sure" }}', isEdit: false, - isGroup: false, confirm: null, inbound: new Inbound(), dbInbound: new DBInbound(), @@ -61,9 +60,6 @@ get isEdit() { return inModal.isEdit; }, - get isGroup() { - return inModal.isGroup; - }, get client() { return inModal.inbound.clients[0]; }, diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 2707fc42..c986e3fd 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -145,10 +145,6 @@ <a-icon type="rest"></a-icon> {{ i18n "pages.inbounds.delDepletedClients" }} </a-menu-item> - <a-menu-item v-if="subSettings.enable && dbInbounds.length > 0" key="addGroupClient"> - <a-icon type="usergroup-add"></a-icon> - {{ i18n "pages.client.groupAdd"}} - </a-menu-item> </a-menu> </a-dropdown> </a-col> @@ -289,7 +285,7 @@ <p v-for="clientEmail in clientCount[dbInbound.id].online">[[ clientEmail ]]</p> </template> <a-tag style="margin:0; padding: 0 2px;" color="blue" v-if="clientCount[dbInbound.id].online.length">[[ clientCount[dbInbound.id].online.length ]]</a-tag> - </a-popover> + </a-popover> </template> </template> <template slot="traffic" slot-scope="text, dbInbound"> @@ -343,7 +339,7 @@ <a-tag style="margin:0;" color="blue">[[ dbInbound.toInbound().stream.network ]]</a-tag> <a-tag style="margin:0;" v-if="dbInbound.toInbound().stream.isTls" color="green">tls</a-tag> <a-tag style="margin:0;" v-if="dbInbound.toInbound().stream.isReality" color="green">reality</a-tag> - </template> + </template> </td> </tr> <tr> @@ -377,7 +373,7 @@ <p v-for="clientEmail in clientCount[dbInbound.id].online">[[ clientEmail ]]</p> </template> <a-tag style="margin:0; padding: 0 2px;" color="green" v-if="clientCount[dbInbound.id].online.length">[[ clientCount[dbInbound.id].online.length ]]</a-tag> - </a-popover> + </a-popover> </td> </tr> <tr> @@ -744,9 +740,6 @@ case "delDepletedClients": this.delDepletedClients(-1) break; - case "addGroupClient": - this.openGroupAddClient() - break; } }, clickAction(action, dbInbound) { @@ -890,20 +883,6 @@ await this.submit(`/panel/inbound/update/${dbInbound.id}`, data, inModal); }, - openGroupAddClient() { - clientModal.show({ - title: '{{ i18n "pages.client.groupAdd"}}', - okText: '{{ i18n "pages.client.submitAdd"}}', - dbInbounds: this.dbInbounds, - confirm: async (clients, dbInboundIds) => { - clientModal.loading(); - await this.addGroupClient(clients, dbInboundIds); - clientModal.close(); - await this.showQrcode(dbInboundIds[0],clients[0], true) - }, - isEdit: false - }); - }, openAddClient(dbInboundId) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); clientModal.show({ @@ -914,7 +893,6 @@ clientModal.loading(); await this.addClient(clients, dbInboundId); clientModal.close(); - await this.showQrcode(dbInboundId,clients) }, isEdit: false }); @@ -939,7 +917,6 @@ clientModal.show({ title: '{{ i18n "pages.client.edit"}}', okText: '{{ i18n "pages.client.submitEdit"}}', - dbInbounds: this.dbInbounds, dbInbound: dbInbound, index: index, confirm: async (client, dbInboundId, clientId) => { @@ -963,41 +940,14 @@ id: dbInboundId, settings: '{"clients": [' + clients.toString() + ']}', }; - - await this.submit(`/panel/inbound/addClient`, data) - }, - - async addGroupClient(clients, dbInboundIds) { - const data = [] - dbInboundIds.forEach((dbInboundId, index) => { - data.push({ - id: dbInboundId, - settings: '{"clients": [' + clients[index].toString() + ']}', - }) - }) - - await this.submit(`/panel/inbound/addGroupClient`, data, true) + await this.submit(`/panel/inbound/addClient`, data); }, async updateClient(client, dbInboundId, clientId) { - if (Array.isArray(client) && Array.isArray(dbInboundId) && Array.isArray(clientId)){ - const data = [] - client.forEach((client, index) => { - data.push({ - clientId: clientId[index], - inbound: { - id: dbInboundId[index], - settings: '{"clients": [' + client.toString() + ']}', - } - }) - }) - await this.submit(`/panel/inbound/updateClients`, data, true); - }else{ - const data = { - id: dbInboundId, - settings: '{"clients": [' + client.toString() + ']}', - }; - await this.submit(`/panel/inbound/updateClient/${clientId}`, data); - } + const data = { + id: dbInboundId, + settings: '{"clients": [' + client.toString() + ']}', + }; + await this.submit(`/panel/inbound/updateClient/${clientId}`, data); }, resetTraffic(dbInboundId) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); @@ -1051,8 +1001,8 @@ checkFallback(dbInbound) { newDbInbound = new DBInbound(dbInbound); if (dbInbound.listen.startsWith("@")){ - rootInbound = this.inbounds.find((i) => - i.isTcp && + rootInbound = this.inbounds.find((i) => + i.isTcp && ['trojan','vless'].includes(i.protocol) && i.settings.fallbacks.find(f => f.dest === dbInbound.listen) ); @@ -1068,10 +1018,10 @@ } return newDbInbound; }, - showQrcode(dbInboundId, client, isJustSub = false) { + showQrcode(dbInboundId, client) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); newDbInbound = this.checkFallback(dbInbound); - qrModal.show('{{ i18n "qrCode"}}', newDbInbound, client, isJustSub); + qrModal.show('{{ i18n "qrCode"}}', newDbInbound, client); }, showInfo(dbInboundId, client) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); @@ -1100,8 +1050,8 @@ await this.updateClient(clients[index], dbInboundId, clientId); this.loading(false); }, - async submit(url, data, isJson = false) { - const msg = isJson ? await HttpUtil.postWithModalJson(url, data) : await HttpUtil.postWithModal(url, data); + async submit(url, data) { + const msg = await HttpUtil.postWithModal(url, data); if (msg.success) { await this.getDBInbounds(); } @@ -1243,7 +1193,7 @@ value: '', okText: '{{ i18n "pages.inbounds.import" }}', confirm: async (dbInboundText) => { - await this.submit('/panel/inbound/import', {data: dbInboundText}); + await this.submit('/panel/inbound/import', {data: dbInboundText}, promptModal); promptModal.close(); }, }); |
