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

This commit is contained in:
Jixun Wu 2021-12-25 12:07:47 +00:00
parent ea57dbf4e7
commit a0b94c0f6f
1 changed files with 8 additions and 1 deletions

View File

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