Skip to content

Commit c68f17e

Browse files
MKY508claude
andcommitted
fix: 修复偏好设置 API 路径 + ChartDisplay 空值处理
- PreferencesSettings: 修正 API 路径 /api/v1/config/config → /api/v1/config - ChartDisplay: 添加 data[0] 空值检查,防止 Object.keys 崩溃 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 73013e0 commit c68f17e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

apps/web/src/components/chat/ChartDisplay.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ export function ChartDisplay({
4747
}: ChartDisplayProps) {
4848
// 自动检测数据键
4949
const keys = useMemo(() => {
50-
if (!data || data.length === 0) return { x: xKey, y: yKey };
50+
if (!data || data.length === 0) return { x: xKey, y: yKey, allNumberKeys: [] };
5151

5252
const firstItem = data[0];
53+
if (!firstItem || typeof firstItem !== "object") {
54+
return { x: xKey, y: yKey, allNumberKeys: [] };
55+
}
5356
const allKeys = Object.keys(firstItem);
5457

5558
// 尝试找到合适的 x 和 y 键

apps/web/src/components/settings/PreferencesSettings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export function PreferencesSettings() {
2727
const { data: config, isLoading } = useQuery({
2828
queryKey: ["user-config"],
2929
queryFn: async () => {
30-
const response = await api.get("/api/v1/config/config");
30+
const response = await api.get("/api/v1/config");
3131
return response.data.data as UserConfig;
3232
},
3333
});
3434

3535
// 更新配置
3636
const updateMutation = useMutation({
3737
mutationFn: async (data: UserConfig) => {
38-
const response = await api.put("/api/v1/config/config", data);
38+
const response = await api.put("/api/v1/config", data);
3939
return response.data;
4040
},
4141
onSuccess: () => {

apps/web/tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)