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

@@ -34,8 +34,13 @@ const messages = {
deleteFailed: '删除邮件失败。',
confirmClearAll: '确定要清空这个收件箱的所有邮件吗?此操作不可恢复。',
clearFailed: '清空收件箱失败。',
generateRandomSuccess: '已生成随机邮箱地址',
checkInboxStart: '正在查询收件箱',
copyFailed: '复制失败!',
copySuccess: '复制成功!', // <-- 这里添加
actionCancelled: '操作已取消',
deleteSuccess: '删除成功!',
clearSuccess: '收件箱已清空!',
},
newMailNotification: '收到新邮件!',
}
@@ -73,8 +78,13 @@ const messages = {
deleteFailed: 'Failed to delete email.',
confirmClearAll: 'Are you sure you want to clear all emails in this inbox? This action cannot be undone.',
clearFailed: 'Failed to clear inbox.',
generateRandomSuccess: 'Random email address generated',
checkInboxStart: 'Checking inbox',
copyFailed: 'Copy failed!',
copySuccess: 'Copied successfully!', // <-- 这里添加
actionCancelled: 'Action cancelled',
deleteSuccess: 'Deleted successfully!',
clearSuccess: 'Inbox cleared!',
},
newMailNotification: 'New mail received!',
}

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>