vuepress-theme-hope / vuepress-theme-hope

A vuepress theme with tons of features✨
https://theme-hope.vuejs.press
MIT License
2.15k stars 752 forks source link

[Bug]在主题中配置searchPro全文检索后搜索中文浏览器报错 #4237

Open 2290774104 opened 5 months ago

2290774104 commented 5 months ago

Checklist

Package name

vuepress-theme-hope

Which operating system are you using?

Describe the bug

使用文档提供的命令创建项目后,在 theme.ts 中的 searchPro 配置 indexContent: true 时,搜索中文会导致页面报错,但 config.ts 中配置则可以正常搜索

pnpm create vuepress-theme-hope my-docs
pnpm add -D vuepress-plugin-search-pro
// theme.ts
export default hopeTheme({
  plugins: {
    searchPro: {
      indexContent: true;
    }
  }
})

这是在 theme.ts 中配置后搜索出现的错误 theme.ts配置报错

// config.ts
import { searchProPlugin } from 'vuepress-plugin-search-pro';

export default defineUserConfig({
  plugins: [
    searchProPlugin({
      indexContent: true
    }),
  ]
})

这是在 config.ts 中配置的搜索成功 config.ts配置后成功

Additional context

开发环境: node v18.20.3 npm 10.7.0 pnpm 9.4.0 项目依赖版本 "@vuepress/bundler-vite": "2.0.0-rc.14", "vue": "^3.4.27", "vuepress": "2.0.0-rc.14", "vuepress-plugin-search-pro": "2.0.0-rc.50", "vuepress-theme-hope": "2.0.0-rc.50"

Mister-Hope commented 4 months ago

A reproduction is required as everything is working fine in https://innenu.com/

github-actions[bot] commented 4 months ago

Hello @2290774104. Please provide a minimal reproduction using a GitHub repository or vuepress-theme-hope.github.io/v2-new. Issues marked with needs reproduction will be closed if they have no activity within 3 days.

abstiger commented 4 months ago

same problem

2290774104 commented 4 months ago

I created a new repository for reproducing:https://github.com/2290774104/vuepress-theme-hope_search-demo.git

github-actions[bot] commented 4 months ago

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 3 days.

github-actions[bot] commented 4 months ago

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 3 days.

github-actions[bot] commented 3 months ago

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 3 days.

Mister-Hope commented 3 months ago

Just some update I am busy with my other project and also a lot of things happened in my real life. One of my family members just passed away in last month and I had to work on some other important things.

I would likely to review this issue once I'm spare again, But i am afraid that the time table will be no longer early then October this year.

So if anyone wants to have a look at this issue, further Information about this is welcome in this thread

CuteReimu commented 4 days ago

我提供一些我发现的线索吧,希望能够有所帮助。

  1. 我最初(大约是54版本)是好的,在进行过一些版本更新(含主题版本和插件版本更新)后出现的问题。
  2. 在dev环境是好的,build才会出问题。
  3. 我尝试修改在config.ts,也是不行的。
  4. 我删掉indexContent: true,也是不行的。
  5. 我这里的报错有些不同:
Uncaught Error: SlimSearch: cannot deserialize an index created with an incompatible version
    at zt (search-pro.worker.js:1:12257)
    at search-pro.worker.js:1:173726
    at Array.map (<anonymous>)
    at search-pro.worker.js:1:173710

断点了一下看对应的位置,c值为undefined

const zt = ({index: e, documentCount: t, nextId: s, documentIds: n, fieldIds: o, fieldLength: u, averageFieldLength: i, storedFields: r, dirtCount: d, serializationVersion: c}, a) => {
    if (c !== 1 && c !== 2)
        throw new Error("SlimSearch: cannot deserialize an index created with an incompatible version");
    const h = new Et(a);

不知是否有所帮助。