vuepress / ecosystem

Official plugins and themes for VuePress2
https://ecosystem.vuejs.press
MIT License
29 stars 41 forks source link

[Bug report] Incorrect base in plugin-docsearch #227

Closed SherkeyXD closed 3 months ago

SherkeyXD commented 3 months ago

Description

When the base is not the root, like /docs, something weird is happening. Left click the search result, you got the right base, like /docs. However, if you press enter, the base is repeated twice, like /docs/docs.

I think this maybe be related to 7e56412, where two different bases appear.

https://github.com/vuepress/ecosystem/blob/2a4768d1391b22570190d39a0a1a7730fc752e58/plugins/search/plugin-docsearch/src/client/composables/useDocsearchShim.ts#L31

https://github.com/vuepress/ecosystem/blob/2a4768d1391b22570190d39a0a1a7730fc752e58/plugins/search/plugin-docsearch/src/client/composables/useDocsearchShim.ts#L50

One is __DOCSEARCH_INDEX_BASE__, and the other is __VUEPRESS_BASE__.

Reproduction

https://github.com/MaaAssistantArknights/MaaAssistantArknights/tree/dev/docs

Used Package Manager

pnpm

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 1.35 GB / 15.63 GB
  Binaries:
    Node: 20.9.0 - ~\AppData\Local\fnm_multishells\21264_1722010991173\node.EXE
    Yarn: Not Found
    npm: 10.8.2 - ~\AppData\Local\fnm_multishells\21264_1722010991173\npm.CMD
    pnpm: 9.1.4 - ~\AppData\Local\fnm_multishells\21264_1722010991173\pnpm.CMD
    bun: Not Found
  Utilities:
    Git: 2.45.1.
  Browsers:
    Chrome: Not Found
    Edge: Chromium (126.0.2592.113)
  npmPackages:
    @vuepress/bundler-vite: 2.0.0-rc.14 => 2.0.0-rc.14
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli: Not Found
    @vuepress/client: Not Found
    @vuepress/core: Not Found
    @vuepress/markdown: Not Found
    @vuepress/shared: Not Found
    @vuepress/utils: Not Found
    vue: ^3.4.33 => 3.4.33
    vue-router: Not Found
    vuepress: 2.0.0-rc.14 => 2.0.0-rc.14
Mister-Hope commented 3 months ago

I think this is a basic that you should use the latest v2 before opening any issues.

github-actions[bot] commented 3 months ago

Hello @SherkeyXD. This issue is marked as invalid and closed. Please follow the issue template.

SherkeyXD commented 3 months ago

I've already tested locally with the newest version when writing this issue, and the problem still exists. Here are the dependencies in my local machine.

"devDependencies": {
    "@vuepress/bundler-vite": "2.0.0-rc.14",
    "@vuepress/plugin-docsearch": "2.0.0-rc.40",
    "@vuepress/plugin-google-analytics": "2.0.0-rc.37",
    "@vuepress/plugin-shiki": "^2.0.0-rc.40",
    "markdown-it": "^14.1.0",
    "markdown-it-anchor": "^9.0.1",
    "vue": "^3.4.33",
    "vuepress": "2.0.0-rc.14",
    "vuepress-theme-hope": "2.0.0-rc.52"
},

And the commit 7e56412 first appears in v2.0.0-rc.39, which is just the deployed version.

SherkeyXD commented 3 months ago

The problem is that the MouseEvent event and keydown event result in different base paths. In v2.0.0-rc.38 they are the same.

Edit: the href is correct, so the problem should be the keydown event.

Mister-Hope commented 3 months ago

Then you should provide a reproducion