Welcome to mirror list, hosted at ThFree Co, Russian Federation.

qrcode_modal.html « common « html « web - github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2bd2f00f65951b0f87aa756674d398dcb0ea0268 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{{define "qrcodeModal"}}
<a-modal id="qrcode-modal" v-model="qrModal.visible" :title="qrModal.title"
         :closable="true"
         :class="themeSwitcher.darkCardClass"
         :footer="null"
         width="300px">
    <a-tag color="green" style="margin-bottom: 10px;display: block;text-align: center;">
        {{ i18n "pages.inbounds.clickOnQRcode" }}
    </a-tag>
    <canvas @click="copyToClipboard()" id="qrCode" style="width: 100%; height: 100%;"></canvas>
</a-modal>

<script>

    const qrModal = {
        title: '',
        content: '',
        inbound: new Inbound(),
        dbInbound: new DBInbound(),
        copyText: '',
        qrcode: null,
        clipboard: null,
        visible: false,
        show: function (title = '', content = '', dbInbound = new DBInbound(), copyText = '') {
            this.title = title;
            this.content = content;
            this.dbInbound = dbInbound;
            this.inbound = dbInbound.toInbound();
            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({
        el: '#qrcode-modal',
        data: {
            qrModal: qrModal,
        },
        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();
                });
            }
        },
    });

</script>
{{end}}