feat: Restructured core logic to support automatic page scanning and rich text translation
This commit is contained in:
@@ -177,7 +177,7 @@ export const sha256 = async (text, salt) => {
|
||||
* 生成随机事件名称
|
||||
* @returns
|
||||
*/
|
||||
export const genEventName = () => btoa(Math.random()).slice(3, 11);
|
||||
export const genEventName = () => `kiss-${btoa(Math.random()).slice(3, 11)}`;
|
||||
|
||||
/**
|
||||
* 判断两个 Set 是否相同
|
||||
@@ -302,3 +302,16 @@ export const extractJson = (raw) => {
|
||||
const match = s.match(/\{[\s\S]*\}/);
|
||||
return match ? match[0] : "{}";
|
||||
};
|
||||
|
||||
/**
|
||||
* 空闲执行
|
||||
* @param {*} cb
|
||||
* @param {*} timeout
|
||||
* @returns
|
||||
*/
|
||||
export const scheduleIdle = (cb, timeout = 200) => {
|
||||
if (window.requestIdleCallback) {
|
||||
return requestIdleCallback(cb, { timeout });
|
||||
}
|
||||
return setTimeout(cb, timeout);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user