nolebase / integrations

A collection of diverse documentation engineering tools | 多元化的文档工程工具合集
https://nolebase-integrations.ayaka.io
MIT License
66 stars 9 forks source link

improve: duplicate git exec in hmr of git changelog plugin #207

Open northword opened 2 weeks ago

northword commented 2 weeks ago

HMR 中重复的 Git 请求。

当前在 changelog.vue 中和 contributors.vue 中分别 send 了一次,这导致 Git 实际上被运行了两次(即使有设置的缓存,但是似乎因为两次执行的太近了,导致两次都是实际运行了 Git 的,从下面这个日志可以看出:

image

nekomeowww commented 2 weeks ago

不知道配合 VueUse 的 useMounted + watch 能不能做一个更好的 store 共享一下。

northword commented 2 weeks ago

刚刚试了试在 client throttle ,似乎不可行。

也许可以在 vite 端做 throttle ;

或者做一个更大的组件,把 Changelog 和 Contributor 都放进来,这样就只需要在这个更大的组件里 import.meta.hot.send ,这样就可以避免两个组件都发送。

useMounted + watch 这种我不太清楚怎么实现。