nonebot-plugin-htmlrender icon indicating copy to clipboard operation
nonebot-plugin-htmlrender copied to clipboard

`*_to_pic` 工具函数不支持远程连接浏览器的场景

Open AzideCupric opened this issue 6 months ago • 2 comments

这些*_to_pic 的函数都会指定 html_to_pic 函数的 template_path 参数为某个文件 file://xxx

https://github.com/kexue-z/nonebot-plugin-htmlrender/blob/aabe39299cb4e9023e8f943db3854d2723d8f668/nonebot_plugin_htmlrender/data_source.py#L127

html_to_pic 会让浏览器 goto 这个文件

https://github.com/kexue-z/nonebot-plugin-htmlrender/blob/aabe39299cb4e9023e8f943db3854d2723d8f668/nonebot_plugin_htmlrender/data_source.py#L211-L215

但是在浏览器和nb分离部署的时候(HTMLRENDER_CONNECT=xxx),浏览器那边可能不会存在这个路径,导致爆炸。
可以考虑

  1. 添加参数goto_url="about:blank"默认跳转到goto_url
  2. template_path默认值改为"about:blank",但是html_to_pic里会检查url是否以"file://"开头,并且语义不是很明确(

发现这个的原因是 bison 想分离浏览器,但是测试炸掉了: failed test

AzideCupric avatar Oct 02 '25 11:10 AzideCupric

可以让分开后的两个目录一样可访问就行(

kexue-z avatar Oct 02 '25 12:10 kexue-z

可以让分开后的两个目录一样可访问就行(

要是出现两个容器分属不同机器的情况呢,这样保持一致会很麻烦吧

AzideCupric avatar Oct 02 '25 13:10 AzideCupric