mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 17:27:08 +08:00
1 parent
a7e86a322f
commit
92585edd1e
6 files changed
+46
-8
No files matched your search
@@ -839,6 +839,7 @@ button.outline-link:hover {
|
||||
overflow: hidden;
|
||||
color: #1f2428;
|
||||
font-size: 13px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
+11
-2
@@ -670,6 +670,16 @@ async function loadWASM() {
|
||||
}
|
||||
if (data.type === "progress") {
|
||||
setProgress(data.text, data.percent);
|
||||
} else if (data.type === "export") {
|
||||
if (wasmRequests.get(data.id)?.openSeq === state.openSeq && state.exporting) {
|
||||
if (data.stage === "save") {
|
||||
setProgress("正在保存", null);
|
||||
} else if (data.completed === data.total) {
|
||||
setProgress("正在封装", null);
|
||||
} else {
|
||||
setProgress(`正在导出 ${data.completed} / ${data.total} 页`, data.completed / data.total * 100);
|
||||
}
|
||||
}
|
||||
} else if (data.type === "ready") {
|
||||
state.ready = true;
|
||||
resolve();
|
||||
@@ -1589,7 +1599,6 @@ async function exportFile(whole, indices = null) {
|
||||
if (openSeq !== state.openSeq) {
|
||||
return;
|
||||
}
|
||||
setProgress(`正在保存 ${result.label}`, 100);
|
||||
if (result.blob) {
|
||||
downloadBytes(result.blob, result.mime, fileName);
|
||||
}
|
||||
@@ -3302,7 +3311,7 @@ async function callWASM(name, ...args) {
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = ++wasmRequestID;
|
||||
wasmRequests.set(id, { resolve, reject });
|
||||
wasmRequests.set(id, { resolve, reject, openSeq: state.openSeq });
|
||||
try {
|
||||
wasmWorker.postMessage({ id, name, args });
|
||||
} catch (err) {
|
||||
|
||||
@@ -24,11 +24,17 @@ async function handleMessage({ id, name, args }) {
|
||||
setTimeout(done, 0);
|
||||
}
|
||||
});
|
||||
if (name === "ofdgoExportDocument") {
|
||||
args.push((completed, total) => {
|
||||
self.postMessage({ id, type: "export", stage: "pages", completed, total });
|
||||
});
|
||||
}
|
||||
}
|
||||
const payload = await globalThis[name](...args);
|
||||
const result = typeof payload === "string" ? JSON.parse(payload) : payload;
|
||||
if (exporting && result.ok) {
|
||||
result.data.size = size;
|
||||
self.postMessage({ id, type: "export", stage: "save" });
|
||||
if (output) {
|
||||
await output.close();
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user