koishijs / webui

WebUI plugins for Koishi
https://koishi.online
GNU Affero General Public License v3.0
30 stars 15 forks source link

Bug: vite fs.strict 导致 webui 的 router 无法找到 path "/" #301

Closed Lipraty closed 9 months ago

Lipraty commented 9 months ago

Describe the bug

在尝试开发 webui 时,会遇到如下 terminal错误:

The request url "/workspace/path/node_modules/koishi-plugin-theme-vanilla/dist/style.css" is outside of Vite serving allow list.

- /workspace/path/external/webui
- /workspace/path/node_modules/vite/dist/client

Refer to docs https://vitejs.dev/config/server-options.html#server-fs-allow for configurations and more details.

The request url "/workspace/path/node_modules/koishi-plugin-dataview/dist/style.css" is outside of Vite serving allow list.
The request url "/workspace/path/node_modules/koishi-plugin-theme-vanilla/dist/index.js" is outside of Vite serving allow list.
The request url "/workspace/path/node_modules/koishi-plugin-dataview/dist/index.js" is outside of Vite serving allow list.
The request url "/workspace/path/node_modules/koishi-plugin-theme-vanilla/dist/style.css" is outside of Vite serving allow list.
The request url "/workspace/path/node_modules/koishi-plugin-dataview/dist/style.css" is outside of Vite serving allow list.

尝试修改配置项以关闭:

# koishi.yml

...
    console:lz8buy:
      open: false
      devMode: true
      dev:
        fs:
          strict: false
...

terminal 无报错,但浏览器循环在 console 输出 [Vue Router warn]: No match found for location with path "/"

应当是 fs.strict 导致 router 无法找到 path 的问题

Steps to reproduce

  1. 创建全新 bp
  2. 在 p.j 中删除 webui 相关依赖
  3. 使用 git clone https://github.com/koishijs/webui/git ./external/webui 下载 webui 仓库
  4. 使用 yarn dev 启动,此时 terminal 提示 The request url "/workspace/path/node_modules/koishi-plugin-theme-vanilla/dist/style.css" is outside of Vite serving allow list.
  5. 修改 koishi.ymlconsole.dev.fs.strict: false 关闭 strict
  6. terminal 无提示,但浏览器 console 提示 [Vue Router warn]: No match found for location with path "/"

Expected behavior

能够正常路由

Screenshots

No response

Versions

Additional context

No response

shigma commented 9 months ago

已复现。

前一半问题可能会考虑将 node_modules 引入默认的 allow list 来解决。

后一半的问题过于诡异,我没有研究出原因或解决办法。代码中唯一的 beforeEach 片段,我在里面打 console.log 有输出,但是我把代码注释掉依然会在此处报错。如果在其中断点会直接导致网页崩溃。

shigma commented 9 months ago

不确定有没有修对。

Lipraty commented 9 months ago

fixed.