错误信息: POST https://ghiuoimfghor.sealoshzh.site/api/community/publish 500 (Internal Server Error)
design
, photo
, video
, 3d
design
, fitting
, tutorial
// 工作类型映射
const workTypeMapping = {
'design': 'design',
'photo': 'fitting', // 照片试衣功能
'video': 'tutorial', // 视频教程
'3d': 'design' // 3D设计
};
// 验证必填字段
if (!titleElement || !titleElement.value.trim()) {
showNotification('发布失败', '请输入作品标题');
return;
}
// 提供默认值
visibility: visibilityElement ? visibilityElement.value : 'public',
allow_download: downloadElement ? downloadElement.value === 'allow' : true,
tags: selectedTags || [],
// 详细的错误分类处理
if (error.message.includes('500')) {
errorMessage = '服务器暂时无法处理请求,请稍后再试';
} else if (error.message.includes('400')) {
errorMessage = '提交的数据格式有误,请检查后重试';
}
// 记录发送的数据以便调试
console.log('发布作品数据:', workData);
console.error('发送的数据:', workData);
{
"work_type": "design|fitting|tutorial",
"title": "string (非空)",
"description": "string",
"images": ["string array"],
"design_id": "string (可选)",
"tags": ["string array"],
"visibility": "public|followers|private",
"allow_download": "boolean",
"allow_comments": "boolean"
}
{
"code": 200,
"data": {
"work_id": "string",
"published_at": "datetime",
"status": "string"
}
}
# 测试API端点是否响应
curl -X POST https://ghiuoimfghor.sealoshzh.site/api/community/publish \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {token}" \
-d '{"work_type":"design","title":"test"}'
现在的修复应该解决大部分前端数据格式问题。如果500错误仍然存在,主要是后端服务器的问题。