fix(js): 解决部分浏览器或系统不支持程序复制的问题

Closes #3
This commit is contained in:
藏柏 2024-04-19 13:58:33 +08:00
parent 308520eb93
commit 5830681e23

View File

@ -55,8 +55,8 @@ $(document).ready(function() {
$.post('/generateLicense', JSON.stringify(data)) $.post('/generateLicense', JSON.stringify(data))
.then(response => { .then(response => {
copyText(response) copyText(response)
.then(() => { .then((result) => {
alert("The activation code has been copied"); alert(result);
}); });
}); });
}; };
@ -65,6 +65,10 @@ $(document).ready(function() {
const copyText = async (val) => { const copyText = async (val) => {
if (navigator.clipboard && navigator.permissions) { if (navigator.clipboard && navigator.permissions) {
await navigator.clipboard.writeText(val); await navigator.clipboard.writeText(val);
return "The activation code has been copied";
} else {
console.log(val);
return "The system does not support it, please go to the console to copy it manually";
} }
}; };