From 74c42af7172a120a821dd735bac5fa185a17c921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=A8=E7=82=8E?= <635735027@qq.com> Date: Fri, 17 Apr 2026 10:55:58 +0800 Subject: [PATCH] fix: handle apiEndpoints/columnDefs objects in preview, add string type checks --- frontend/scene-generator/llm-client.js | 8 +++++--- .../scene-generator/sg_scene_generator.html | 17 +++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/frontend/scene-generator/llm-client.js b/frontend/scene-generator/llm-client.js index aaf7a27..14d473f 100644 --- a/frontend/scene-generator/llm-client.js +++ b/frontend/scene-generator/llm-client.js @@ -70,7 +70,8 @@ function buildAnalyzePrompt(sourceDir, dirContents) { parts.push(`\n=== 脚本文件 ===`); for (const [name, content] of Object.entries(dirContents.scripts)) { parts.push(`\n--- ${name} ---`); - parts.push(content.substring(0, 2000)); + const contentStr = typeof content === 'string' ? content : String(content || ''); + parts.push(contentStr.substring(0, 2000)); } } @@ -99,7 +100,7 @@ function buildDeepAnalyzePrompt(sourceDir, dirContents, indexHtmlContent) { } // Include index.html content (key addition) - if (indexHtmlContent) { + if (indexHtmlContent && typeof indexHtmlContent === 'string') { parts.push(`\n=== index.html ===`); // Limit to first 15000 chars to avoid token limits parts.push(indexHtmlContent.substring(0, 15000)); @@ -109,7 +110,8 @@ function buildDeepAnalyzePrompt(sourceDir, dirContents, indexHtmlContent) { parts.push(`\n=== 脚本文件 ===`); for (const [name, content] of Object.entries(dirContents.scripts)) { parts.push(`\n--- ${name} ---`); - parts.push(content.substring(0, 3000)); + const contentStr = typeof content === 'string' ? content : String(content || ''); + parts.push(contentStr.substring(0, 3000)); } } diff --git a/frontend/scene-generator/sg_scene_generator.html b/frontend/scene-generator/sg_scene_generator.html index 279d333..68f8496 100644 --- a/frontend/scene-generator/sg_scene_generator.html +++ b/frontend/scene-generator/sg_scene_generator.html @@ -493,9 +493,12 @@ const apiCount = document.getElementById("previewApiCount"); if (data.apiEndpoints && data.apiEndpoints.length > 0) { apiCount.textContent = data.apiEndpoints.length; - apiList.innerHTML = data.apiEndpoints.map(ep => - `
${field} → ${label}