前端美化

This commit is contained in:
2025-09-16 18:39:10 +08:00
parent 17691af8d1
commit 174d8a3bc5
26 changed files with 337 additions and 474 deletions

View File

@@ -10,17 +10,27 @@ const themeInput = document.getElementById('theme');
// 调用后端API
async function callBackendAPI(theme) {
try {
const response = await fetch('http://127.0.0.1:5002/api/aimodelapp/poetry', {
const token = AUTH_CONFIG.getToken();
const headers = {
'Content-Type': 'application/json'
};
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
const response = await fetch(`${API_CONFIG.baseUrl}${API_CONFIG.endpoints.poetry}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
headers: headers,
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}`);
}