forked from XiaoMo/ChatGPT-Next-Web
Update utils.ts
This commit is contained in:
parent
0acb877b03
commit
905bf41cd8
@ -9,6 +9,7 @@ export function trimTopic(topic: string) {
|
|||||||
export async function copyToClipboard(text: string) {
|
export async function copyToClipboard(text: string) {
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(text);
|
await navigator.clipboard.writeText(text);
|
||||||
|
showToast(Locale.Copy.Success);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const textArea = document.createElement("textarea");
|
const textArea = document.createElement("textarea");
|
||||||
textArea.value = text;
|
textArea.value = text;
|
||||||
@ -17,11 +18,11 @@ export async function copyToClipboard(text: string) {
|
|||||||
textArea.select();
|
textArea.select();
|
||||||
try {
|
try {
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
|
showToast(Locale.Copy.Success);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showToast(Locale.Copy.Failed);
|
showToast(Locale.Copy.Failed);
|
||||||
}
|
}
|
||||||
} finally {
|
document.body.removeChild(textArea);
|
||||||
showToast(Locale.Copy.Success);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user