diff --git a/src/zotero_kb/templates/index.html b/src/zotero_kb/templates/index.html index e7ceef8..c85faed 100644 --- a/src/zotero_kb/templates/index.html +++ b/src/zotero_kb/templates/index.html @@ -389,18 +389,6 @@ projectForm: document.getElementById("create-project-form"), projectStatus: document.getElementById("project-status"), projectList: document.getElementById("project-list"), - importModal: document.getElementById("import-modal"), - importModalOverlay: document.getElementById("import-modal-overlay"), - openImportModalButton: document.getElementById("open-import-modal-button"), - closeImportModalButton: document.getElementById("close-import-modal-button"), - importModalProjectLabel: document.getElementById("import-modal-project-label"), - modalSelectedCount: document.getElementById("modal-selected-count"), - modalCollectionTree: document.getElementById("modal-collection-tree"), - modalCollectionItems: document.getElementById("modal-collection-items"), - modalSelectDescendantsButton: document.getElementById("modal-select-descendants-button"), - modalClearSelectionButton: document.getElementById("modal-clear-selection-button"), - modalImportSelectedItemsButton: document.getElementById("modal-import-selected-items-button"), - previewPopover: document.getElementById("item-preview-popover"), currentProjectLabel: document.getElementById("current-project-label"), cardList: document.getElementById("card-list"), cardDetail: document.getElementById("card-detail"), @@ -601,8 +589,9 @@ method: "POST", body: JSON.stringify({ prompt }), }); - setStatus(elements.recommendStatus, `返回 ${payload.results.length} 条候选引用。`); - renderRecommendationResults(payload.results || []); + const results = Array.isArray(payload.results) ? payload.results : []; + setStatus(elements.recommendStatus, `返回 ${results.length} 条候选引用。`); + renderRecommendationResults(results); } catch (error) { setStatus(elements.recommendStatus, error.message, true); } @@ -620,8 +609,9 @@ method: "POST", body: JSON.stringify({ prompt }), }); - setStatus(elements.planStatus, `生成 ${payload.sections.length} 个方案段落。`); - renderPlanResults(payload.sections || []); + const sections = Array.isArray(payload.sections) ? payload.sections : []; + setStatus(elements.planStatus, `生成 ${sections.length} 个方案段落。`); + renderPlanResults(sections); } catch (error) { setStatus(elements.planStatus, error.message, true); }