tuna / mirror-web

Source code of the web interface of https://mirrors.tuna.tsinghua.edu.cn/
GNU General Public License v2.0
759 stars 294 forks source link

修复 bs3-polyfill.scss SHA256校验错误导致的显示异常 #420

Closed OXeu closed 4 months ago

OXeu commented 4 months ago

问题

改版后镜像站显示颜色变为深蓝色,能明显感知到显示问题 image

查看控制台发现存在错误: image

mirrors.tuna.tsinghua.edu.cn/:1 
 Failed to find a valid digest in the 'integrity' attribute for resource 'https://mirrors.tuna.tsinghua.edu.cn/assets/bs3-polyfill-D-SBFs68.css' with computed SHA-256 integrity 'P9Uwo4Jep5O8z4BWrm2n6HUmxksUVQ8dRLMNI7jK63k='. The resource has been blocked.

相关代码在 commit https://github.com/tuna/mirror-web/commit/19109103be00f0b3d8ec9c5547090c3da574dc3e 引入 https://github.com/tuna/mirror-web/blob/26dfed430fbed2d06dfe7321eca05b621b91d20b/_includes/head.html#L34

尝试删除 integrity 后恢复 image

shankerwangmiao commented 4 months ago

您好,链接的蓝色较此前饱和度提高了一些,是 Bootstrap 5 的默认颜色,是预期的效果。您指出的 bs3-polyfill.scss 的 integrity 校验失败是有意为之。因为较旧的浏览器不支持 Bootstrap 5 所依赖的 CSS 变量的功能,所以不能正常显示。该文件提供了代用的 Bootstrap3 的样式表。较新的浏览器支持验证 integrity,从而拒绝加载该文件,能正确使用 Bootstrap 5 的样式;较旧的浏览器不支持验证 integrity,从而可以加载该文件,而该文件中的选择器的级别较高,覆盖了 Bootstrap 5 的样式,使得较旧的浏览器也能基本正确显示镜像站的界面。目前我们测试的结果显示,IE11、Safari 8、Safari 10 都可以正确显示镜像站的主要界面;IE8 也可以正确显示代用页面。此外,基于终端的浏览器,如 w3m 以及 lynx 也可以正确浏览本站目录。

OXeu commented 4 months ago

了解了