2026-07-08 21:10:47 +08:00
|
|
|
import fs from 'node:fs';
|
|
|
|
|
import path from 'node:path';
|
2026-07-10 20:44:04 +08:00
|
|
|
import {
|
|
|
|
|
normalizeWorkspaceRelativePath,
|
|
|
|
|
resolveAssetWorkspaceRelativePath,
|
|
|
|
|
resolvePageWorkspaceRelativePath,
|
|
|
|
|
} from './mindspace-workspace-relative-path.mjs';
|
2026-07-08 21:10:47 +08:00
|
|
|
import { resolvePublishDir } from './user-publish.mjs';
|
2026-07-05 23:14:41 +08:00
|
|
|
|
2026-07-10 20:44:04 +08:00
|
|
|
export {
|
|
|
|
|
normalizeWorkspaceRelativePath,
|
|
|
|
|
resolveAssetWorkspaceRelativePath,
|
|
|
|
|
resolvePageWorkspaceRelativePath,
|
|
|
|
|
};
|
2026-07-05 23:14:41 +08:00
|
|
|
|
2026-07-08 21:10:47 +08:00
|
|
|
export async function readWorkspacePublishHtml(h5Root, userId, relativePath) {
|
|
|
|
|
const normalized = normalizeWorkspaceRelativePath(relativePath);
|
|
|
|
|
if (!h5Root || !userId || !normalized) return null;
|
|
|
|
|
const filePath = path.join(resolvePublishDir(h5Root, { id: userId }), ...normalized.split('/'));
|
|
|
|
|
try {
|
|
|
|
|
return await fs.promises.readFile(filePath, 'utf8');
|
|
|
|
|
} catch {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|