fix: handle apiEndpoints/columnDefs objects in preview, add string type checks
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 =>
|
||||
`<div class="preview-list-item">${escapeHtml(ep)}</div>`
|
||||
).join("");
|
||||
apiList.innerHTML = data.apiEndpoints.map(ep => {
|
||||
const name = escapeHtml(ep.name || "unknown");
|
||||
const url = escapeHtml(ep.url || "");
|
||||
const method = escapeHtml(ep.method || "GET");
|
||||
return `<div class="preview-list-item"><strong>${name}</strong>: ${url} <span style="color: var(--muted);">[${method}]</span></div>`;
|
||||
}).join("");
|
||||
} else {
|
||||
apiCount.textContent = "0";
|
||||
apiList.innerHTML = '<div class="preview-list-item" style="color: var(--muted);">无</div>';
|
||||
@@ -506,9 +509,11 @@
|
||||
const colCount = document.getElementById("previewColumnCount");
|
||||
if (data.columnDefs && data.columnDefs.length > 0) {
|
||||
colCount.textContent = data.columnDefs.length;
|
||||
colList.innerHTML = data.columnDefs.map(col =>
|
||||
`<div class="preview-list-item">${escapeHtml(col)}</div>`
|
||||
).join("");
|
||||
colList.innerHTML = data.columnDefs.map(col => {
|
||||
const field = escapeHtml(Array.isArray(col) ? col[0] : (col.field || ""));
|
||||
const label = escapeHtml(Array.isArray(col) ? col[1] : (col.label || ""));
|
||||
return `<div class="preview-list-item"><code>${field}</code> → ${label}</div>`;
|
||||
}).join("");
|
||||
} else {
|
||||
colCount.textContent = "0";
|
||||
colList.innerHTML = '<div class="preview-list-item" style="color: var(--muted);">无</div>';
|
||||
|
||||
Reference in New Issue
Block a user