3x-ui/web/html/common/qrcode_modal.html

77 lines
2.5 KiB
HTML
Raw Normal View History

2023-02-09 22:18:06 +03:00
{{define "qrcodeModal"}}
<a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title"
2023-03-24 16:17:14 +03:00
:closable="true"
2023-05-08 17:44:22 +03:00
:class="themeSwitcher.darkCardClass"
2023-03-24 16:17:14 +03:00
:footer="null"
width="300px">
2023-05-08 17:44:22 +03:00
<a-tag color="green" style="margin-bottom: 10px;display: block;text-align: center;">
{{ i18n "pages.inbounds.clickOnQRcode" }}
</a-tag>
2023-05-12 20:23:05 +03:00
<a-tag v-if="qrModal.clientName" color="orange" style="margin-bottom: 10px;display: block;text-align: center;">
{{ i18n "pages.inbounds.email" }}: "[[ qrModal.clientName ]]"
</a-tag>
<canvas @click="copyToClipboard()" id="qrCode" style="width: 100%; height: 100%; margin-top: 10px;"></canvas>
2023-02-09 22:18:06 +03:00
</a-modal>
<script>
const qrModal = {
title: '',
content: '',
inbound: new Inbound(),
dbInbound: new DBInbound(),
copyText: '',
2023-05-12 20:23:05 +03:00
clientName: null,
2023-02-09 22:18:06 +03:00
qrcode: null,
clipboard: null,
visible: false,
2023-05-12 20:23:05 +03:00
show: function (title = '', content = '', dbInbound = new DBInbound(), copyText = '', clientName = null) {
2023-02-09 22:18:06 +03:00
this.title = title;
this.content = content;
this.dbInbound = dbInbound;
this.inbound = dbInbound.toInbound();
2023-05-12 20:23:05 +03:00
this.clientName = clientName;
2023-02-09 22:18:06 +03:00
if (ObjectUtil.isEmpty(copyText)) {
this.copyText = content;
} else {
this.copyText = copyText;
}
this.visible = true;
qrModalApp.$nextTick(() => {
if (this.qrcode === null) {
this.qrcode = new QRious({
element: document.querySelector('#qrCode'),
size: 260,
value: content,
});
} else {
this.qrcode.value = content;
}
});
},
close: function () {
this.visible = false;
},
};
const qrModalApp = new Vue({
2023-05-12 20:23:05 +03:00
delimiters: ['[[', ']]'],
2023-02-09 22:18:06 +03:00
el: '#qrcode-modal',
data: {
qrModal: qrModal,
},
2023-03-17 19:07:49 +03:00
methods: {
copyToClipboard() {
this.qrModal.clipboard = new ClipboardJS('#qrCode', {
text: () => this.qrModal.copyText,
});
this.qrModal.clipboard.on('success', () => {
app.$message.success('{{ i18n "copied" }}')
this.qrModal.clipboard.destroy();
});
}
},
2023-02-09 22:18:06 +03:00
});
</script>
{{end}}