| | |
| | | return _url.startsWith('/') ? _url : '/' + _url; |
| | | } |
| | | |
| | | type ConvertApi2FormUrlOptions = { |
| | | fileName?: string; |
| | | }; |
| | | |
| | | /** |
| | | * 把api返回的路径转换为upload的路径 |
| | | */ |
| | | export function convertApi2FormUrl(path: string) { |
| | | export function convertApi2FormUrl(path: string, options: ConvertApi2FormUrlOptions = {}) { |
| | | const { fileName } = options; |
| | | return { |
| | | name: setOssFileName(path), |
| | | name: fileName ? fileName : setOssFileName(path), |
| | | path: urlOmitDomain(path), |
| | | url: setOSSLink(path), |
| | | status: 'success', |
| | |
| | | } as UploadUserFile; |
| | | } |
| | | |
| | | export function convertApi2FormUrlOnlyOne(path: string) { |
| | | return path ? [convertApi2FormUrl(path)] : []; |
| | | export function convertApi2FormUrlOnlyOne(path: string, options: ConvertApi2FormUrlOptions = {}) { |
| | | return path ? [convertApi2FormUrl(path, options)] : []; |
| | | } |
| | | |
| | | /** |