feat: support subtitle translate

This commit is contained in:
Gabe
2025-10-07 16:35:00 +08:00
parent df8c96569a
commit b2b5bef9f5
22 changed files with 971 additions and 6 deletions

View File

@@ -350,3 +350,15 @@ export const withTimeout = (task, timeout, timeoutMsg = "Task timed out") => {
),
]);
};
/**
* 截短字符串
* @param {*} str
* @param {*} maxLength
* @returns
*/
export const truncateWords = (str, maxLength) => {
if (str.length <= maxLength) return str;
const truncated = str.slice(0, maxLength);
return truncated.slice(0, truncated.lastIndexOf(" ")) + " …";
};