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

@@ -25,39 +25,11 @@ function showErrorMessage(msg) {
resultContainer.innerHTML = `<div class="placeholder">${msg}</div>`;
}
// 调用后端API
// 调用后端统一 chat提示词在前端markdownOption 仅保留兼容 UI不参与提示词
async function callBackendAPI(articleText, emojiStyle, markdownOption) {
try {
const token = window.AUTH_CONFIG.getToken();
if (!token) throw new Error('未登录请先登录后使用AI功能');
const url = `${window.API_CONFIG.baseUrl}${window.API_CONFIG.endpoints.markdownFormatting}`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
article_text: articleText,
emoji_style: emojiStyle,
markdown_option: markdownOption
})
});
if (!response.ok) {
if (response.status === 402) throw new Error('您的萌芽币余额不足,无法使用此功能');
const errorData = await response.json().catch(() => ({}));
throw new Error(errorData.error || `API请求失败: ${response.status} ${response.statusText}`);
}
const data = await response.json();
if (data.success && data.formatted_markdown) return data.formatted_markdown;
throw new Error(data.error || 'API响应格式异常');
} catch (error) {
console.error('API调用错误:', error);
throw error;
}
return window.AiChat.complete([
{ role: 'user', content: window.AiPrompts.markdownFormatting(articleText, emojiStyle) },
]);
}
// 显示结果