Commit 155ec4c9 by lijiabin

feat: 新增OSS处理参数URL拼接工具函数

parent c442debf
export * from './app' export * from './app'
export * from './wxUtil' export * from './wxUtil'
export * from './excel' export * from './excel'
export * from './oss'
/**
* 给文件 URL 拼接 OSS 处理参数。
* 后端返回的 URL 可能已带 query(如 ?expires=...&sign=...),
* 此时必须用 & 连接,否则会出现双 ? 导致资源加载失败。
*/
export const withOssProcess = (url: string, process: string) => {
if (!url) return url
return `${url}${url.includes('?') ? '&' : '?'}x-oss-process=${process}`
}
/** 图片转 webp */
export const toWebpUrl = (url: string) => withOssProcess(url, 'image/format,webp')
/** 视频第 1 秒截帧作为封面 */
export const getVideoPosterUrl = (url: string) => withOssProcess(url, 'video/snapshot,t_1000,f_jpg')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment