feat: display verification code in frontend email list

This commit is contained in:
eoao
2026-05-10 00:26:45 +08:00
parent 92e18ea683
commit a46192b214
5 changed files with 77 additions and 20 deletions

View File

@@ -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 '';