fix: handle apiEndpoints/columnDefs objects in preview, add string type checks

This commit is contained in:
木炎
2026-04-17 10:55:58 +08:00
parent bb15d14749
commit 74c42af717
2 changed files with 16 additions and 9 deletions

View File

@@ -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));
}
}