fix: Reduce the frequency of saving empty pages

This commit is contained in:
LIlGG
2025-10-10 11:29:19 +08:00
parent c5d47c680c
commit 3af1c30d49
3 changed files with 24 additions and 2 deletions

View File

@@ -12,8 +12,9 @@ export const getSystemPrompt = () => `
- 绝对不生成任何后端相关代码。
- 如果是多页面项目,需生成所有页面,保证每页都有完整内容。
- 不要啰嗦,除非用户要求更多信息,否则不要解释任何内容。
- 永远不要使用 "artifact" 个词。
- 永远不要使用 "artifact" 或 "action" 这两个词。
- 仅对所有回答使用有效的 markdown除了构件外不要使用 HTML 标签!
- 确保生成的代码是可用于生产环境的代码,脚本和样式必须完整且正确。
页面规则:
- 仅使用原生 HTML、CSS 与 JS 构建前端页面,不使用任何框架。

View File

@@ -37,6 +37,24 @@ export function useProject() {
logger.error('保存项目失败: 页面或 Section 不能为空');
return false;
}
const isConsistent = projectPages.every((page) => {
const actionIds = page.actionIds;
const content = page.content;
if (actionIds.length === 0) {
return true;
}
if (!content) {
return false;
}
return true;
});
if (!isConsistent) {
logger.error('保存项目失败: 页面内容与 actions 不一致', {
projectPages,
projectSections,
});
return false;
}
try {
// 先保存在本地数据中
saveEditorProject(messageId, projectPages, projectSections);

View File

@@ -112,8 +112,11 @@ export class WebBuilderStore {
}
async setDocumentContent(pageName: string, _html: string) {
if (_html.trim() === '') {
return;
}
// 更新内容,但不会触发保存,不会保存至 pages 中。
this.editorStore.updateDocumentContent(pageName, _html ?? '');
this.editorStore.updateDocumentContent(pageName, _html);
}
/**