Skip to content

Commit 6fd305e

Browse files
committed
fix: 修复多个问题
- 修复创建ZIP项目时缺少source_type字段的问题 - 修复LiteLLM模型名称被错误解析为effort参数的问题 - 修复登录/注册页面无法正确显示验证错误的问题 - 添加Windows导出PDF需要GTK依赖的说明文档
1 parent 2656431 commit 6fd305e

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,34 @@ LLM_API_KEY=your_api_key:your_secret_key
283283
获取地址:https://console.bce.baidu.com/qianfan/
284284
</details>
285285

286+
<details>
287+
<summary><b>Windows 导出 PDF 报错怎么办?</b></summary>
288+
289+
PDF 导出功能使用 WeasyPrint 库,在 Windows 系统上需要安装 GTK 依赖:
290+
291+
**方法一:使用 MSYS2 安装(推荐)**
292+
```bash
293+
# 1. 下载并安装 MSYS2: https://www.msys2.org/
294+
# 2. 打开 MSYS2 终端,执行:
295+
pacman -S mingw-w64-x86_64-pango mingw-w64-x86_64-gtk3
296+
297+
# 3. 将 MSYS2 的 bin 目录添加到系统 PATH 环境变量:
298+
# C:\msys64\mingw64\bin
299+
```
300+
301+
**方法二:使用 GTK3 Runtime 安装包**
302+
1. 下载 GTK3 Runtime: https://github.com/nickvidal/gtk3-runtime/releases
303+
2. 安装后将安装目录添加到系统 PATH
304+
305+
**方法三:使用 Docker 部署(最简单)**
306+
使用 Docker 部署后端可以避免 Windows 上的依赖问题:
307+
```bash
308+
docker-compose up -d backend
309+
```
310+
311+
安装完成后重启后端服务即可正常导出 PDF。
312+
</details>
313+
286314
<details>
287315
<summary><b>如何使用 API 中转站?</b></summary>
288316

backend/app/services/llm/adapters/litellm_adapter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ async def _send_request(self, request: LLMRequest) -> LLMResponse:
105105
# 禁用 LiteLLM 的缓存,确保每次都实际调用 API
106106
litellm.cache = None
107107

108+
# 禁用 LiteLLM 自动添加的 reasoning_effort 参数
109+
# 这可以防止模型名称被错误解析为 effort 参数
110+
litellm.drop_params = True
111+
108112
# 构建消息
109113
messages = [{"role": msg.role, "content": msg.content} for msg in request.messages]
110114

frontend/src/pages/Login.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ export default function Login() {
5959
await login(response.data.access_token);
6060
toast.success("登录成功");
6161
} catch (error: any) {
62-
toast.error(error.response?.data?.detail || "登录失败,请检查邮箱和密码");
62+
const detail = error.response?.data?.detail;
63+
// 处理 Pydantic 验证错误(数组格式)
64+
if (Array.isArray(detail)) {
65+
const messages = detail.map((err: any) => err.msg || err.message || JSON.stringify(err)).join('; ');
66+
toast.error(messages || "登录失败");
67+
} else if (typeof detail === 'object') {
68+
toast.error(detail.msg || detail.message || JSON.stringify(detail));
69+
} else {
70+
toast.error(detail || "登录失败,请检查邮箱和密码");
71+
}
6372
} finally {
6473
setLoading(false);
6574
}

frontend/src/pages/Register.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ export default function Register() {
2626
toast.success('注册成功,请登录');
2727
navigate('/login');
2828
} catch (error: any) {
29-
toast.error(error.response?.data?.detail || '注册失败');
29+
const detail = error.response?.data?.detail;
30+
// 处理 Pydantic 验证错误(数组格式)
31+
if (Array.isArray(detail)) {
32+
const messages = detail.map((err: any) => err.msg || err.message || JSON.stringify(err)).join('; ');
33+
toast.error(messages || '注册失败');
34+
} else if (typeof detail === 'object') {
35+
toast.error(detail.msg || detail.message || JSON.stringify(detail));
36+
} else {
37+
toast.error(detail || '注册失败');
38+
}
3039
} finally {
3140
setLoading(false);
3241
}

frontend/src/shared/api/database.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const api = {
6868
const res = await apiClient.post('/projects/', {
6969
name: project.name,
7070
description: project.description,
71+
source_type: project.source_type || 'repository',
7172
repository_url: project.repository_url,
7273
repository_type: project.repository_type,
7374
default_branch: project.default_branch,

0 commit comments

Comments
 (0)