修复
This commit is contained in:
63
test_mail.html
Normal file
63
test_mail.html
Normal file
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>邮件创建测试</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>邮件创建测试</h1>
|
||||
<button onclick="testLogin()">登录</button>
|
||||
<button onclick="testCreateMail()">创建邮件</button>
|
||||
<div id="result"></div>
|
||||
|
||||
<script>
|
||||
let authToken = '';
|
||||
|
||||
async function testLogin() {
|
||||
try {
|
||||
const response = await axios.post('http://localhost:5003/api/v1/auth/login', {
|
||||
email: 'test@example.com',
|
||||
password: 'test123'
|
||||
});
|
||||
|
||||
authToken = response.data.data.token;
|
||||
document.getElementById('result').innerHTML = '<pre>登录成功,令牌: ' + authToken + '</pre>';
|
||||
} catch (error) {
|
||||
document.getElementById('result').innerHTML = '<pre>登录失败: ' + JSON.stringify(error.response.data, null, 2) + '</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
async function testCreateMail() {
|
||||
if (!authToken) {
|
||||
document.getElementById('result').innerHTML = '<pre>请先登录</pre>';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const mailData = {
|
||||
title: "测试邮件标题",
|
||||
content: "这是一封测试邮件的内容",
|
||||
recipientType: "SELF",
|
||||
sendTime: "2026-10-16T08:03:58.479Z",
|
||||
triggerType: "TIME",
|
||||
triggerCondition: {},
|
||||
attachments: [],
|
||||
isEncrypted: false,
|
||||
capsuleStyle: "default"
|
||||
};
|
||||
|
||||
const response = await axios.post('http://localhost:5003/api/v1/mails/create', mailData, {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + authToken,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('result').innerHTML = '<pre>邮件创建成功: ' + JSON.stringify(response.data, null, 2) + '</pre>';
|
||||
} catch (error) {
|
||||
document.getElementById('result').innerHTML = '<pre>邮件创建失败: ' + JSON.stringify(error.response.data, null, 2) + '</pre>';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user