mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
Merge 7b3c62b916
into be8d55dadb
This commit is contained in:
commit
f9c8f5e1b5
14 changed files with 161 additions and 11 deletions
|
@ -1,10 +1,9 @@
|
||||||
{{define "modals/qrcodeModal"}}
|
{{define "modals/qrcodeModal"}}
|
||||||
<a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title"
|
<a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title"
|
||||||
:dialog-style="isMobile ? { top: '18px' } : {}"
|
:dialog-style="isMobile ? { top: '18px' } : {}" :closable="true" :class="themeSwitcher.currentTheme" :footer="null"
|
||||||
:closable="true"
|
width="fit-content">
|
||||||
:class="themeSwitcher.currentTheme"
|
|
||||||
:footer="null" width="fit-content">
|
|
||||||
<tr-qr-modal class="qr-modal">
|
<tr-qr-modal class="qr-modal">
|
||||||
|
|
||||||
<template v-if="app.subSettings.enable && qrModal.subId">
|
<template v-if="app.subSettings.enable && qrModal.subId">
|
||||||
<tr-qr-box class="qr-box">
|
<tr-qr-box class="qr-box">
|
||||||
<a-tag color="purple" class="qr-tag"><span>{{ i18n "pages.settings.subSettings"}}</span></a-tag>
|
<a-tag color="purple" class="qr-tag"><span>{{ i18n "pages.settings.subSettings"}}</span></a-tag>
|
||||||
|
@ -25,6 +24,18 @@
|
||||||
</template>
|
</template>
|
||||||
<template v-for="(row, index) in qrModal.qrcodes">
|
<template v-for="(row, index) in qrModal.qrcodes">
|
||||||
<tr-qr-box class="qr-box">
|
<tr-qr-box class="qr-box">
|
||||||
|
<div style="display: flex; align-items: center; margin-bottom: 8px;">
|
||||||
|
<span>{{ i18n "useIPv4ForHost" }}: </span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
role="switch"
|
||||||
|
:aria-checked="row.useIPv4"
|
||||||
|
:class="['ant-switch', 'ant-switch-small', { 'ant-switch-checked': row.useIPv4 }]"
|
||||||
|
@click="toggleIPv4(index)"
|
||||||
|
style="margin-left: 8px;">
|
||||||
|
<span class="ant-switch-inner"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<a-tag color="green" class="qr-tag"><span>[[ row.remark ]]</span></a-tag>
|
<a-tag color="green" class="qr-tag"><span>[[ row.remark ]]</span></a-tag>
|
||||||
<tr-qr-bg class="qr-bg">
|
<tr-qr-bg class="qr-bg">
|
||||||
<canvas @click="copy(row.link)" :id="'qrCode-'+index" class="qr-cv"></canvas>
|
<canvas @click="copy(row.link)" :id="'qrCode-'+index" class="qr-cv"></canvas>
|
||||||
|
@ -34,6 +45,53 @@
|
||||||
</tr-qr-modal>
|
</tr-qr-modal>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.ant-table:not(.ant-table-expanded-row .ant-table) {
|
||||||
|
outline: 1px solid #f0f0f0;
|
||||||
|
outline-offset: -1px;
|
||||||
|
border-radius: 1rem;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* QR code transition effects */
|
||||||
|
.qr-cv {
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-transition-enter-active, .qr-transition-leave-active {
|
||||||
|
transition: opacity 0.3s, transform 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-transition-enter, .qr-transition-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-transition-enter-to, .qr-transition-leave {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-flash {
|
||||||
|
animation: qr-flash-animation 0.6s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes qr-flash-animation {
|
||||||
|
0% {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
opacity: 0.5;
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const qrModal = {
|
const qrModal = {
|
||||||
title: '',
|
title: '',
|
||||||
|
@ -49,18 +107,24 @@
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.subId = '';
|
this.subId = '';
|
||||||
this.qrcodes = [];
|
this.qrcodes = [];
|
||||||
|
// Reset the status fetched flag when showing the modal
|
||||||
|
if (qrModalApp) qrModalApp.statusFetched = false;
|
||||||
if (this.inbound.protocol == Protocols.WIREGUARD) {
|
if (this.inbound.protocol == Protocols.WIREGUARD) {
|
||||||
this.inbound.genInboundLinks(dbInbound.remark).split('\r\n').forEach((l, index) => {
|
this.inbound.genInboundLinks(dbInbound.remark).split('\r\n').forEach((l, index) => {
|
||||||
this.qrcodes.push({
|
this.qrcodes.push({
|
||||||
remark: "Peer " + (index + 1),
|
remark: "Peer " + (index + 1),
|
||||||
link: l
|
link: l,
|
||||||
|
useIPv4: false,
|
||||||
|
originalLink: l
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.inbound.genAllLinks(this.dbInbound.remark, app.remarkModel, client).forEach(l => {
|
this.inbound.genAllLinks(this.dbInbound.remark, app.remarkModel, client).forEach(l => {
|
||||||
this.qrcodes.push({
|
this.qrcodes.push({
|
||||||
remark: l.remark,
|
remark: l.remark,
|
||||||
link: l.link
|
link: l.link,
|
||||||
|
useIPv4: false,
|
||||||
|
originalLink: l.link
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -76,8 +140,72 @@
|
||||||
mixins: [MediaQueryMixin],
|
mixins: [MediaQueryMixin],
|
||||||
data: {
|
data: {
|
||||||
qrModal: qrModal,
|
qrModal: qrModal,
|
||||||
|
serverStatus: null,
|
||||||
|
statusFetched: false,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async getStatus() {
|
||||||
|
try {
|
||||||
|
const msg = await HttpUtil.post('/server/status');
|
||||||
|
if (msg.success) {
|
||||||
|
this.serverStatus = msg.obj;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to get status:", e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleIPv4(index) {
|
||||||
|
const row = qrModal.qrcodes[index];
|
||||||
|
row.useIPv4 = !row.useIPv4;
|
||||||
|
this.updateLink(index);
|
||||||
|
},
|
||||||
|
updateLink(index) {
|
||||||
|
const row = qrModal.qrcodes[index];
|
||||||
|
if (!this.serverStatus || !this.serverStatus.publicIP) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row.useIPv4 && this.serverStatus.publicIP.ipv4) {
|
||||||
|
// Replace the hostname or IP in the link with the IPv4 address
|
||||||
|
const originalLink = row.originalLink;
|
||||||
|
const url = new URL(originalLink);
|
||||||
|
const ipv4 = this.serverStatus.publicIP.ipv4;
|
||||||
|
|
||||||
|
if (qrModal.inbound.protocol == Protocols.WIREGUARD) {
|
||||||
|
// Special handling for WireGuard config
|
||||||
|
const endpointRegex = /Endpoint = ([^:]+):(\d+)/;
|
||||||
|
const match = originalLink.match(endpointRegex);
|
||||||
|
if (match) {
|
||||||
|
row.link = originalLink.replace(
|
||||||
|
`Endpoint = ${match[1]}:${match[2]}`,
|
||||||
|
`Endpoint = ${ipv4}:${match[2]}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// For other protocols using URL format
|
||||||
|
url.hostname = ipv4;
|
||||||
|
row.link = url.toString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Restore original link
|
||||||
|
row.link = row.originalLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update QR code with transition effect
|
||||||
|
const canvasElement = document.querySelector('#qrCode-' + index);
|
||||||
|
if (canvasElement) {
|
||||||
|
// Add flash animation class
|
||||||
|
canvasElement.classList.add('qr-flash');
|
||||||
|
|
||||||
|
// Remove the class after animation completes
|
||||||
|
setTimeout(() => {
|
||||||
|
canvasElement.classList.remove('qr-flash');
|
||||||
|
}, 600);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setQrCode("qrCode-" + index, row.link);
|
||||||
|
},
|
||||||
copy(content) {
|
copy(content) {
|
||||||
ClipboardManager
|
ClipboardManager
|
||||||
.copyText(content)
|
.copyText(content)
|
||||||
|
@ -117,8 +245,14 @@
|
||||||
updated() {
|
updated() {
|
||||||
if (this.qrModal.visible) {
|
if (this.qrModal.visible) {
|
||||||
fixOverflow();
|
fixOverflow();
|
||||||
|
if (!this.statusFetched) {
|
||||||
|
this.getStatus();
|
||||||
|
this.statusFetched = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.revertOverflow();
|
this.revertOverflow();
|
||||||
|
// Reset the flag when modal is closed so it will fetch again next time
|
||||||
|
this.statusFetched = false;
|
||||||
}
|
}
|
||||||
if (qrModal.client && qrModal.client.subId) {
|
if (qrModal.client && qrModal.client.subId) {
|
||||||
qrModal.subId = qrModal.client.subId;
|
qrModal.subId = qrModal.client.subId;
|
||||||
|
@ -127,6 +261,10 @@
|
||||||
}
|
}
|
||||||
qrModal.qrcodes.forEach((element, index) => {
|
qrModal.qrcodes.forEach((element, index) => {
|
||||||
this.setQrCode("qrCode-" + index, element.link);
|
this.setQrCode("qrCode-" + index, element.link);
|
||||||
|
// Update links based on current toggle state
|
||||||
|
if (element.useIPv4 && this.serverStatus && this.serverStatus.publicIP) {
|
||||||
|
this.updateLink(index);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -142,8 +280,7 @@
|
||||||
|
|
||||||
function wrapContentsInMarquee(element) {
|
function wrapContentsInMarquee(element) {
|
||||||
element.classList.add("tr-marquee");
|
element.classList.add("tr-marquee");
|
||||||
element.children[0].style.animation = `move-ltr ${
|
element.children[0].style.animation = `move-ltr ${(element.children[0].clientWidth / element.clientWidth) * 5
|
||||||
(element.children[0].clientWidth / element.clientWidth) * 5
|
|
||||||
}s ease-in-out infinite`;
|
}s ease-in-out infinite`;
|
||||||
const marqueeText = element.children[0];
|
const marqueeText = element.children[0];
|
||||||
if (element.children.length < 2) {
|
if (element.children.length < 2) {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "اتنسخ بنجاح"
|
"copySuccess" = "اتنسخ بنجاح"
|
||||||
"sure" = "متأكد؟"
|
"sure" = "متأكد؟"
|
||||||
"encryption" = "تشفير"
|
"encryption" = "تشفير"
|
||||||
|
"useIPv4ForHost" = "استخدم IPv4 للمضيف"
|
||||||
"transmission" = "نقل"
|
"transmission" = "نقل"
|
||||||
"host" = "المستضيف"
|
"host" = "المستضيف"
|
||||||
"path" = "مسار"
|
"path" = "مسار"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "Copied Successful"
|
"copySuccess" = "Copied Successful"
|
||||||
"sure" = "Sure"
|
"sure" = "Sure"
|
||||||
"encryption" = "Encryption"
|
"encryption" = "Encryption"
|
||||||
|
"useIPv4ForHost" = "Use IPv4 for host"
|
||||||
"transmission" = "Transmission"
|
"transmission" = "Transmission"
|
||||||
"host" = "Host"
|
"host" = "Host"
|
||||||
"path" = "Path"
|
"path" = "Path"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "Copiado exitosamente"
|
"copySuccess" = "Copiado exitosamente"
|
||||||
"sure" = "Seguro"
|
"sure" = "Seguro"
|
||||||
"encryption" = "Encriptación"
|
"encryption" = "Encriptación"
|
||||||
|
"useIPv4ForHost" = "Usar IPv4 para el host"
|
||||||
"transmission" = "Transmisión"
|
"transmission" = "Transmisión"
|
||||||
"host" = "Anfitrión"
|
"host" = "Anfitrión"
|
||||||
"path" = "Ruta"
|
"path" = "Ruta"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "باموفقیت کپیشد"
|
"copySuccess" = "باموفقیت کپیشد"
|
||||||
"sure" = "مطمئن"
|
"sure" = "مطمئن"
|
||||||
"encryption" = "رمزگذاری"
|
"encryption" = "رمزگذاری"
|
||||||
|
"useIPv4ForHost" = "از IPv4 برای میزبان استفاده کنید"
|
||||||
"transmission" = "راهاتصال"
|
"transmission" = "راهاتصال"
|
||||||
"host" = "آدرس"
|
"host" = "آدرس"
|
||||||
"path" = "مسیر"
|
"path" = "مسیر"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "Berhasil Disalin"
|
"copySuccess" = "Berhasil Disalin"
|
||||||
"sure" = "Yakin"
|
"sure" = "Yakin"
|
||||||
"encryption" = "Enkripsi"
|
"encryption" = "Enkripsi"
|
||||||
|
"useIPv4ForHost" = "Gunakan IPv4 untuk host"
|
||||||
"transmission" = "Transmisi"
|
"transmission" = "Transmisi"
|
||||||
"host" = "Host"
|
"host" = "Host"
|
||||||
"path" = "Jalur"
|
"path" = "Jalur"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "コピー成功"
|
"copySuccess" = "コピー成功"
|
||||||
"sure" = "確定"
|
"sure" = "確定"
|
||||||
"encryption" = "暗号化"
|
"encryption" = "暗号化"
|
||||||
|
"useIPv4ForHost" = "ホストにIPv4を使用"
|
||||||
"transmission" = "伝送"
|
"transmission" = "伝送"
|
||||||
"host" = "ホスト"
|
"host" = "ホスト"
|
||||||
"path" = "パス"
|
"path" = "パス"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "Copiado com Sucesso"
|
"copySuccess" = "Copiado com Sucesso"
|
||||||
"sure" = "Certo"
|
"sure" = "Certo"
|
||||||
"encryption" = "Criptografia"
|
"encryption" = "Criptografia"
|
||||||
|
"useIPv4ForHost" = "Usar IPv4 para o host"
|
||||||
"transmission" = "Transmissão"
|
"transmission" = "Transmissão"
|
||||||
"host" = "Servidor"
|
"host" = "Servidor"
|
||||||
"path" = "Caminho"
|
"path" = "Caminho"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "Скопировано"
|
"copySuccess" = "Скопировано"
|
||||||
"sure" = "Да"
|
"sure" = "Да"
|
||||||
"encryption" = "Шифрование"
|
"encryption" = "Шифрование"
|
||||||
|
"useIPv4ForHost" = "Использовать IPv4 для хоста"
|
||||||
"transmission" = "Протокол"
|
"transmission" = "Протокол"
|
||||||
"host" = "Хост"
|
"host" = "Хост"
|
||||||
"path" = "Путь"
|
"path" = "Путь"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "Başarıyla Kopyalandı"
|
"copySuccess" = "Başarıyla Kopyalandı"
|
||||||
"sure" = "Emin misiniz"
|
"sure" = "Emin misiniz"
|
||||||
"encryption" = "Şifreleme"
|
"encryption" = "Şifreleme"
|
||||||
|
"useIPv4ForHost" = "Ana bilgisayar için IPv4 kullan"
|
||||||
"transmission" = "İletim"
|
"transmission" = "İletim"
|
||||||
"host" = "Sunucu"
|
"host" = "Sunucu"
|
||||||
"path" = "Yol"
|
"path" = "Yol"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "Скопійовано успішно"
|
"copySuccess" = "Скопійовано успішно"
|
||||||
"sure" = "Звичайно"
|
"sure" = "Звичайно"
|
||||||
"encryption" = "Шифрування"
|
"encryption" = "Шифрування"
|
||||||
|
"useIPv4ForHost" = "Використовувати IPv4 для хоста"
|
||||||
"transmission" = "Протокол передачи"
|
"transmission" = "Протокол передачи"
|
||||||
"host" = "Хост"
|
"host" = "Хост"
|
||||||
"path" = "Шлях"
|
"path" = "Шлях"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "Đã sao chép thành công"
|
"copySuccess" = "Đã sao chép thành công"
|
||||||
"sure" = "Chắc chắn"
|
"sure" = "Chắc chắn"
|
||||||
"encryption" = "Mã hóa"
|
"encryption" = "Mã hóa"
|
||||||
|
"useIPv4ForHost" = "Sử dụng IPv4 cho máy chủ"
|
||||||
"transmission" = "Truyền tải"
|
"transmission" = "Truyền tải"
|
||||||
"host" = "Máy chủ"
|
"host" = "Máy chủ"
|
||||||
"path" = "Đường dẫn"
|
"path" = "Đường dẫn"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "复制成功"
|
"copySuccess" = "复制成功"
|
||||||
"sure" = "确定"
|
"sure" = "确定"
|
||||||
"encryption" = "加密"
|
"encryption" = "加密"
|
||||||
|
"useIPv4ForHost" = "使用 IPv4 连接主机"
|
||||||
"transmission" = "传输"
|
"transmission" = "传输"
|
||||||
"host" = "主机"
|
"host" = "主机"
|
||||||
"path" = "路径"
|
"path" = "路径"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"copySuccess" = "複製成功"
|
"copySuccess" = "複製成功"
|
||||||
"sure" = "確定"
|
"sure" = "確定"
|
||||||
"encryption" = "加密"
|
"encryption" = "加密"
|
||||||
|
"useIPv4ForHost" = "使用 IPv4 連接主機"
|
||||||
"transmission" = "傳輸"
|
"transmission" = "傳輸"
|
||||||
"host" = "主機"
|
"host" = "主機"
|
||||||
"path" = "路徑"
|
"path" = "路徑"
|
||||||
|
|
Loading…
Reference in a new issue