Joe主题替换jsdelivr的js、css文件 - 星泽V社

星泽
2022-05-17 / 5 评论 / 643 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年05月19日,已超过40天没有更新,若内容或图片失效,请留言反馈。

众所周知,在去年年底,知名的免费cdn服务提供商jsdelivr由于大陆域名备案的问题,没有国内的CDN加速了,目前都只能解析到海外,不但速度慢,还会偶发性无法连接到服务器。因此国内超多网站都受到了影响。现在cdn.jsdelivr.net被墙,国内打不开这导致大部分网站js与css失效,所以要把jsdelivr的js和css替换一下,我选择直接替换到本地。
下面放我改好的文件,替换主题的原文件即可。
执念二开joe主题链接: https://zhinianblog.com/archives/993/
只适用于执念二开Joe主题,官方原版暂未支持!
只适用于执念二开Joe主题,官方原版暂未支持!
只适用于执念二开Joe主题,官方原版暂未支持!
只适用于执念二开Joe主题,官方原版暂未支持!
只适用于执念二开Joe主题,官方原版暂未支持!
只适用于执念二开Joe主题,官方原版暂未支持!

l39jlsrs.png

joe/post.php 文件里的head标签替换为下列代码

<head>
    <?php $this->need('public/include.php'); ?>
    <?php if ($this->options->JPrismTheme) : ?>
        <link rel="stylesheet" href="<?php $this->options->JPrismTheme() ?>">
    <?php else : ?>
        <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/prism.min.css'); ?>">
    <?php endif; ?>
    <script src="<?php $this->options->themeUrl('assets/js/clipboard.min.js'); ?>"></script>
    <script src="<?php $this->options->themeUrl('assets/js/prism.min.js'); ?>"></script>
    <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.post.min.css'); ?>">
    <script src="<?php $this->options->themeUrl('assets/js/joe.post_page.min.js'); ?>"></script>

</head>

joe/page.php 内的head标签修改为下列代码

<head>
    <?php $this->need('public/include.php'); ?>
    <?php if ($this->options->JPrismTheme) : ?>
        <link rel="stylesheet" href="<?php $this->options->JPrismTheme() ?>">
    <?php else : ?>
        <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/prism.min.css'); ?>">
    <?php endif; ?>
    <script src="<?php $this->options->themeUrl('assets/js/clipboard.min.js'); ?>"></script>
    <script src="<?php $this->options->themeUrl('assets/js/prism.min.js'); ?>"></script>
    <script src="<?php $this->options->themeUrl('assets/js/joe.post_page.min.js'); ?>"></script>

</head>

joe/archive.php 内的head标签修改为下列代码

<head>
    <?php $this->need('public/include.php'); ?>
    <script src="<?php $this->options->themeUrl('assets/js/wow.min.js'); ?>"></script>
    <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.archive.min.css'); ?>">
    <script src="<?php $this->options->themeUrl('assets/js/joe.archive.min.js'); ?>"></script>
</head>

