这个提交包含在:
binary-husky
2024-01-16 00:29:46 +08:00
父节点 74bced2d35
当前提交 0e43b08837
共有 2 个文件被更改,包括 87 次插入43 次删除

查看文件

@@ -239,14 +239,20 @@ function do_something_but_not_too_frequently(min_interval, func) {
const now = Date.now();
if (!lastInvocationTime || (now - lastInvocationTime) >= min_interval) {
lastInvocationTime = now;
func.apply(this, args);
// 现在就执行
setTimeout(() => {
func.apply(this, lastArgs);
}, 0);
} else if (!timeoutID) {
// 等一会执行
timeoutID = setTimeout(() => {
timeoutID = null;
lastInvocationTime = Date.now();
func.apply(this, lastArgs);
}, min_interval - (now - lastInvocationTime));
}
} else {
// 压根不执行
}
}
}
@@ -258,7 +264,7 @@ function chatbotContentChanged(attempt = 1, force = false) {
}, i === 0 ? 0 : 200);
}
const run_mermaid_render = do_something_but_not_too_frequently(500, function () {
const run_mermaid_render = do_something_but_not_too_frequently(1000, function () {
const blocks = document.querySelectorAll(`pre.mermaid, diagram-div`);
if (blocks.length == 0) { return; }
uml("mermaid");