feat: support subtitle translate
This commit is contained in:
@@ -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(" ")) + " …";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user