Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

主题的所有排版失效 #289

Closed
MuuuShin opened this issue May 25, 2022 · 8 comments
Closed

主题的所有排版失效 #289

MuuuShin opened this issue May 25, 2022 · 8 comments

Comments

@MuuuShin
Copy link

在几天之前,Sakura的主题突然无法正常使用,具体表现为所有排版都消失,页面变回类似ie兼容模式的风格。
切换为其他预设主题能正常展示主题。
下载全新的3.4.0Sakura主题并安装仍会遇见排版问题。
更改php版本(72->80)也无效。
升级wp无效。

bug 重现步骤
未在过去的几周内对blog有任何操作。

我自己的blog(https://www.mushin.top/)
image

另一位的blog(http://yorunina.cn/)
image

系统信息

  • chrome、edge
  • PHP 版本:72
  • WordPress 版本:6.0.0
  • Sakura 主题版本:3.4.0
@AdminXYZ666
Copy link

好像是因为jsdelivr的问题

@huangguiniab
Copy link

huangguiniab commented May 25, 2022

jsdelivr彻底凉了,导致CSS样式表无法加载,部分JS库也无法加载。

对于您自己的站点,要彻底解决该问题,请进入sakura主题设置→CDN,勾选'本地调用前端库(lib.js、lib.css)',和'本地调用主题 js、css 文件(sakura-app.js、style.css)'这两个选项。保存并应用。

对于他人的站点,请联系或者留下评论给博主,让他们手动开启这两个选项。

最后,实在没办法的办法就是浏览博客的时候始终使用代理等办法。

@mashirozx
Copy link
Owner

mashirozx commented May 25, 2022

欢迎pr,把全部资源移到本地(狗头

@MuuuShin
Copy link
Author

jsdelivr彻底凉了,导致CSS样式表无法加载,部分JS库也无法加载。

对于您自己的站点,要彻底解决该问题,请进入sakura主题设置→CDN,勾选'本地调用前端库(lib.js、lib.css)',和'本地调用主题 js、css 文件(sakura-app.js、style.css)'这两个选项。保存并应用。

对于他人的站点,请联系或者留下评论给博主,让他们手动开启这两个选项。

最后,实在没办法的办法就是浏览博客的时候始终使用代理等办法。

感谢!

@AdminXYZ666
Copy link

已经在一个一个转到本地了(滑稽)
https://mihoyo.wiki
欢迎来访,顺便看看还有没有地方有问题

@huangguiniab
Copy link

另外还有一个问题,就是就算勾选了这两个选项,还是有些资源会从访问不到的地方获取,比如切换夜间主题和'Discovery'左边的树叶形状图标一直加载不出来。虽然说不影响网页使用,但是网页的加载进度条会一直显示直到加载失败。

@mashirozx
Copy link
Owner

批量替换jsdelivr资源镜像的方法

在wp_content/themes目录下运行:

sed -i "s/cdn.jsdelivr.net/jsdelivr.2heng.xin/g" `grep -rl 'cdn.jsdelivr.net' Sakura`

其中 jsdelivr.2heng.xin 需要自行替换成自己的 jsdelivr 镜像域名,镜像配置如下(Nginx):

# 缓存路径配置
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;

# referer 白名单
map $http_referer $jsdelivr_allow_referer {
    default              0;
    "~2heng.xin"         1; 
    "~mashiro.top"       1;
}

map $jsdelivr_allow_referer $jsdelivr_disallow_referer {
    0     1;
    1     "";
}

server {
    listen 443 ssl http2;
    server_name jsdelivr.2heng.xin;

   # ssl 配置
    ssl_certificate ~/.acme.sh/mashiro/fullchain.cer;
    ssl_certificate_key ~/.acme.sh/mashiro/mashiro.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;

    # 关闭日志
    access_log off;
   # 指定 DNS
    resolver 8.8.8.8;

    if ($jsdelivr_disallow_referer) {
        return 403 "The referer domain is not allowed to access this resource.";
    }

    location / {
        proxy_redirect off;
        proxy_pass https://fastly.jsdelivr.net;
        proxy_cache_revalidate on;
        proxy_set_header Host cdn.jsdelivr.net;

        proxy_cache CACHE;
        # 客户端的缓存时长
        proxy_cache_valid 200 1h;
        proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
        proxy_cache_lock on;
       # 服务器端的缓存时长
        expires 1h;
    }
}

以上需要在境外服务器上配置。如果没有海外服务器需要使用我的镜像,请通过QQ联系我。

@mashirozx
Copy link
Owner

参见 #290

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants