mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-01 02:18:13 +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.L = $L;
|
||||||
$A.Electron = null;
|
$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;
|
if (!$A.isEEUiApp) return;
|
||||||
return $A.eeuiModuleSync("webview").setDisabledUserLongClickSelect(val);
|
return $A.eeuiModuleSync("webview").setDisabledUserLongClickSelect(val);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
eeuiAppCopyText(text) {
|
||||||
|
if (!$A.isEEUiApp) return;
|
||||||
|
$A.eeuiModule("eeui").copyText(text)
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
window.$A = $;
|
window.$A = $;
|
||||||
|
|||||||
@ -46,13 +46,13 @@ export default {
|
|||||||
if (navigator.clipboard?.writeText)
|
if (navigator.clipboard?.writeText)
|
||||||
navigator.clipboard.writeText(codeBlock.textContent ?? '')
|
navigator.clipboard.writeText(codeBlock.textContent ?? '')
|
||||||
else
|
else
|
||||||
this.copyText({text: codeBlock.textContent ?? '', origin: true})
|
this.copyContent({text: codeBlock.textContent ?? '', origin: true})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
copyText(options) {
|
copyContent(options) {
|
||||||
const props = {origin: true, ...options}
|
const props = {origin: true, ...options}
|
||||||
|
|
||||||
let input
|
let input
|
||||||
|
|||||||
@ -2872,18 +2872,18 @@ export default {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'link':
|
case 'link':
|
||||||
this.$copyText(value).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败'))
|
this.copyText(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'selected':
|
case 'selected':
|
||||||
this.$copyText(value).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败'))
|
this.copyText(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'text':
|
case 'text':
|
||||||
const copyEl = $A(this.$refs.scroller.$el).find(`[data-id="${this.operateItem.id}"]`).find('.dialog-content')
|
const copyEl = $A(this.$refs.scroller.$el).find(`[data-id="${this.operateItem.id}"]`).find('.dialog-content')
|
||||||
if (copyEl.length > 0) {
|
if (copyEl.length > 0) {
|
||||||
const text = copyEl[0].innerText.replace(/\n\n/g, "\n").replace(/(^\s*)|(\s*$)/g, "")
|
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 {
|
} else {
|
||||||
$A.messageWarning('不可复制的内容');
|
$A.messageWarning('不可复制的内容');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -562,11 +562,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.linkFocus();
|
this.linkFocus();
|
||||||
this.$copyText(this.linkData.url).then(_ => {
|
this.copyText(this.linkData.url);
|
||||||
$A.messageSuccess('复制成功');
|
|
||||||
}).catch(_ => {
|
|
||||||
$A.messageError('复制失败');
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
linkFocus() {
|
linkFocus() {
|
||||||
|
|||||||
@ -548,10 +548,10 @@ export default {
|
|||||||
sharekey: this.addData.sharekey
|
sharekey: this.addData.sharekey
|
||||||
},
|
},
|
||||||
}).then(({ data }) => {
|
}).then(({ data }) => {
|
||||||
this.$copyText(data).then(_ => {
|
this.copyText({
|
||||||
$A.messageSuccess('已复制会议邀请链接');
|
text: data,
|
||||||
}).catch(_ => {
|
success: '已复制会议邀请链接',
|
||||||
$A.messageError('复制失败');
|
error: "复制失败"
|
||||||
});
|
});
|
||||||
this.invitationShow = false;
|
this.invitationShow = false;
|
||||||
}).catch(({ msg }) => {
|
}).catch(({ msg }) => {
|
||||||
|
|||||||
@ -1420,11 +1420,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.inviteFocus();
|
this.inviteFocus();
|
||||||
this.$copyText(this.inviteData.url).then(_ => {
|
this.copyText(this.inviteData.url);
|
||||||
$A.messageSuccess('复制成功');
|
|
||||||
}).catch(_ => {
|
|
||||||
$A.messageError('复制失败');
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
inviteFocus() {
|
inviteFocus() {
|
||||||
|
|||||||
@ -1381,11 +1381,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.linkFocus();
|
this.linkFocus();
|
||||||
this.$copyText(this.linkData.url).then(_ => {
|
this.copyText(this.linkData.url);
|
||||||
$A.messageSuccess('复制成功');
|
|
||||||
}).catch(_ => {
|
|
||||||
$A.messageError('复制失败');
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
linkFocus() {
|
linkFocus() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user