mirror of
https://github.com/NotoChen/Jetbrains-Help.git
synced 2025-05-24 15:06:43 +08:00
[fix]复制激活码页面滚动到底部
This commit is contained in:
parent
b455aa58fc
commit
a824cdc497
|
@ -74,16 +74,22 @@ $(document).ready(function() {
|
||||||
return navigator.clipboard.writeText(val);
|
return navigator.clipboard.writeText(val);
|
||||||
} else {
|
} else {
|
||||||
console.log(val);
|
console.log(val);
|
||||||
|
const scrollX = window.scrollX;
|
||||||
const textArea = document.createElement('textarea')
|
const textArea = document.createElement('textarea')
|
||||||
textArea.value = val
|
textArea.value = val
|
||||||
// 使text area不在viewport,同时设置不可见
|
// 使text area不在viewport,同时设置不可见
|
||||||
document.body.appendChild(textArea)
|
document.body.appendChild(textArea)
|
||||||
textArea.focus()
|
textArea.focus()
|
||||||
textArea.select()
|
textArea.select()
|
||||||
return new Promise((res, rej) => {
|
try {
|
||||||
document.execCommand('copy') ? res() : rej()
|
const result = document.execCommand('copy');
|
||||||
textArea.remove()
|
return result ? Promise.resolve() : Promise.reject();
|
||||||
})
|
} catch (e) {
|
||||||
|
return Promise.reject(e);
|
||||||
|
} finally {
|
||||||
|
textArea.remove();
|
||||||
|
window.scrollTo(scrollX, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user