Skip to content

[Bug] Windows 下 WebUI 将 SVG 返回为错误 MIME 类型,导致插件默认图标和 favicon 破图 #9734

Description

@YacratesWyh

Description

环境

  • AstrBot:v4.27.3
  • 操作系统:Windows
  • 浏览器:Google Chrome
  • WebUI:http://:6185/#/extension/plugins
    问题现象
    “插件 → 已安装”页面中,没有自带 logo.png 的插件全部显示破图,图片位置显示插件名称的 alt 文本。同时浏览器标签页的 AstrBot favicon 也无法正常显示。
    远程插件市场图片和代理连接均正常,因此与 HTTP proxy 无关。

实际响应
GET /favicon.svg
HTTP/1.1 200
Content-Type: image/svg
image/svg 不是标准 SVG MIME 类型。Chrome 在 中无法正常渲染该资源。
正确类型应为:
Content-Type: image/svg+xml
根因
Windows 的 Python mimetypes 可能根据系统注册表将 .svg 识别为 image/svg。WebUI 静态文件服务沿用了这个 MIME 映射。
前端已安装插件卡片在插件没有 logo.png 时会回退到 /favicon.svg,因此所有此类插件同时破图。
临时修复
在 dashboard server 初始化时显式注册 SVG MIME:
import mimetypes

mimetypes.add_type("image/svg+xml", ".svg", strict=True)
例如放在:
astrbot/dashboard/server.py
服务重启后验证:
GET /favicon.svg
HTTP/1.1 200
Content-Type: image/svg+xml
随后在 Chrome 中执行一次忽略缓存的强制刷新,插件默认图标和标签页 favicon 即恢复正常。
建议修复
在 WebUI 静态文件服务初始化前显式设置 .svg 的标准 MIME 类型,避免依赖 Windows 系统注册表中的 MIME 映射。

Reproduction Steps

复现步骤

  1. 在 Windows 上启动 AstrBot v4.27.3。
  2. 使用 Chrome 打开 WebUI。
  3. 进入“插件 → 已安装”。
  4. 查看没有自定义 logo 的插件卡片。
    这些插件会回退使用 /favicon.svg,但图片无法显示。

AstrBot Version

latest

Operating System

Windows

Deployment Method

uv

Message Platform Adapter

onebot

Error Log

1

Supplementary Information

No response

Checklist

  • I have searched the Issue list for related issues and could not resolve the problem, or this issue has never been reported before.
  • I have tried disabling all plugins to rule out issues caused by plugins.
  • The issue I am reporting is related to AstrBot itself, not to a specific plugin.
  • I have read and agree to the project's Code of Conduct.
  • (Optional) I am willing to submit a PR to help fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:webuiThe bug / feature is about webui(dashboard) of astrbot.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions