我忘了改啥了
This commit is contained in:
@@ -269,31 +269,28 @@ export default function VerifyCodeTest() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 真实API调用模式
|
||||
try {
|
||||
// 根据后端架构文档中的API网关信息
|
||||
// 根据后端代码分析,使用正确的API接口格式
|
||||
const API_ENDPOINTS = [
|
||||
{
|
||||
name: 'API网关v1版本',
|
||||
url: 'https://code.littlelan.cn/CarrotSkin/APIgateway/api/v1/auth/send-code'
|
||||
},
|
||||
{
|
||||
name: 'API网关v2版本',
|
||||
url: 'https://code.littlelan.cn/CarrotSkin/APIgateway/api/v2/auth/send-code'
|
||||
},
|
||||
{
|
||||
name: '直接API',
|
||||
url: 'https://code.littlelan.cn/CarrotSkin/api/auth/send-code'
|
||||
name: 'API v1版本',
|
||||
url: `${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/send-code`
|
||||
}
|
||||
];
|
||||
|
||||
// 测试多个可能的端点
|
||||
for (const endpoint of API_ENDPOINTS) {
|
||||
addLog(`\n=== 测试 ${endpoint.name} ===`);
|
||||
addLog(`请求URL: ${endpoint.url}`);
|
||||
addLog(`请求参数: {"email": "${email}"}`);
|
||||
|
||||
try {
|
||||
// 根据后端代码分析,需要包含type参数
|
||||
const requestBody = {
|
||||
email,
|
||||
type: 'register' // 默认使用register类型,可以根据需要修改为reset_password或change_email
|
||||
};
|
||||
|
||||
addLog(`\n=== 测试 ${endpoint.name} ===`);
|
||||
addLog(`请求URL: ${endpoint.url}`);
|
||||
addLog(`请求参数: ${JSON.stringify(requestBody)}`);
|
||||
|
||||
// 发送请求
|
||||
const startTime = Date.now();
|
||||
const controller = new AbortController();
|
||||
@@ -304,7 +301,7 @@ export default function VerifyCodeTest() {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ email }),
|
||||
body: JSON.stringify(requestBody),
|
||||
signal: controller.signal,
|
||||
credentials: 'include'
|
||||
});
|
||||
@@ -334,7 +331,7 @@ export default function VerifyCodeTest() {
|
||||
addLog(`非JSON响应: ${text.substring(0, 150)}${text.length > 150 ? '...' : ''}`);
|
||||
}
|
||||
} catch (fetchError) {
|
||||
if (fetchError.name === 'AbortError') {
|
||||
if (fetchError instanceof Error && fetchError.name === 'AbortError') {
|
||||
addLog('请求超时 (8秒)');
|
||||
} else {
|
||||
addLog(`请求错误: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`);
|
||||
@@ -352,7 +349,6 @@ export default function VerifyCodeTest() {
|
||||
|
||||
setMessageType('error');
|
||||
setMessage('所有API端点连接失败,请检查后端服务状态');
|
||||
|
||||
} catch (error) {
|
||||
addLog(`系统异常: ${error instanceof Error ? error.message : String(error)}`);
|
||||
setMessageType('error');
|
||||
@@ -405,14 +401,13 @@ export default function VerifyCodeTest() {
|
||||
|
||||
{/* 后端架构信息 */}
|
||||
<div className="verify-code-info-box">
|
||||
<h3>后端架构信息</h3>
|
||||
<p>基于提供的后端架构文档:</p>
|
||||
<h3>后端API接口信息</h3>
|
||||
<ul>
|
||||
<li>认证模块: internal/handler/auth_handler.go</li>
|
||||
<li>邮箱验证码模块: internal/service/verification_service.go</li>
|
||||
<li>验证码: 6位数字,Redis存储(10分钟有效期)</li>
|
||||
<li>发送频率: 限制1分钟</li>
|
||||
<li>邮件格式: HTML格式</li>
|
||||
<li>API端点: <code>POST /api/v1/auth/send-code</code></li>
|
||||
<li>请求参数: <code>{'{"email": "user@example.com", "type": "register|reset_password|change_email"}'}</code></li>
|
||||
<li>验证码规则: 6位数字,Redis存储(10分钟有效期)</li>
|
||||
<li>限制: 每分钟只能发送1次</li>
|
||||
<li>实现文件: internal/handler/auth_handler.go 和 internal/service/verification_service.go</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -428,7 +423,7 @@ export default function VerifyCodeTest() {
|
||||
checked={testMode === 'real'}
|
||||
onChange={() => setTestMode('real')}
|
||||
/>
|
||||
真实API调用
|
||||
API调用
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
@@ -442,9 +437,8 @@ export default function VerifyCodeTest() {
|
||||
</label>
|
||||
</div>
|
||||
<p className="verify-code-test-mode-description">
|
||||
{testMode === 'real'
|
||||
? '将实际调用后端API发送验证码'
|
||||
: '模拟验证码发送过程,生成测试验证码'}
|
||||
API调用: 真实调用后端API接口<br/>
|
||||
本地模拟: 在前端模拟验证码发送流程
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user