feat(前端优化): 优化后台渲染与导出,修复快速滚动时加载状态残留
build.yaml / build (push) Successful in 46s

This commit is contained in:
xiaoqidun committed 2026-09-12 00:34:29 +08:00
1 parent 04e5cd7071
commit fb4ba04767
5 files changed
+162 -159

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
importScripts("./wasm_exec.js");
self.onmessage = ({ data: { id, name, args } }) => {
try {
const payload = globalThis[name](...args);
const result = typeof payload === "string" ? JSON.parse(payload) : payload;
self.postMessage({ id, ...result }, result.data?.bytes ? [result.data.bytes.buffer] : []);
} catch (err) {
self.postMessage({ id, ok: false, error: err.message });
}
};
function exitWASM(err) {
self.postMessage({ type: "exit", error: err?.message || "渲染引擎已退出" });
self.close();
}
async function loadWASM() {
const go = new Go();
self.postMessage({ type: "progress", text: "正在下载引擎", percent: 16 });
const response = await fetch("./ofdgo.wasm");
self.postMessage({ type: "progress", text: "正在编译引擎", percent: 35 });
const { instance } = await WebAssembly.instantiateStreaming(response, go.importObject);
self.postMessage({ type: "progress", text: "正在启动引擎", percent: 58 });
go.run(instance).then(exitWASM, exitWASM);
if (!go.exited) {
self.postMessage({ type: "ready" });
}
}
loadWASM().catch(exitWASM);