From 201bff5d11fcbd957cc49c83c8a3e54f985ce75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AA=E5=AD=90?= Date: Wed, 22 May 2024 14:21:07 +0800 Subject: [PATCH] =?UTF-8?q?openai=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- page-archives.php | 63 ++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/page-archives.php b/page-archives.php index aaf03b3..71c39b3 100644 --- a/page-archives.php +++ b/page-archives.php @@ -15,36 +15,49 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>

-
- publishedPostsNum)->to($archives); - $year = 0; - $mon = 0; - $i = 0; - $j = 0; +
+ publishedPostsNum)->to($archives); + $year = 0; $mon = 0; $output = '
'; - while ($archives->next()) { + + while ($archives->next()) { $year_tmp = date('Y', $archives->created); $mon_tmp = date('m', $archives->created); - $y = $year; - $m = $mon; - if ($year > $year_tmp || $mon > $mon_tmp) { - $output .= ''; + + // 检查年份和月份是否变化 + if ($year != $year_tmp) { + if ($year > 0) { + $output .= '
'; // 结束上一个年份的ul和div + } + + $year = $year_tmp; $mon = 0; // 更新年份和重置月份 + $output .= '

' . date('Y', $archives->created) . '

'; // 输出新的年份 + } + + if ($mon != $mon_tmp) { + if ($mon > 0) { + $output .= ''; // 结束上一个月份的ul + } + + $mon = $mon_tmp; // 更新月份 + $output .= '

'. date('M', $archives->created) . '

    '; // 输出新的月份和开始新的列表 + } + + // 输出文章项 + $output .= '
  • '; + $output .= '
    ' . date('m月d日', $archives->created) . '
  • '; } - if ($year != $year_tmp || $mon != $mon_tmp) { - $year = $year_tmp; - $mon = $mon_tmp; - $output .= '

    ' . date('Y年', $archives->created) . '

    -

    '. date('m月', $archives->created) .'

      - '; //输出年份 + + if ($year > 0) { + $output .= '
'; // 确保结束最后一个月份列表和div } - $output .= '
  • -
    ' . date('m月d日', $archives->created) . '
  • '; //输出文章 - } - $output .= '
    '; - echo $output;?> - + + $output .= ''; // 结束归档div + echo $output; + ?> + need('footer.php'); ?> \ No newline at end of file