@@ -656,6 +667,24 @@ function handleSearch(type, value) {
emit('right-search', type, value);
}
+async function copyCode(code) {
+ try {
+ await navigator.clipboard.writeText(code);
+ ElMessage({
+ message: t('copySuccessMsg'),
+ type: 'success',
+ plain: true
+ })
+ } catch (err) {
+ console.error(`${t('copyFailMsg')}:`, err);
+ ElMessage({
+ message: t('copyFailMsg'),
+ type: 'error',
+ plain: true
+ })
+ }
+}
+
function handleDelete() {
ElMessageBox.confirm(t('delEmailsConfirm'), {
confirmButtonText: t('confirm'),
@@ -1139,14 +1168,37 @@ function loadData() {
}
.email-subject {
+ display: flex;
+ align-items: center;
+ gap: 6px;
overflow: hidden;
white-space: nowrap;
- text-overflow: ellipsis;
+ min-width: 0;
@media (min-width: 1367px) {
padding-left: 5px;
}
}
+ .code-tag {
+ flex: 0 0 auto;
+ max-width: 170px;
+ height: 20px;
+ line-height: 20px;
+ font-size: 14px;
+ color: var(--el-text-color-primary);
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ cursor: pointer;
+ }
+
+ .subject-text {
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ min-width: 0;
+ }
+
.email-content {
overflow: hidden;
white-space: nowrap;
diff --git a/mail-vue/src/i18n/en.js b/mail-vue/src/i18n/en.js
index d030b63..8e1028e 100644
--- a/mail-vue/src/i18n/en.js
+++ b/mail-vue/src/i18n/en.js
@@ -104,6 +104,8 @@ const en = {
validUntil: 'Valid Until',
expired: 'Expired',
copy: 'Copy',
+ copyCode: 'Copy Code',
+ codeLabel: 'Code: ',
history: 'History',
addRegKey: 'Add Invite Code',
regKey: 'Invite Code',
diff --git a/mail-vue/src/i18n/zh.js b/mail-vue/src/i18n/zh.js
index fc382d2..35e47b8 100644
--- a/mail-vue/src/i18n/zh.js
+++ b/mail-vue/src/i18n/zh.js
@@ -104,6 +104,8 @@ const zh = {
validUntil: '有效至期',
expired: '已过期',
copy: '复制',
+ copyCode: '复制验证码',
+ codeLabel: '验证码:',
history: '记录',
addRegKey: '添加注册码',
regKey: '注册码',
diff --git a/mail-worker/src/init/init.js b/mail-worker/src/init/init.js
index d9ad096..e06665a 100644
--- a/mail-worker/src/init/init.js
+++ b/mail-worker/src/init/init.js
@@ -35,7 +35,11 @@ const dbInit = {
async v3_0DB(c) {
try {
- await c.env.db.prepare(`ALTER TABLE email ADD COLUMN code TEXT NOT NULL DEFAULT '';`).run();
+ await c.env.db.batch([
+ await c.env.db.prepare(`ALTER TABLE email ADD COLUMN code TEXT NOT NULL DEFAULT '';`).run(),
+ await c.env.db.prepare(`ALTER TABLE setting ADD COLUMN ai_code INTEGER NOT NULL DEFAULT 1;`).run(),
+ await c.env.db.prepare(`ALTER TABLE setting ADD COLUMN ai_code_filter TEXT NOT NULL DEFAULT '';`).run()
+ ]);
} catch (e) {
console.warn(`跳过字段:${e.message}`);
}
@@ -50,17 +54,6 @@ const dbInit = {
console.warn(`跳过字段:${e.message}`);
}
- try {
- await c.env.db.prepare(`ALTER TABLE setting ADD COLUMN ai_code INTEGER NOT NULL DEFAULT 1;`).run();
- } catch (e) {
- console.warn(`跳过字段:${e.message}`);
- }
-
- try {
- await c.env.db.prepare(`ALTER TABLE setting ADD COLUMN ai_code_filter TEXT NOT NULL DEFAULT '';`).run();
- } catch (e) {
- console.warn(`跳过字段:${e.message}`);
- }
},
async v2_9DB(c) {
diff --git a/mail-worker/src/service/ai-service.js b/mail-worker/src/service/ai-service.js
index 9f1124c..c9a5e68 100644
--- a/mail-worker/src/service/ai-service.js
+++ b/mail-worker/src/service/ai-service.js
@@ -22,7 +22,7 @@ const aiService = {
messages: [
{
role: 'system',
- content: 'You extract verification codes from emails. Return only JSON like {"code":"123456"} or {"code":""}. Do not explain.'
+ content: 'You extract verification codes from emails. Return only JSON like {"code":"123456"} or {"code":""}. The code must be 6 characters or fewer and must not contain spaces. If the code is longer than 6 characters or contains spaces, return {"code":""}. Do not explain.'
},
{
role: 'user',
@@ -35,7 +35,15 @@ const aiService = {
const content = typeof result === 'string' ? result : result?.response || '';
const json = JSON.parse(content);
- return typeof json.code === 'string' ? json.code.trim().slice(0, 64) : '';
+ if (typeof json.code !== 'string') {
+ return '';
+ }
+
+ if (json.code.length > 6 || /\s/.test(json.code)) {
+ return '';
+ }
+
+ return json.code;
} catch (e) {
console.error('验证码提取失败: ', e);
return '';