Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled
16 lines
473 B
TypeScript
16 lines
473 B
TypeScript
/**
|
|
* 文件展示 URL 拼接工具
|
|
* 开发环境走相对路径,生产环境拼接固定域名
|
|
*/
|
|
|
|
const PROD_DOMAIN = 'http://39.98.44.136:6024';
|
|
|
|
/** 根据服务端返回的 fileUrl 字段拼出可用于 <img>/<video> src 的完整地址 */
|
|
export function getFileDisplayUrl(fileUrl: string): string {
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
if (isDev) {
|
|
return `/data/file/${fileUrl}`;
|
|
}
|
|
return `${PROD_DOMAIN}/data/file/${fileUrl}`;
|
|
}
|