还有一个地方是代码高亮的调用,把 joe/functions.php 内的代码高亮的调用修改为下列代码(js已经放在文件里了,直接调用即可)

           $JPrismTheme = new Typecho_Widget_Helper_Form_Element_Select(
        'JPrismTheme',
        array(
            '/usr/themes/Joe/assets/css/prism.min.css' => 'prism(默认)',
            '/usr/themes/Joe/assets/css/prism-dark.min.css' => 'prism-dark',
            '/usr/themes/Joe/assets/css/prism-okaidia.min.css' => 'prism-okaidia',
            '/usr/themes/Joe/assets/css/prism-solarizedlight.min.css' => 'prism-solarizedlight',
            '/usr/themes/Joe/assets/css/prism-tomorrow.min.css' => 'prism-tomorrow',
            '/usr/themes/Joe/assets/css/prism-twilight.min.css' => 'prism-twilight',
            '/usr/themes/Joe/assets/css/prism-a11y-dark.min.css' => 'prism-a11y-dark',
            '/usr/themes/Joe/assets/css/prism-atom-dark.min.css' => 'prism-atom-dark',
            '/usr/themes/Joe/assets/css/prism-base16-ateliersulphurpool.light.min.css' => 'prism-base16-ateliersulphurpool.light',
            '/usr/themes/Joe/assets/css/prism-cb.min.css' => 'prism-cb',
            '/usr/themes/Joe/assets/css/prism-coldark-cold.min.css' => 'prism-coldark-cold',
            '/usr/themes/Joe/assets/css/prism-coldark-dark.min.css' => 'prism-coldark-dark',
            '/usr/themes/Joe/assets/css/prism-darcula.min.css' => 'prism-darcula',
            '/usr/themes/Joe/assets/css/prism-dracula.min.css' => 'prism-dracula',
            '/usr/themes/Joe/assets/css/prism-duotone-dark.min.css' => 'prism-duotone-dark',
            '/usr/themes/Joe/assets/css/prism-duotone-earth.min.css' => 'prism-duotone-earth',
            '/usr/themes/Joe/assets/css/prism-duotone-forest.min.css' => 'prism-duotone-forest',
            '/usr/themes/Joe/assets/css/prism-duotone-light.min.css' => 'prism-duotone-light',
            '/usr/themes/Joe/assets/css/prism-duotone-sea.min.css' => 'prism-duotone-sea',
            '/usr/themes/Joe/assets/css/prism-duotone-space.min.css' => 'prism-duotone-space',
            '/usr/themes/Joe/assets/css/prism-ghcolors.min.css' => 'prism-ghcolors',
            '/usr/themes/Joe/assets/css/prism-gruvbox-dark.min.css' => 'prism-gruvbox-dark',
            '/usr/themes/Joe/assets/css/prism-hopscotch.min.css' => 'prism-hopscotch',
            '/usr/themes/Joe/assets/css/prism-lucario.min.css' => 'prism-lucario',
            '/usr/themes/Joe/assets/css/prism-material-dark.min.css' => 'prism-material-dark',
            '/usr/themes/Joe/assets/css/prism-material-light.min.css' => 'prism-material-light',
            '/usr/themes/Joe/assets/css/prism-material-oceanic.min.css' => 'prism-material-oceanic',
            '/usr/themes/Joe/assets/css/prism-night-owl.min.css' => 'prism-night-owl',
            '/usr/themes/Joe/assets/css/prism-nord.min.css' => 'prism-nord',
            '/usr/themes/Joe/assets/css/prism-pojoaque.min.css' => 'prism-pojoaque',
            '/usr/themes/Joe/assets/css/prism-shades-of-purple.min.css' => 'prism-shades-of-purple',
            '/usr/themes/Joe/assets/css/prism-synthwave84.min.css' => 'prism-synthwave84',
            '/usr/themes/Joe/assets/css/prism-vs.min.css' => 'prism-vs',
            '/usr/themes/Joe/assets/css/prism-vsc-dark-plus.min.css' => 'prism-vsc-dark-plus',
            '/usr/themes/Joe/assets/css/prism-xonokai.min.css' => 'prism-xonokai',
            '/usr/themes/Joe/assets/css/prism-onelight.min.css' => 'prism-onelight',
            '/usr/themes/Joe/assets/css/prism-onedark.min.css' => 'prism-onedark',
            '/usr/themes/Joe/assets/css/prism-onedark2.min.css' => 'prism-onedark2',
        ),
        '//cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism.min.css',
        '选择一款您喜欢的代码高亮样式',
        '介绍:用于修改代码块的高亮风格 <br>
         其他:如果您有其他样式,可通过源代码修改此项,引入您的自定义样式链接'
    );
    $JPrismTheme->setAttribute('class', 'joe_content joe_post');
    $form->addInput($JPrismTheme->multiMode());

l39jpzps.png
这里的Joe是我的主题目录,如果你的不是就改成你的目录名。

写的比较匆忙,先备份主题再测试,有问题及时反馈。

2022/5/19:
再次说明,需要修改的四个文件没放替换版文件是因为怕你们自己修改过,如果替换了,你们自己修改的东西会丢失,所以才手动修改代码。
有说替换文件不全的,确实不全,比如二次元动态模型的js引用没有替换,但影响使用的js、css一定是完整的。至于说我教程有问题的,麻烦确认下自己修改的文件对不对,主题目录名对不对,是吧,我也只是尽量的提供帮助,没必要网络暴力吧,为什么别人跟着我教程就没问题?是不是改考虑考虑自己的问题?

再次提醒:
做好备份!
做好备份!
最好备份!

本文来源于星泽V社,未经允许禁止转载,原文链接: https://www.52xzv.cn/archives/728.html

本文共 643 个字数,平均阅读时长 ≈ 2分钟

评论 (5)

取消
  1. 头像
    young Lv.1
    Windows 10 · Google Chrome
    沙发

    完了。我的被我整挂了

    回复 删除 垃圾
    1. 头像
      星泽 Lv.4 作者
      Windows 10 · Google Chrome
      @ young

      哪有问题?

      回复 删除 垃圾
  2. 头像
    QQ:764293729 Lv.1
    Windows 10 · Google Chrome
    板凳

    漂亮,替换完之后,成功废了~~请求支援~~~~ 看到加我QQ :764293729

    回复 删除 垃圾
    1. 头像
      星泽 Lv.4 作者
      Android · Google Chrome
      @ QQ:764293729

      1

      回复 删除 垃圾
  3. 头像
    Lv.1
    Android · Google Chrome
    地毯

    我用joe模板电脑访问首页就是一个一直在加载的状态不出内容,换别的模板就没这个问题,有什么方法解决吗?

    回复 删除 垃圾