feat: improve mindspace asset handling and local runtime paths

This commit is contained in:
john
2026-06-28 12:18:26 +08:00
parent 4a9bc710f1
commit ea19ffb5fa
36 changed files with 867 additions and 100 deletions
+20
View File
@@ -822,6 +822,25 @@ export function createAssetService(pool, options = {}) {
};
};
const readPublicAsset = async (assetId) => {
const [rows] = await pool.query(
`SELECT a.*, c.category_code, v.storage_key, v.scan_status
FROM h5_assets a
JOIN h5_space_categories c ON c.id = a.category_id AND c.user_id = a.user_id
JOIN h5_asset_versions v ON v.id = a.current_version_id
WHERE a.id = ? AND a.status <> 'deleted'
LIMIT 1`,
[assetId],
);
const asset = rows[0];
if (!asset) throw Object.assign(new Error('资产不存在'), { code: 'asset_not_found' });
assertAssetDownloadable(asset);
return {
asset: assetResponse(asset),
path: await resolveReadableStoragePath(asset.storage_key),
};
};
const createChatAsset = async (
userId,
{ categoryCode, buffer, filename, displayName, sourceType = 'chat' },
@@ -1101,6 +1120,7 @@ export function createAssetService(pool, options = {}) {
listAssets,
deleteAsset,
readAsset,
readPublicAsset,
renderAssetPreview,
extractAssetText,
renderAssetThumbnail,