🐞 fix: 修复油管解析时间显示的问题

This commit is contained in:
秋刀鱼 2024-11-15 13:14:07 +08:00
parent e05f7d2901
commit f48da3b91f

View File

@ -30,9 +30,15 @@ export function removeParams(url) {
} }
export function convertToSeconds(timeStr) { export function convertToSeconds(timeStr) {
const [hour, minutes, seconds] = timeStr.split(':').map(Number); // 拆分并转换为数字 const parts = timeStr.split(':').map(Number);
if (!seconds) return timeStr; if (parts.length === 2) {
return hour * 3600 + minutes * 60 + seconds; // 分钟转化为秒并加上秒数 const [minutes, seconds] = parts;
return minutes * 60 + seconds;
} else if (parts.length === 3) {
const [hours, minutes, seconds] = parts;
return hours * 3600 + minutes * 60 + seconds;
}
return timeStr;
} }
export async function autoSelectMusicOrVideoSend() { export async function autoSelectMusicOrVideoSend() {