From c817ce624944e4a4582b6336fa1e9affd6ba36df Mon Sep 17 00:00:00 2001 From: iFwu Date: Tue, 8 Oct 2024 01:23:44 +0800 Subject: [PATCH] dev use local wasm & data --- src/chessEngine.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/chessEngine.ts b/src/chessEngine.ts index 71f6642..98db3a7 100644 --- a/src/chessEngine.ts +++ b/src/chessEngine.ts @@ -12,8 +12,13 @@ export class ChessEngine { (window as any).Pikafish = Pikafish; this.engineInstance = await Pikafish({ locateFile: (file: string) => { + if (import.meta.env.DEV) { + return file === 'pikafish.data' + ? `${import.meta.env.BASE_URL}wasm/data/${file}` + : `${import.meta.env.BASE_URL}wasm/${file}`; + } return file === 'pikafish.data' - ? 'https://xiangqiai.com/wasm/data/pikafish.data' + ? `https://xiangqiai.com/wasm/data/${file}` : `https://xiangqiai.com/wasm/single/${file}`; }, });