diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index d0e7f38a5..1d5a9ce8c 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -161,6 +161,27 @@ Vue.prototype.goBack = function () { } }; +// 复制文本 +Vue.prototype.copyText = function (obj) { + if (!$A.isJson(obj)) { + obj = { + text: obj, + success: "复制成功", + error: "复制失败" + } + } + if ($A.isEEUiApp) { + $A.eeuiAppCopyText(obj.text) + obj.success && $A.messageSuccess(obj.success) + return + } + app.$copyText(text).then(_ => { + obj.success && $A.messageSuccess(obj.success) + }).catch(_ => { + obj.error && $A.messageError(obj.error) + }) +}; + // 全局对象/变量 $A.L = $L; $A.Electron = null; diff --git a/resources/assets/js/functions/eeui.js b/resources/assets/js/functions/eeui.js index 93b4a6be2..f4b1d46f3 100755 --- a/resources/assets/js/functions/eeui.js +++ b/resources/assets/js/functions/eeui.js @@ -165,6 +165,11 @@ if (!$A.isEEUiApp) return; return $A.eeuiModuleSync("webview").setDisabledUserLongClickSelect(val); }, + + eeuiAppCopyText(text) { + if (!$A.isEEUiApp) return; + $A.eeuiModule("eeui").copyText(text) + }, }); window.$A = $; diff --git a/resources/assets/js/pages/manage/components/DialogMarkdown.vue b/resources/assets/js/pages/manage/components/DialogMarkdown.vue index 891336296..07c6f89c8 100644 --- a/resources/assets/js/pages/manage/components/DialogMarkdown.vue +++ b/resources/assets/js/pages/manage/components/DialogMarkdown.vue @@ -46,13 +46,13 @@ export default { if (navigator.clipboard?.writeText) navigator.clipboard.writeText(codeBlock.textContent ?? '') else - this.copyText({text: codeBlock.textContent ?? '', origin: true}) + this.copyContent({text: codeBlock.textContent ?? '', origin: true}) }) } }) }, - copyText(options) { + copyContent(options) { const props = {origin: true, ...options} let input diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 8fb466e5a..6b3fff5c6 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -2872,18 +2872,18 @@ export default { break; case 'link': - this.$copyText(value).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败')) + this.copyText(value); break; case 'selected': - this.$copyText(value).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败')) + this.copyText(value); break; case 'text': const copyEl = $A(this.$refs.scroller.$el).find(`[data-id="${this.operateItem.id}"]`).find('.dialog-content') if (copyEl.length > 0) { const text = copyEl[0].innerText.replace(/\n\n/g, "\n").replace(/(^\s*)|(\s*$)/g, "") - this.$copyText(text).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败')) + this.copyText(text) } else { $A.messageWarning('不可复制的内容'); } diff --git a/resources/assets/js/pages/manage/components/FileContent.vue b/resources/assets/js/pages/manage/components/FileContent.vue index 1c5dbc46e..4ac54663b 100644 --- a/resources/assets/js/pages/manage/components/FileContent.vue +++ b/resources/assets/js/pages/manage/components/FileContent.vue @@ -562,11 +562,7 @@ export default { return; } this.linkFocus(); - this.$copyText(this.linkData.url).then(_ => { - $A.messageSuccess('复制成功'); - }).catch(_ => { - $A.messageError('复制失败'); - }); + this.copyText(this.linkData.url); }, linkFocus() { diff --git a/resources/assets/js/pages/manage/components/MeetingManager.vue b/resources/assets/js/pages/manage/components/MeetingManager.vue index 7701cff40..9e89d6d6e 100644 --- a/resources/assets/js/pages/manage/components/MeetingManager.vue +++ b/resources/assets/js/pages/manage/components/MeetingManager.vue @@ -548,10 +548,10 @@ export default { sharekey: this.addData.sharekey }, }).then(({ data }) => { - this.$copyText(data).then(_ => { - $A.messageSuccess('已复制会议邀请链接'); - }).catch(_ => { - $A.messageError('复制失败'); + this.copyText({ + text: data, + success: '已复制会议邀请链接', + error: "复制失败" }); this.invitationShow = false; }).catch(({ msg }) => { diff --git a/resources/assets/js/pages/manage/components/ProjectPanel.vue b/resources/assets/js/pages/manage/components/ProjectPanel.vue index 084e89260..70297e77f 100644 --- a/resources/assets/js/pages/manage/components/ProjectPanel.vue +++ b/resources/assets/js/pages/manage/components/ProjectPanel.vue @@ -1420,11 +1420,7 @@ export default { return; } this.inviteFocus(); - this.$copyText(this.inviteData.url).then(_ => { - $A.messageSuccess('复制成功'); - }).catch(_ => { - $A.messageError('复制失败'); - }); + this.copyText(this.inviteData.url); }, inviteFocus() { diff --git a/resources/assets/js/pages/manage/file.vue b/resources/assets/js/pages/manage/file.vue index 9d0ba9435..fe099186c 100644 --- a/resources/assets/js/pages/manage/file.vue +++ b/resources/assets/js/pages/manage/file.vue @@ -1381,11 +1381,7 @@ export default { return; } this.linkFocus(); - this.$copyText(this.linkData.url).then(_ => { - $A.messageSuccess('复制成功'); - }).catch(_ => { - $A.messageError('复制失败'); - }); + this.copyText(this.linkData.url); }, linkFocus() {