update: 2026-03-28 20:59

This commit is contained in:
2026-03-28 20:59:52 +08:00
parent e21d58e603
commit 1c81d4e6ea
611 changed files with 27847 additions and 65061 deletions

View File

@@ -7,45 +7,12 @@ const loading = document.getElementById('loading');
const poemOutput = document.getElementById('poemOutput');
const themeInput = document.getElementById('theme');
// 调用后端API
// 调用后端统一 chat提示词在前端 ai-prompts.js
async function callBackendAPI(theme) {
try {
// 获取JWT token
const token = localStorage.getItem('token');
if (!token) {
throw new Error('未登录请先登录后使用AI功能');
}
const response = await fetch(`${window.API_CONFIG.baseUrl}/api/aimodelapp/poetry`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
theme: theme
})
});
if (!response.ok) {
if (response.status === 402) {
throw new Error('您的萌芽币余额不足,无法使用此功能');
}
const errorData = await response.json();
throw new Error(errorData.error || `API请求失败: ${response.status} ${response.statusText}`);
}
const data = await response.json();
if (data.success) {
return data.poem;
} else {
throw new Error(data.error || 'API响应格式异常');
}
} catch (error) {
console.error('API调用错误:', error);
throw error;
}
const content = await window.AiChat.complete(
[{ role: 'user', content: window.AiPrompts.poetry(theme) }]
);
return content;
}
// 显示错误信息