fix(mindspace): 公开页上传图片物化到 static 路径供转发访问
Finish 同步与首次访问时将私有资产 API 图片复制到 public/.tmp-images, 避免其他用户转发链接后因无登录态无法加载页面内图片。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import { extractStaticPageLinks } from './mindspace-chat-save.mjs';
|
||||
import { extractStaticPageLinks, materializePrivateAssetsInPublicHtmlFiles } from './mindspace-chat-save.mjs';
|
||||
import { DOWNLOADABLE_FILE_PATTERN } from './mindspace-html-download-links.mjs';
|
||||
import { scheduleWorkspaceHtmlThumbnailSidecars } from './mindspace-workspace-thumbnails.mjs';
|
||||
|
||||
@@ -480,6 +480,9 @@ export async function syncPublicHtmlAfterFinish({
|
||||
syncWorkspaceAssets,
|
||||
registerPublicHtmlArtifacts,
|
||||
sessionId = null,
|
||||
pool = null,
|
||||
storageRoot = null,
|
||||
h5Root = null,
|
||||
} = {}) {
|
||||
if (!hasRecentOwnPublicHtmlReference(messages, currentUser, { publishDir })) {
|
||||
return { materialized: [], skipped: [], synced: false };
|
||||
@@ -496,6 +499,17 @@ export async function syncPublicHtmlAfterFinish({
|
||||
});
|
||||
const publicHtmlRelativePaths = publicHtmlArtifactRefs.map((ref) => ref.relativePath);
|
||||
const sourceMessageId = publicHtmlArtifactRefs.find((ref) => ref.messageId)?.messageId ?? null;
|
||||
let assetMaterialization = { materialized: [], skipped: [] };
|
||||
if (pool && storageRoot && h5Root && currentUser?.id && publicHtmlRelativePaths.length > 0) {
|
||||
assetMaterialization = await materializePrivateAssetsInPublicHtmlFiles({
|
||||
pool,
|
||||
storageRoot,
|
||||
h5Root,
|
||||
userId: currentUser.id,
|
||||
publishDir,
|
||||
relativePaths: publicHtmlRelativePaths,
|
||||
}).catch(() => ({ materialized: [], skipped: publicHtmlRelativePaths }));
|
||||
}
|
||||
let synced = false;
|
||||
if (typeof syncWorkspaceAssets === 'function' && currentUser?.id) {
|
||||
await syncWorkspaceAssets(currentUser.id, {
|
||||
@@ -512,5 +526,13 @@ export async function syncPublicHtmlAfterFinish({
|
||||
artifactRefs: publicHtmlArtifactRefs,
|
||||
});
|
||||
}
|
||||
return { materialized, skipped, synced, docxSync, publicHtmlRelativePaths, publicHtmlArtifactRefs };
|
||||
return {
|
||||
materialized,
|
||||
skipped,
|
||||
synced,
|
||||
docxSync,
|
||||
publicHtmlRelativePaths,
|
||||
publicHtmlArtifactRefs,
|
||||
assetMaterialization,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user