Исправление багов
This commit is contained in:
@@ -842,7 +842,7 @@ class Search {
|
||||
d.click();
|
||||
} else if (action == 'copyLink') {
|
||||
//копирование ссылки
|
||||
if (utils.copyTextToClipboard(href))
|
||||
if (await utils.copyTextToClipboard(href))
|
||||
this.$root.notify.success('Ссылка успешно скопирована');
|
||||
else
|
||||
this.$root.notify.error('Копирование ссылки не удалось');
|
||||
|
||||
@@ -48,7 +48,29 @@ export function wordEnding(num, type = 0) {
|
||||
}
|
||||
}
|
||||
|
||||
export function fallbackCopyTextToClipboard(text) {
|
||||
let textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
|
||||
let result = false;
|
||||
try {
|
||||
result = document.execCommand('copy');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
document.body.removeChild(textArea);
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function copyTextToClipboard(text) {
|
||||
if (!navigator.clipboard) {
|
||||
return fallbackCopyTextToClipboard(text);
|
||||
}
|
||||
|
||||
let result = false;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
|
||||
Reference in New Issue
Block a user