fix: subtitle

This commit is contained in:
Gabe
2025-10-10 13:49:04 +08:00
parent 769a4f00aa
commit 251e57ec61
7 changed files with 139 additions and 143 deletions

View File

@@ -355,7 +355,8 @@ export const withTimeout = (task, timeout, timeoutMsg = "Task timed out") => {
* @param {*} maxLength
* @returns
*/
export const truncateWords = (str, maxLength) => {
export const truncateWords = (str, maxLength = 200) => {
if (typeof str !== "string") return "";
if (str.length <= maxLength) return str;
const truncated = str.slice(0, maxLength);
return truncated.slice(0, truncated.lastIndexOf(" ")) + " …";