mirror of
https://github.com/alireza0/x-ui.git
synced 2026-03-14 05:23:09 +00:00
151 lines
4.8 KiB
HTML
151 lines
4.8 KiB
HTML
{{define "inboundModal"}}
|
|
<a-modal id="inbound-modal" v-model="inModal.visible" :title="inModal.title" @ok="inModal.ok"
|
|
:confirm-loading="inModal.confirmLoading" :closable="true" :mask-closable="false"
|
|
:ok-text="inModal.okText" cancel-text='{{ i18n "close" }}'>
|
|
{{template "form/inbound"}}
|
|
</a-modal>
|
|
<script>
|
|
|
|
const inModal = {
|
|
title: '',
|
|
visible: false,
|
|
confirmLoading: false,
|
|
okText: '{{ i18n "sure" }}',
|
|
isEdit: false,
|
|
confirm: null,
|
|
inbound: new Inbound(),
|
|
dbInbound: new DBInbound(),
|
|
clientIps: [],
|
|
ok() {
|
|
ObjectUtil.execute(inModal.confirm, inModal.inbound, inModal.dbInbound);
|
|
},
|
|
show({ title='', okText='{{ i18n "sure" }}', inbound=null, dbInbound=null, confirm=(inbound, dbInbound)=>{}, isEdit=false }) {
|
|
this.title = title;
|
|
this.okText = okText;
|
|
if (inbound) {
|
|
this.inbound = Inbound.fromJson(inbound.toJson());
|
|
} else {
|
|
this.inbound = new Inbound();
|
|
}
|
|
if (dbInbound) {
|
|
this.dbInbound = new DBInbound(dbInbound);
|
|
} else {
|
|
this.dbInbound = new DBInbound();
|
|
}
|
|
this.confirm = confirm;
|
|
this.visible = true;
|
|
this.isEdit = isEdit;
|
|
},
|
|
close() {
|
|
inModal.visible = false;
|
|
inModal.loading(false);
|
|
},
|
|
loading(loading) {
|
|
inModal.confirmLoading = loading;
|
|
},
|
|
};
|
|
|
|
const protocols = {
|
|
VMESS: Protocols.VMESS,
|
|
VLESS: Protocols.VLESS,
|
|
TROJAN: Protocols.TROJAN,
|
|
SHADOWSOCKS: Protocols.SHADOWSOCKS,
|
|
DOKODEMO: Protocols.DOKODEMO,
|
|
SOCKS: Protocols.SOCKS,
|
|
HTTP: Protocols.HTTP,
|
|
};
|
|
|
|
new Vue({
|
|
delimiters: ['[[', ']]'],
|
|
el: '#inbound-modal',
|
|
data: {
|
|
inModal: inModal,
|
|
Protocols: protocols,
|
|
SSMethods: SSMethods,
|
|
get inbound() {
|
|
return inModal.inbound;
|
|
},
|
|
get dbInbound() {
|
|
return inModal.dbInbound;
|
|
},
|
|
get clientIps() {
|
|
return inModal.clientIps;
|
|
},
|
|
get isEdit() {
|
|
return inModal.isEdit;
|
|
}
|
|
},
|
|
methods: {
|
|
streamNetworkChange(oldValue) {
|
|
if (oldValue === 'kcp') {
|
|
this.inModal.inbound.tls = false;
|
|
}
|
|
},
|
|
addClient(protocol,value, clients) {
|
|
switch (protocol) {
|
|
case Protocols.VMESS: return clients.push(new Inbound.VmessSettings.Vmess());
|
|
case Protocols.VLESS: return clients.push(new Inbound.VLESSSettings.VLESS());
|
|
default: return null;
|
|
}
|
|
},
|
|
removeClient(index, clients) {
|
|
clients.splice(index, 1);
|
|
},
|
|
|
|
async getDBClientIps(index, email) {
|
|
|
|
const msg = await HttpUtil.post('/xui/inbound/clientIps/'+ email);
|
|
if (!msg.success) {
|
|
return;
|
|
}
|
|
try {
|
|
ips = JSON.parse(msg.obj)
|
|
ips = ips.join(",")
|
|
this.inModal.clientIps[index] = ips
|
|
} catch (error) {
|
|
// text
|
|
this.inModal.clientIps[index] = msg.obj
|
|
|
|
}
|
|
|
|
},
|
|
async clearDBClientIps(email) {
|
|
const msg = await HttpUtil.post('/xui/inbound/clearClientIps/'+ email);
|
|
if (!msg.success) {
|
|
return;
|
|
}
|
|
this.inModal.clientIps = ""
|
|
},
|
|
getIPsByIndex(index) {
|
|
return inModal.clientIps[index]
|
|
},
|
|
|
|
},
|
|
updated() {
|
|
switch (inModal.inbound.protocol) {
|
|
case Protocols.VMESS:
|
|
vmesses = inModal.inbound.settings.vmesses
|
|
for (const index in vmesses) {
|
|
if(vmesses[index].email)
|
|
this.getDBClientIps(index, vmesses[index].email)
|
|
}
|
|
break;
|
|
case Protocols.VLESS:
|
|
vlesses = inModal.inbound.settings.vlesses
|
|
|
|
for (const index in vlesses) {
|
|
if(vlesses[index].email)
|
|
this.getDBClientIps(index, vlesses[index].email)
|
|
|
|
}
|
|
break;
|
|
default: return null;
|
|
}
|
|
console.log(this.inModal.clientIps)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
{{end}} |