feat(mindspace): 全部页面管理、级联删除与页面同步去重

支持全部页面分页/多选/删除/分享,删除时可选移除广场帖并清理工作区附件;修复并发同步重复创建页面,并补齐预览下载链接重写与 iframe 下载权限。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-06-30 01:22:38 +08:00
parent 6e6d00568a
commit ea6c49f046
30 changed files with 2562 additions and 351 deletions
+47
View File
@@ -129,3 +129,50 @@ test('syncGeneratedPagesFromPublicAssets creates pages for unlinked public html
assert.equal(result.created, 1);
assert.equal(created[0].source.assetId, 'asset-1');
});
test('syncGeneratedPagesFromPublicAssets reuses db page when memory index is empty', async () => {
const publishDir = await fs.mkdtemp(path.join(os.tmpdir(), 'page-sync-dedupe-'));
const publicDir = path.join(publishDir, 'public');
await fs.mkdir(publicDir, { recursive: true });
await fs.writeFile(
path.join(publicDir, 'demo.html'),
'<html><head><title>Demo Page</title></head><body>Hi</body></html>',
'utf8',
);
const created = [];
const updated = [];
const pool = {
async query(sql) {
if (sql.includes('JSON_UNQUOTE(JSON_EXTRACT(pv.source_snapshot_json')) {
return [[{ id: 'page-existing', updated_at: 100 }]];
}
if (sql.includes('FROM h5_page_records p')) return [[]];
if (sql.includes('FROM h5_assets a')) return [[]];
return [[]];
},
};
const pageService = {
async createFromChat() {
created.push(true);
return { id: 'page-new' };
},
async updatePage(userId, pageId) {
updated.push({ userId, pageId });
return { id: pageId };
},
};
const result = await syncGeneratedPagesFromPublicAssets({
pool,
pageService,
assetService: null,
userId: 'user-1',
publishDir,
});
assert.equal(result.created, 0);
assert.equal(created.length, 0);
assert.equal(updated.length, 1);
assert.equal(updated[0].pageId, 'page-existing');
});