feat: 分享内容稿件
This commit is contained in:
@ -265,3 +265,19 @@ export const formatUploadSpeed = (bytesPerSecond: number): string => {
|
||||
return `${(bytesPerSecond / (1024 * 1024)).toFixed(2)} MB/s`;
|
||||
}
|
||||
};
|
||||
|
||||
export function convertVideoUrlToCoverUrl(videoUrl: string): string {
|
||||
if (!videoUrl || typeof videoUrl !== 'string') {
|
||||
console.error('Invalid video URL');
|
||||
return '';
|
||||
}
|
||||
|
||||
const urlWithCovers = videoUrl.replace('/videos/', '/covers/');
|
||||
|
||||
const lastDotIndex = urlWithCovers.lastIndexOf('.');
|
||||
if (lastDotIndex !== -1) {
|
||||
return urlWithCovers.substring(0, lastDotIndex) + '.jpg';
|
||||
}
|
||||
|
||||
return urlWithCovers + '.jpg';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user