Browse Source

fix(QMCv2): Fail gracefully when WebAssembly loader failed.

(cherry picked from commit 700574fb8efd1a1057bc16a053e5015dcb2e3044)
20230320
Jixun Wu 3 years ago
committed by MengYX
parent
commit
fc4a0e002f
No known key found for this signature in database GPG Key ID: E63F9C7303E8F604
  1. 9
      src/decrypt/qmc_wasm.ts

9
src/decrypt/qmc_wasm.ts

@ -25,7 +25,14 @@ export async function DecryptQMCWasm(mggBlob: ArrayBuffer): Promise<QMC2Decrypti
const result: QMC2DecryptionResult = { success: false, data: new Uint8Array(), songId: 0, error: '' };
// 初始化模组
const QMCCrypto = await QMCCryptoModule();
let QMCCrypto: QMCCrypto;
try {
QMCCrypto = await QMCCryptoModule();
} catch (err: any) {
result.error = err?.message || 'wasm 加载失败';
return result;
}
// 申请内存块,并文件末端数据到 WASM 的内存堆
const detectionBuf = new Uint8Array(mggBlob.slice(-DETECTION_SIZE));

Loading…
Cancel
Save