mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
perf: 优化复制功能
This commit is contained in:
parent
71c62a3772
commit
1fdd532133
21
resources/assets/js/app.js
vendored
21
resources/assets/js/app.js
vendored
@ -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;
|
||||
|
||||
5
resources/assets/js/functions/eeui.js
vendored
5
resources/assets/js/functions/eeui.js
vendored
@ -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 = $;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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('不可复制的内容');
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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 }) => {
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user