diff options
| author | Shishkevich D. <135337715+shishkevichd@users.noreply.github.com> | 2025-03-06 22:43:46 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-06 22:43:46 +0300 |
| commit | 2d8cca3a2ec1ae9034b7bc28a2fb5f2260f43e1a (patch) | |
| tree | d9b0f6b919d75d872b0c1a3cf30a4b009ccf21e5 /web/html | |
| parent | cf7fec1351e44c624e599c226c35748f187ff8d1 (diff) | |
refactor: delete `clipboardjs` (#2727)
text copying can be done without using additional libraries
Diffstat (limited to 'web/html')
| -rw-r--r-- | web/html/common/qrcode_modal.html | 17 | ||||
| -rw-r--r-- | web/html/common/text_modal.html | 20 | ||||
| -rw-r--r-- | web/html/xui/inbound_info_modal.html | 23 | ||||
| -rw-r--r-- | web/html/xui/inbounds.html | 1 | ||||
| -rw-r--r-- | web/html/xui/index.html | 1 |
5 files changed, 22 insertions, 40 deletions
diff --git a/web/html/common/qrcode_modal.html b/web/html/common/qrcode_modal.html index 94e750c7..117dd640 100644 --- a/web/html/common/qrcode_modal.html +++ b/web/html/common/qrcode_modal.html @@ -10,7 +10,7 @@ <a-tag color="purple" class="qr-tag"><span>{{ i18n "pages.settings.subSettings"}}</span></a-tag> <tr-qr-bg class="qr-bg-sub"> <tr-qr-bg-inner class="qr-bg-sub-inner"> - <canvas @click="copyToClipboard('qrCode-sub',genSubLink(qrModal.client.subId))" id="qrCode-sub" class="qr-cv"></canvas> + <canvas @click="copyToClipboard(genSubLink(qrModal.client.subId))" id="qrCode-sub" class="qr-cv"></canvas> </tr-qr-bg-inner> </tr-qr-bg> </tr-qr-box> @@ -18,7 +18,7 @@ <a-tag color="purple" class="qr-tag"><span>{{ i18n "pages.settings.subSettings"}} Json</span></a-tag> <tr-qr-bg class="qr-bg-sub"> <tr-qr-bg-inner class="qr-bg-sub-inner"> - <canvas @click="copyToClipboard('qrCode-subJson',genSubJsonLink(qrModal.client.subId))" id="qrCode-subJson" class="qr-cv"></canvas> + <canvas @click="copyToClipboard(genSubJsonLink(qrModal.client.subId))" id="qrCode-subJson" class="qr-cv"></canvas> </tr-qr-bg-inner> </tr-qr-bg> </tr-qr-box> @@ -27,7 +27,7 @@ <tr-qr-box class="qr-box"> <a-tag color="green" class="qr-tag"><span>[[ row.remark ]]</span></a-tag> <tr-qr-bg class="qr-bg"> - <canvas @click="copyToClipboard('qrCode-'+index, row.link)" :id="'qrCode-'+index" class="qr-cv"></canvas> + <canvas @click="copyToClipboard(row.link)" :id="'qrCode-'+index" class="qr-cv"></canvas> </tr-qr-bg> </tr-qr-box> </template> @@ -41,7 +41,6 @@ dbInbound: new DBInbound(), client: null, qrcodes: [], - clipboard: null, visible: false, subId: '', show: function(title = '', dbInbound, client) { @@ -79,14 +78,10 @@ qrModal: qrModal, }, methods: { - copyToClipboard(elementId, content) { - this.qrModal.clipboard = new ClipboardJS('#' + elementId, { - text: () => content, - }); - this.qrModal.clipboard.on('success', () => { + copyToClipboard(content) { + return copyToClipboard(content).then(() => { app.$message.success('{{ i18n "copied" }}') - this.qrModal.clipboard.destroy(); - }); + }) }, setQrCode(elementId, content) { new QRious({ diff --git a/web/html/common/text_modal.html b/web/html/common/text_modal.html index d668c792..36589199 100644 --- a/web/html/common/text_modal.html +++ b/web/html/common/text_modal.html @@ -7,7 +7,7 @@ :href="'data:application/text;charset=utf-8,' + encodeURIComponent(txtModal.content)" :download="txtModal.fileName">[[ txtModal.fileName ]] </a-button> - <a-button type="primary" id="copy-btn">{{ i18n "copy" }}</a-button> + <a-button type="primary" @click="txtModal.copy(txtModal.content)">{{ i18n "copy" }}</a-button> </template> <a-input style="overflow-y: auto;" type="textarea" v-model="txtModal.content" :autosize="{ minRows: 10, maxRows: 20}"></a-input> @@ -20,24 +20,18 @@ content: '', fileName: '', qrcode: null, - clipboard: null, visible: false, show: function (title = '', content = '', fileName = '') { this.title = title; this.content = content; this.fileName = fileName; this.visible = true; - textModalApp.$nextTick(() => { - if (this.clipboard === null) { - this.clipboard = new ClipboardJS('#copy-btn', { - text: () => this.content, - }); - this.clipboard.on('success', () => { - app.$message.success('{{ i18n "copied" }}') - this.close(); - }); - } - }); + }, + copy: function (content = '') { + copyToClipboard(content).then(() => { + app.$message.success('{{ i18n "copied" }}') + this.close(); + }) }, close: function () { this.visible = false; diff --git a/web/html/xui/inbound_info_modal.html b/web/html/xui/inbound_info_modal.html index d9913f32..f95461e2 100644 --- a/web/html/xui/inbound_info_modal.html +++ b/web/html/xui/inbound_info_modal.html @@ -258,7 +258,7 @@ <tr-info-title class="tr-info-title"> <a-tag color="purple">Subscription Link</a-tag> <a-tooltip title='{{ i18n "copy" }}'> - <a-button size="small" icon="snippets" id="copy-sub-link" @click="copyToClipboard('copy-sub-link', infoModal.subLink)"></a-button> + <a-button size="small" icon="snippets" @click="copyToClipboard(infoModal.subLink)"></a-button> </a-tooltip> </tr-info-title> <a :href="[[ infoModal.subLink ]]" target="_blank">[[ infoModal.subLink ]]</a> @@ -267,7 +267,7 @@ <tr-info-title class="tr-info-title"> <a-tag color="purple">Json Link</a-tag> <a-tooltip title='{{ i18n "copy" }}'> - <a-button size="small" icon="snippets" id="copy-subJson-link" @click="copyToClipboard('copy-subJson-link', infoModal.subJsonLink)"></a-button> + <a-button size="small" icon="snippets" @click="copyToClipboard(infoModal.subJsonLink)"></a-button> </a-tooltip> </tr-info-title> <a :href="[[ infoModal.subJsonLink ]]" target="_blank">[[ infoModal.subJsonLink ]]</a> @@ -279,7 +279,7 @@ <tr-info-title class="tr-info-title"> <a-tag color="blue">[[ infoModal.clientSettings.tgId ]]</a-tag> <a-tooltip title='{{ i18n "copy" }}'> - <a-button size="small" icon="snippets" id="copy-tg-link" @click="copyToClipboard('copy-tg-link', infoModal.clientSettings.tgId)"></a-button> + <a-button size="small" icon="snippets" @click="copyToClipboard(infoModal.clientSettings.tgId)"></a-button> </a-tooltip> </tr-info-title> </tr-info-row> @@ -290,7 +290,7 @@ <tr-info-title class="tr-info-title"> <a-tag class="tr-info-tag" color="green">[[ link.remark ]]</a-tag> <a-tooltip title='{{ i18n "copy" }}'> - <a-button style="min-width: 24px;" size="small" icon="snippets" :id="'copy-url-link-'+index" @click="copyToClipboard('copy-url-link-'+index, link.link)"></a-button> + <a-button style="min-width: 24px;" size="small" icon="snippets" @click="copyToClipboard(link.link)"></a-button> </a-tooltip> </tr-info-title> <code>[[ link.link ]]</code> @@ -304,7 +304,7 @@ <tr-info-title class="tr-info-title"> <a-tag class="tr-info-tag" color="green">[[ link.remark ]]</a-tag> <a-tooltip title='{{ i18n "copy" }}'> - <a-button style="min-width: 24px;" size="small" icon="snippets" :id="'copy-url-link-'+index" @click="copyToClipboard('copy-url-link-'+index, link.link)"></a-button> + <a-button style="min-width: 24px;" size="small" icon="snippets" @click="copyToClipboard(link.link)"></a-button> </a-tooltip> </tr-info-title> <code>[[ link.link ]]</code> @@ -431,7 +431,7 @@ <tr-info-title class="tr-info-title"> <a-tag color="blue">Config</a-tag> <a-tooltip title='{{ i18n "copy" }}'> - <a-button style="min-width: 24px;" size="small" icon="snippets" :id="'copy-url-link-'+index" @click="copyToClipboard('copy-url-link-'+index, infoModal.links[index])"></a-button> + <a-button style="min-width: 24px;" size="small" icon="snippets" @click="copyToClipboard(infoModal.links[index])"></a-button> </a-tooltip> </tr-info-title> <div v-html="infoModal.links[index].replaceAll(`\n`,`<br />`)" style="border-radius: 1rem; padding: 0.5rem;" class="client-table-odd-row"> @@ -464,7 +464,6 @@ clientStats: [], upStats: 0, downStats: 0, - clipboard: null, links: [], index: null, isExpired: false, @@ -533,14 +532,10 @@ }, }, methods: { - copyToClipboard(elementId, content) { - this.infoModal.clipboard = new ClipboardJS('#' + elementId, { - text: () => content, - }); - this.infoModal.clipboard.on('success', () => { + copyToClipboard(content) { + return copyToClipboard(content).then(() => { app.$message.success('{{ i18n "copied" }}') - this.infoModal.clipboard.destroy(); - }); + }) }, statsColor(stats) { return usageColor(stats.up + stats.down, app.trafficDiff, stats.total); diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 89a37a29..86890926 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -546,7 +546,6 @@ {{template "js" .}} <script src="{{ .base_path }}assets/base64/base64.min.js"></script> <script src="{{ .base_path }}assets/qrcode/qrious2.min.js?{{ .cur_ver }}"></script> -<script src="{{ .base_path }}assets/clipboard/clipboard.min.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/uri/URI.min.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/js/model/inbound.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/js/model/dbinbound.js?{{ .cur_ver }}"></script> diff --git a/web/html/xui/index.html b/web/html/xui/index.html index 2e57277a..8f89da90 100644 --- a/web/html/xui/index.html +++ b/web/html/xui/index.html @@ -332,7 +332,6 @@ </a-modal> </a-layout> {{template "js" .}} -<script src="{{ .base_path }}assets/clipboard/clipboard.min.js?{{ .cur_ver }}"></script> {{template "component/themeSwitcher" .}} {{template "textModal"}} <script> |
