diff options
| author | Kurococ Liu <21096362+KurococLiu@users.noreply.github.com> | 2022-10-23 12:58:52 +0800 |
|---|---|---|
| committer | Kurococ Liu <21096362+KurococLiu@users.noreply.github.com> | 2022-10-23 12:58:52 +0800 |
| commit | f142d61f01fc57cf7befe2cc71cc8a3f8b0fdc82 (patch) | |
| tree | 6242be98d3fa0303dea38168558b8fd4ab65c04f | |
| parent | d9e677d6cd90b9c868d505f5177868090dbf1842 (diff) | |
:newspaper: Add: 加入preconnect、字数统计,Readme新增公益CDN名单
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | includes/head.php | 8 | ||||
| -rw-r--r-- | libs/Matcha.php | 36 | ||||
| -rw-r--r-- | libs/Options.php | 12 |
4 files changed, 62 insertions, 2 deletions
@@ -93,6 +93,14 @@ Matcha 主题采用[语义化版本 2.0.0](https://semver.org/lang/zh-CN/) 标å‡ [Pixabay 用户 - OpenClipart-Vectors](https://pixabay.com/zh/vectors/screaming-surprised-smiley-emotion-146426/):提供 404 页面使用的矢量图 + +#### 公益CDN + +[Cravatar](https://cravatar.cn/) | +[cdnjs](https://cdnjs.cloudflare.com/) | +[字节跳动静态资源公共库](https://cdn.bytedance.com/) + + --- Copyright © 2022 SumiMakito, memset0 & Eltrac, under GPL v3.0 License. diff --git a/includes/head.php b/includes/head.php index 19f0ab2..4c02fad 100644 --- a/includes/head.php +++ b/includes/head.php @@ -3,9 +3,15 @@ <html> <head> <meta charset="<?php $this->options->charset(); ?>"> + <!-- IE 8浏览器的页面渲染方式 & 默认使用极速内核:针对国内浏览器产商 --> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="renderer" content="webkit"> - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> + <!-- 自适应 --> + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no"> + <!-- 关闭百度转码 --> + <meta http-equiv="x-dns-prefetch-control" content="on"> + <meta http-equiv="Cache-Control" content="no-transform"> + <meta http-equiv="Cache-Control" content="no-siteapp"> <?php //设置 favicon if($this->options->favicon){ ?> <link rel="icon" type="image/x-icon" href="<?php $this->options->favicon(); ?>"> diff --git a/libs/Matcha.php b/libs/Matcha.php index 1ec3c39..fd6135b 100644 --- a/libs/Matcha.php +++ b/libs/Matcha.php @@ -12,6 +12,7 @@ class Matcha * 包括 css 引用、标题 */ public static function head() { + Matcha::preconnect(); Matcha::linkCSS(); Matcha::iconfont(); Helper::options()->customHead(); @@ -68,7 +69,32 @@ class Matcha echo '" />'; } } - + + /** + * 输出 preconnect 标签 + */ + public static function preconnect() { + if(isset(Helper::options()->StaticCDN) && Helper::options()->StaticCDN!='local'){ + if(Helper::options()->StaticCDN=='bytedance'){ + $src_link = array( + '//lf3-cdn-tos.bytecdntp.com/', + '//lf9-cdn-tos.bytecdntp.com/', + '//lf26-cdn-tos.bytecdntp.com/', + ); + } + elseif(Helper::options()->StaticCDN=='cdnjs'){ + $src_link = array( + '://cdnjs.cloudflare.com/', + ); + } + echo '<!-- 预连接 -->'; + foreach($src_link as $value){ + echo '<link rel="preconnect" href="'.$value.'" />'; + } + + } + } + /** * 引用 iconfont */ @@ -290,6 +316,14 @@ class Matcha */ static public function footerInfo() { + //字数统计 + if (Helper::options()->EnableWordsCounter=='able') { + + echo '<br />'; + echo '一共书写了'; + WordsCounter_Plugin::allOfCharacters(); + echo '字'; + } //备案号 if (Helper::options()->icpNum!='') { echo '<br />'; diff --git a/libs/Options.php b/libs/Options.php index fde322b..04384c0 100644 --- a/libs/Options.php +++ b/libs/Options.php @@ -133,6 +133,18 @@ function themeConfig($form) { ') ); $form->addInput($EnableBusuanzi->addRule('required', _t('此处必须设置'))); + //启用字数统计 + $EnableWordsCounter = new Typecho_Widget_Helper_Form_Element_Radio('EnableWordsCounter', array( + 'able' => _t('启用'), + 'disable' => _t('停用'), + ), + 'able', + _t('是否启用 <a rel="nofollow" target="_blank" href="https://github.com/elatisy/Typecho_WordsCounter">字数统计</a> 功能'), + _t(' + <a rel="nofollow" target="_blank" href="https://github.com/elatisy/Typecho_WordsCounter">字数统计</a>是一个基于WordsCounter插件统计全站字数的,<b>默认启用</b> + ') + ); + $form->addInput($EnableWordsCounter->addRule('required', _t('此处必须设置'))); /** * 自定义 & 开发者设置 |
