From 134bb0d66c1e568845789e3a91917b1191d7a6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AA=E5=AD=90?= Date: Sun, 27 Jul 2025 13:39:53 +0800 Subject: [PATCH] 1.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加了多条公告的功能 并修改了相关描述 --- functions.php | 16 +++++++++++----- header.php | 34 ++++++++++++++++++++++++++++------ index.php | 2 +- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/functions.php b/functions.php index 220df67..a14498e 100644 --- a/functions.php +++ b/functions.php @@ -39,7 +39,7 @@ function themeConfig($form) array('0'=> _t('否'), '1'=> _t('是')), '0', _t('社交分享显示'), _t('选择"是"在文章页面显示社交分享。需要搭配插件使用,默认关闭')); $form->addInput($social); - $gonggao = new Typecho_Widget_Helper_Form_Element_Textarea('gonggao', NULL, NULL, _t('站点公告'), _t('支持HTML')); + $gonggao = new Typecho_Widget_Helper_Form_Element_Textarea('gonggao', NULL, NULL, _t('站点公告'), _t('使用格式: 标题|链接|图标
多条公告回车分隔.链接和图标可以为空.图标使用Font Awesome,如: fa-regular fa-bell')); $form->addInput($gonggao); $adlisttop = new Typecho_Widget_Helper_Form_Element_Textarea('adlisttop', NULL, NULL, _t('文章列表上方广告位'), _t('支持HTML')); $form->addInput($adlisttop); @@ -51,13 +51,19 @@ function themeConfig($form) $form->addInput($articlemid); $articlefoot = new Typecho_Widget_Helper_Form_Element_Textarea('articlefoot', NULL, NULL, _t('文章页底部广告位'), _t('支持HTML')); $form->addInput($articlefoot); - $addhead = new Typecho_Widget_Helper_Form_Element_Textarea('addhead', NULL, NULL, _t('网站验证代码'), _t('若开启无刷新加载,请在标签上加上data-instant属性')); + $addhead = new Typecho_Widget_Helper_Form_Element_Textarea('addhead', NULL, ' +', _t('网站验证代码'), _t('若开启无刷新加载,请在标签上加上data-instant属性')); $form->addInput($addhead); - $tongji = new Typecho_Widget_Helper_Form_Element_Textarea('tongji', NULL, NULL, _t('网站统计代码'), _t('支持HTML')); + $tongji = new Typecho_Widget_Helper_Form_Element_Textarea('tongji', NULL, '', _t('网站统计代码'), _t('支持HTML')); $form->addInput($tongji); - $footerinfo = new Typecho_Widget_Helper_Form_Element_Textarea('footerinfo', NULL, NULL, _t('底部关于我们'), _t('支持HTML')); + $footerinfo = new Typecho_Widget_Helper_Form_Element_Textarea('footerinfo', NULL, ' + + + + +', _t('底部关于我们'), _t('支持HTML')); $form->addInput($footerinfo); - $footercopyright = new Typecho_Widget_Helper_Form_Element_Textarea('footercopyright', NULL, NULL, _t('底部版权信息'), _t('支持HTML')); + $footercopyright = new Typecho_Widget_Helper_Form_Element_Textarea('footercopyright', NULL, '版权所有 转载请注明出处', _t('底部版权信息'), _t('支持HTML')); $form->addInput($footercopyright); $sidebarBlock = new \Typecho\Widget\Helper\Form\Element\Checkbox( 'sidebarBlock', diff --git a/header.php b/header.php index b7ae25e..3f22fe6 100644 --- a/header.php +++ b/header.php @@ -177,12 +177,34 @@
- +options->gonggao; +if ($gonggao) { + // 按行分割 + $lines = explode("\n", $gonggao); + foreach ($lines as $line) { + $parts = explode('|', $line); + // 只处理格式正确的行 + if (count($parts) >= 3) { + $title = trim($parts[0]); + $url = trim($parts[1]); + $icon = trim($parts[2]); + // 链接为空时使用 javascript:void(0) + $href = $url !== '' ? htmlspecialchars($url) : 'javascript:void(0)'; + // 图标为空时使用默认 + $icon_class = $icon !== '' ? $icon : 'fa-regular fa-bell'; + // 输出 HTML + echo ''; + } + } +} +?>
diff --git a/index.php b/index.php index d4e6134..243d931 100644 --- a/index.php +++ b/index.php @@ -4,7 +4,7 @@ * * @package Typecho Pouck Theme * @author 老孙博客 - * @version 1.2.0 + * @version 1.2.1 * @link http://www.imsun.org */