Fix tokenizer wasm path and init

This commit is contained in:
2026-02-09 21:16:02 +08:00
parent 636dd32174
commit 8edb0cf006

View File

@@ -390,17 +390,17 @@ export async function preload() {
loadingPromise = (async () => {
try {
// 动态 import 结巴模块
const wasmPath = `${extensionFolderPath}/libs/jieba-wasm/jieba_rs_wasm_bg.wasm`;
// ★ 使用绝对路径(开头加 /
const wasmPath = `/${extensionFolderPath}/libs/jieba-wasm/jieba_rs_wasm_bg.wasm`;
// eslint-disable-next-line no-unsanitized/method
jiebaModule = await import(
`${extensionFolderPath}/libs/jieba-wasm/jieba_rs_wasm.js`
`/${extensionFolderPath}/libs/jieba-wasm/jieba_rs_wasm.js`
);
// 初始化 WASM
// 初始化 WASM(新版 API 用对象形式)
if (typeof jiebaModule.default === 'function') {
await jiebaModule.default(wasmPath);
await jiebaModule.default({ module_or_path: wasmPath });
}
// 缓存函数引用