mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-03-02 01:30:51 +03:00
64 lines
2.1 KiB
HTML
64 lines
2.1 KiB
HTML
{{define "qrcodeModal"}}
|
|
<a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title"
|
|
:closable="true" width="300px" :ok-text="qrModal.okText"
|
|
:class="siderDrawer.isDarkTheme ? darkClass : ''"
|
|
cancel-text='{{ i18n "close" }}' :ok-button-props="{attrs:{id:'qr-modal-ok-btn'}}">
|
|
<canvas id="qrCode" style="width: 100%; height: 100%;"></canvas>
|
|
</a-modal>
|
|
|
|
<script>
|
|
|
|
const qrModal = {
|
|
title: '',
|
|
content: '',
|
|
inbound: new Inbound(),
|
|
dbInbound: new DBInbound(),
|
|
okText: '',
|
|
copyText: '',
|
|
qrcode: null,
|
|
clipboard: null,
|
|
visible: false,
|
|
show: function (title='', content='', dbInbound=new DBInbound(),okText='{{ i18n "copy" }}', copyText='') {
|
|
this.title = title;
|
|
this.content = content;
|
|
this.dbInbound = dbInbound;
|
|
this.inbound = dbInbound.toInbound();
|
|
this.okText = okText;
|
|
if (ObjectUtil.isEmpty(copyText)) {
|
|
this.copyText = content;
|
|
} else {
|
|
this.copyText = copyText;
|
|
}
|
|
this.visible = true;
|
|
qrModalApp.$nextTick(() => {
|
|
if (this.clipboard === null) {
|
|
this.clipboard = new ClipboardJS('#qr-modal-ok-btn', {
|
|
text: () => this.copyText,
|
|
});
|
|
this.clipboard.on('success', () => app.$message.success('{{ i18n "copied" }}'));
|
|
}
|
|
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({
|
|
el: '#qrcode-modal',
|
|
data: {
|
|
qrModal: qrModal,
|
|
},
|
|
});
|
|
|
|
</script>
|
|
{{end}} |