Browse Source

修复复制存档失败BUG

master
许孟阳 1 week ago
parent
commit
2b0f5bc7c7
  1. 13
      src/views/archive.vue

13
src/views/archive.vue

@ -47,13 +47,24 @@ const showMenu = () => {
} }
const copyArchive = () => { const copyArchive = () => {
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(archive.value).then(() => { navigator.clipboard.writeText(archive.value).then(() => {
commit('set_sys_info', { msg: t('copyArchive.1'), type: 'win' }) commit('set_sys_info', { msg: t('copyArchive.1'), type: 'win' })
}, () => { showMenu();
}).catch(() => {
commit('set_sys_info', { msg: t('copyArchive.2'), type: 'waring' }) commit('set_sys_info', { msg: t('copyArchive.2'), type: 'waring' })
}); });
} else {
const textField = document.createElement("textarea");
textField.innerText = archive.value;
document.body.appendChild(textField);
textField.select();
document.execCommand("copy");
textField.remove();
commit('set_sys_info', { msg: t('copyArchive.1'), type: 'win' })
showMenu(); showMenu();
} }
}
const pasteArchive = () => { const pasteArchive = () => {
navigator.clipboard.readText().then((text) => { navigator.clipboard.readText().then((text) => {

Loading…
Cancel
Save