Files
trihuy-russian/web/html/xui/inbound_modal.html
T

145 lines
5.3 KiB
HTML
Raw Normal View History

2023-02-09 22:48:06 +03:30
{{define "inboundModal"}}
2024-03-11 16:14:24 +03:30
<a-modal id="inbound-modal" v-model="inModal.visible" :title="inModal.title"
:dialog-style="{ top: '20px' }" @ok="inModal.ok"
:confirm-loading="inModal.confirmLoading" :closable="true" :mask-closable="false"
:class="themeSwitcher.currentTheme"
:ok-text="inModal.okText" cancel-text='{{ i18n "close" }}'>
2023-02-09 22:48:06 +03:30
{{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(),
ok() {
ObjectUtil.execute(inModal.confirm, inModal.inbound, inModal.dbInbound);
},
2023-05-08 19:14:22 +04:30
show({ title = '', okText = '{{ i18n "sure" }}', inbound = null, dbInbound = null, confirm = (inbound, dbInbound) => {}, isEdit = false }) {
2023-02-09 22:48:06 +03:30
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);
},
2024-02-21 15:09:56 +03:30
loading(loading=true) {
2023-02-09 22:48:06 +03:30
inModal.confirmLoading = loading;
},
};
new Vue({
delimiters: ['[[', ']]'],
el: '#inbound-modal',
data: {
inModal: inModal,
2023-04-18 21:34:06 +03:30
delayedStart: false,
2023-02-09 22:48:06 +03:30
get inbound() {
return inModal.inbound;
},
get dbInbound() {
return inModal.dbInbound;
},
get isEdit() {
return inModal.isEdit;
},
2023-04-18 21:34:06 +03:30
get client() {
2023-12-08 18:45:21 +01:00
return inModal.inbound.clients[0];
2023-02-09 22:48:06 +03:30
},
2024-01-02 09:32:21 +01:00
get datepicker() {
return app.datepicker;
},
2023-04-18 21:34:06 +03:30
get delayedExpireDays() {
return this.client && this.client.expiryTime < 0 ? this.client.expiryTime / -86400000 : 0;
2023-02-09 22:48:06 +03:30
},
2023-05-08 19:14:22 +04:30
set delayedExpireDays(days) {
2023-04-18 21:34:06 +03:30
this.client.expiryTime = -86400000 * days;
2023-02-09 22:48:06 +03:30
},
2023-12-08 18:45:21 +01:00
get externalProxy() {
return this.inbound.stream.externalProxy.length > 0;
2023-05-22 17:31:41 +03:30
},
2023-12-08 18:45:21 +01:00
set externalProxy(value) {
2023-05-22 17:31:41 +03:30
if (value) {
2023-12-08 18:45:21 +01:00
inModal.inbound.stream.externalProxy = [{
forceTls: "same",
dest: window.location.hostname,
port: inModal.inbound.port,
remark: ""
}];
2023-05-22 17:31:41 +03:30
} else {
2023-12-08 18:45:21 +01:00
inModal.inbound.stream.externalProxy = [];
2023-05-22 17:31:41 +03:30
}
}
2023-04-18 21:34:06 +03:30
},
methods: {
streamNetworkChange() {
2023-12-08 16:46:44 +01:00
if (!inModal.inbound.canEnableTls()) {
2023-04-18 21:34:06 +03:30
this.inModal.inbound.stream.security = 'none';
}
if (!inModal.inbound.canEnableReality()) {
this.inModal.inbound.reality = false;
}
if (this.inModal.inbound.protocol == Protocols.VLESS && !inModal.inbound.canEnableTlsFlow()) {
this.inModal.inbound.settings.vlesses.forEach(client => {
client.flow = "";
2023-12-13 19:27:36 +03:30
});
}
2023-02-09 22:48:06 +03:30
},
2023-07-18 03:19:01 +03:30
SSMethodChange() {
if (this.inModal.inbound.isSSMultiUser) {
if (this.inModal.inbound.settings.shadowsockses.length ==0){
this.inModal.inbound.settings.shadowsockses = [new Inbound.ShadowsocksSettings.Shadowsocks()];
}
2023-08-26 16:01:02 +03:30
if (!this.inModal.inbound.isSS2022) {
2023-07-27 11:58:12 +03:30
this.inModal.inbound.settings.shadowsockses.forEach(client => {
client.method = this.inModal.inbound.settings.method;
})
} else {
this.inModal.inbound.settings.shadowsockses.forEach(client => {
client.method = "";
})
}
2023-07-18 03:19:01 +03:30
} else {
if (this.inModal.inbound.settings.shadowsockses.length > 0){
this.inModal.inbound.settings.shadowsockses = [];
}
}
},
2023-05-17 00:55:19 +03:30
setDefaultCertData(index) {
inModal.inbound.stream.tls.certs[index].certFile = app.defaultCert;
inModal.inbound.stream.tls.certs[index].keyFile = app.defaultKey;
2023-04-09 23:13:18 +03:30
},
2023-05-08 19:14:22 +04:30
async getNewX25519Cert() {
2023-04-18 21:34:06 +03:30
inModal.loading(true);
const msg = await HttpUtil.post('/server/getNewX25519Cert');
inModal.loading(false);
if (!msg.success) {
return;
}
inModal.inbound.stream.reality.privateKey = msg.obj.privateKey;
inModal.inbound.stream.reality.settings.publicKey = msg.obj.publicKey;
2023-02-09 22:48:06 +03:30
}
},
});
</script>
2023-03-17 19:37:49 +03:30
{{end}}