fix(mindspace): refresh published HTML after workspace sync

Keep online publication snapshots aligned when public/*.html changes, default static page binds to public access with MindSpace delivery URLs, and split browser-safe workspace helpers out of the Vite import chain.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-10 20:44:04 +08:00
parent 7f8d692d16
commit e3063ea806
12 changed files with 279 additions and 110 deletions
+10 -28
View File
@@ -1,9 +1,17 @@
import fs from 'node:fs';
import path from 'node:path';
import { normalizeWorkspaceRelativePath } from './mindspace-pages.mjs';
import {
normalizeWorkspaceRelativePath,
resolveAssetWorkspaceRelativePath,
resolvePageWorkspaceRelativePath,
} from './mindspace-workspace-relative-path.mjs';
import { resolvePublishDir } from './user-publish.mjs';
export { normalizeWorkspaceRelativePath };
export {
normalizeWorkspaceRelativePath,
resolveAssetWorkspaceRelativePath,
resolvePageWorkspaceRelativePath,
};
export async function readWorkspacePublishHtml(h5Root, userId, relativePath) {
const normalized = normalizeWorkspaceRelativePath(relativePath);
@@ -15,29 +23,3 @@ export async function readWorkspacePublishHtml(h5Root, userId, relativePath) {
return null;
}
}
export function resolvePageWorkspaceRelativePath(snapshot) {
if (!snapshot || typeof snapshot !== 'object') return null;
return normalizeWorkspaceRelativePath(snapshot.relative_path) || null;
}
export function resolveAssetWorkspaceRelativePath({
categoryCode = null,
originalFilename = null,
explicitPath = null,
} = {}) {
const explicit = normalizeWorkspaceRelativePath(explicitPath);
if (explicit) return explicit;
const filename = String(originalFilename ?? '')
.replace(/\\/g, '/')
.replace(/^\/+/, '');
if (!filename) return null;
if (/^(?:public|oa)\//i.test(filename)) {
return normalizeWorkspaceRelativePath(filename);
}
const category = String(categoryCode ?? '').trim();
if (category === 'public' || category === 'oa') {
return normalizeWorkspaceRelativePath(`${category}/${filename}`);
}
return null;
}