From 4dcaefb291d7f0e6bc69aa5c34d703c08414fdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AA=E5=AD=90?= Date: Mon, 4 Aug 2025 17:00:37 +0800 Subject: [PATCH] 1.2.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用评论实现说说的功能 --- .gitignore | 2 + comments.php | 2 +- functions.php | 55 ++++++++------- index.php | 2 +- page-full.php | 2 +- page-says.php | 182 +++++++++++++++++++++++++++++++++++++++++++++++++ page-talks.php | 174 ---------------------------------------------- 7 files changed, 219 insertions(+), 200 deletions(-) create mode 100644 page-says.php delete mode 100644 page-talks.php diff --git a/.gitignore b/.gitignore index 2d19fc7..3d9435a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.html +/.vercel +page-talks copy.php diff --git a/comments.php b/comments.php index a8de73e..318536d 100644 --- a/comments.php +++ b/comments.php @@ -171,7 +171,7 @@
- date('Y-m-d H:i:s'); ?> + created); ?> 回复
diff --git a/functions.php b/functions.php index bb0506b..4e16326 100644 --- a/functions.php +++ b/functions.php @@ -92,6 +92,16 @@ function themeFields($layout) { $layout->addItem($cover); } +/** 头像镜像加速全局设置 + * @param $email + * @param $size + * @param $default + * @return string +*/ +$options = Typecho_Widget::widget('Widget_Options'); +$gravatarPrefix = empty($options->cnavatar) ? 'https://cravatar.cn/avatar/' : $options->cnavatar; +define('__TYPECHO_GRAVATAR_PREFIX__', $gravatarPrefix); + /* * 文章浏览数统计 */ @@ -1437,26 +1447,25 @@ function get_site_statistics() { ]; } -// Typecho AJAX 登录接口,支持前端 AJAX 提交并返回 JSON -//if (!empty($_GET['ajaxLogin']) && $_GET['ajaxLogin'] == 1) { -// header('Content-Type: application/json; charset=utf-8'); -// if ($_SERVER['REQUEST_METHOD'] !== 'POST') { -// echo json_encode(['success' => false, 'msg' => '请求方式错误']); -// exit; -// } -// $name = isset($_POST['name']) ? trim($_POST['name']) : ''; -// $password = isset($_POST['password']) ? $_POST['password'] : ''; -// $referer = isset($_POST['referer']) ? $_POST['referer'] : '/'; -// if (!$name || !$password) { -// echo json_encode(['success' => false, 'msg' => '用户名或密码不能为空']); -// exit; -// } -// $user = Typecho_Widget::widget('Widget_User'); -// try { -// $user->login($name, $password, isset($_POST['remember']) ? 1 : 0); -// echo json_encode(['success' => true, 'msg' => '登录成功', 'redirect' => $referer]); -// } catch (Typecho_Exception $e) { -// echo json_encode(['success' => false, 'msg' => $e->getMessage()]); -// } -// exit; -//} \ No newline at end of file +/** + * 友好时间显示函数 + * @param $timestamp + * @return string + */ +function friendly_date($timestamp) { + $time = is_numeric($timestamp) ? $timestamp : strtotime($timestamp); + $diff = time() - $time; + if ($diff < 60) { + return '刚刚'; + } elseif ($diff < 3600) { + return floor($diff / 60) . '分钟前'; + } elseif ($diff < 86400) { + return floor($diff / 3600) . '小时前'; + } elseif ($diff < 2592000) { + return floor($diff / 86400) . '天前'; + } elseif ($diff < 31536000) { + return floor($diff / 2592000) . '月前'; + } else { + return date('Y-m-d H:i:s', $time); + } +} \ No newline at end of file diff --git a/index.php b/index.php index bd2f9c7..e8159f6 100644 --- a/index.php +++ b/index.php @@ -5,7 +5,7 @@ * * @package Typecho Pouck Theme * @author 老孙博客 - * @version 1.2.2 + * @version 1.2.3 * @link http://www.imsun.org */ diff --git a/page-full.php b/page-full.php index 51a8368..563254d 100644 --- a/page-full.php +++ b/page-full.php @@ -16,7 +16,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
-
+

content(); ?>

diff --git a/page-says.php b/page-says.php new file mode 100644 index 0000000..31b9407 --- /dev/null +++ b/page-says.php @@ -0,0 +1,182 @@ +need('header.php'); +?> + +
+
+ options->showsidebar): ?> +
+ +
+ + user->hasLogin()) { + $GLOBALS['isLogin'] = true; + } else { + $GLOBALS['isLogin'] = false; + } + + // 评论回调函数 + function threadedComments($comments, $options) { + $mail = $comments->mail; + $mailHash = md5(strtolower(trim($mail))); + $purl = $comments->url; + $nickname = $comments->author; + $cnavatar = Helper::options()->cnavatar ? Helper::options()->cnavatar : 'https://cravatar.cn/avatar/'; + $avatarurl = rtrim($cnavatar, '/') . '/' . $mailHash . '?s=80&d=identicon'; + $loadingImg = Helper::options()->themeUrl . '/assets/img/load.svg'; + ?> +
+
+ +
+
+
+ parent) {echo getPermalinkFromCoid($comments->parent);} echo parse_smiley_shortcode($comments->content);?> +
+ +
+
+
+
+ + comments()->to($comments); ?> + have()): ?> + user->hasLogin() && $this->user->group == 'administrator') : ?> +
+ +
+ + 有什么新鲜事 + +
+
+
+
+ +
+ + + + +
+
+ options->social): ?> + + + + +
+
+
+
+
+ + + next()): ?> + options); ?> + + +
+ pageNav('«', '»', 1, '...', array( + 'wrapTag' => 'ul', + 'wrapClass' => 'pagination comment-ajax-load', + 'itemTag' => 'li', + 'textTag' => 'span', + 'currentClass' => 'active', + 'prevClass' => 'prev', + 'nextClass' => 'next' + )); ?> +
+
+ + options->showsidebar): ?> + need('sidebar.php'); ?> + +
+
+need('footer.php'); ?> + \ No newline at end of file diff --git a/page-talks.php b/page-talks.php deleted file mode 100644 index a2a42bf..0000000 --- a/page-talks.php +++ /dev/null @@ -1,174 +0,0 @@ - -need('header.php'); ?> -