feat: fix backend sql error;fix frontend i18n display error

This commit is contained in:
2025-07-29 15:35:34 +08:00
parent 32320e1cb0
commit 7ee074249f
4 changed files with 43 additions and 48 deletions

View File

@@ -168,6 +168,7 @@ const fetchMessages = async () => {
ElMessage.warning(t('home.alerts.enterEmail'));
return;
}
ElMessage.info(t('home.alerts.checkInboxStart'));
loading.value = true;
selectedMessage.value = null;
attachments.value = [];
@@ -326,60 +327,39 @@ const generateRandomEmail = () => {
} else {
prefix = `${word1}${separator}${word2}${number}`;
}
ElMessage.success(t('home.alerts.generateRandomSuccess'));
recipient.value = `${prefix}@${domain}`;
};
const copyEmail = () => {
const copyEmail = async () => {
if (!recipient.value) return;
const textToCopy = recipient.value;
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(textToCopy).then(() => {
showCopySuccess();
}).catch(err => {
console.error('Modern copy failed: ', err);
fallbackCopy(textToCopy);
});
} else {
fallbackCopy(textToCopy);
}
};
const fallbackCopy = (text) => {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.top = '-9999px';
textArea.style.left = '-9999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
const successful = document.execCommand('copy');
if (successful) {
showCopySuccess();
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(recipient.value);
} else {
throw new Error('Fallback copy was unsuccessful');
// fallback 方案
const textArea = document.createElement('textarea');
textArea.value = recipient.value;
textArea.style.position = 'fixed'; // 防止滚动时跳动
textArea.style.left = '-9999px';
textArea.style.top = '-9999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
const success = document.execCommand('copy');
document.body.removeChild(textArea);
if (!success) throw new Error('Fallback copy failed');
}
copyStatus.value = 'copied';
ElMessage.success(t('home.alerts.copySuccess'));
setTimeout(() => copyStatus.value = 'idle', 2000);
} catch (err) {
console.error('Fallback copy failed: ', err);
console.error('Copy failed:', err);
ElMessage.error(t('home.alerts.copyFailed'));
}
document.body.removeChild(textArea);
};
const showCopySuccess = () => {
copyStatus.value = 'copied';
setTimeout(() => {
copyStatus.value = 'idle';
}, 2000);
};
</script>
<style scoped>