feat: Restructured core logic to support automatic page scanning and rich text translation

This commit is contained in:
Gabe
2025-09-21 19:51:57 +08:00
parent 7dc847fca2
commit 943a9e86f0
24 changed files with 2095 additions and 705 deletions

View File

@@ -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);
};