Files
jinshen-website/app/composables/directus/useDirectusFiles.ts
R2m1liA a520775a8d
All checks were successful
deploy to server / build-and-deploy (push) Successful in 3m2s
refactor: 将文件请求由app端转到server端
2025-11-12 18:19:21 +08:00

18 lines
385 B
TypeScript

export const useDirectusFiles = () => {
const getFileUrl = (
id?: string | null,
options?: Record<string, string | number | boolean>
): string => {
if (!id) return '';
const params = new URLSearchParams(
options as Record<string, string>
).toString();
return `/api/assets/${id}${params ? `?${params}` : ''}`;
};
return {
getFileUrl,
};
};