Fix tokenizer wasm path and init
This commit is contained in:
@@ -390,17 +390,17 @@ export async function preload() {
|
|||||||
|
|
||||||
loadingPromise = (async () => {
|
loadingPromise = (async () => {
|
||||||
try {
|
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
|
// eslint-disable-next-line no-unsanitized/method
|
||||||
jiebaModule = await import(
|
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') {
|
if (typeof jiebaModule.default === 'function') {
|
||||||
await jiebaModule.default(wasmPath);
|
await jiebaModule.default({ module_or_path: wasmPath });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 缓存函数引用
|
// 缓存函数引用
|
||||||
|
|||||||
Reference in New Issue
Block a user