diff --git a/assets/css/frontend/forum/board.css b/assets/css/frontend/forum/board.css index 039319e3..df23dd1c 100644 --- a/assets/css/frontend/forum/board.css +++ b/assets/css/frontend/forum/board.css @@ -586,6 +586,104 @@ text-shadow: 0 1px 2px rgba(0,0,0,.35); } +/* detail list card (zibll forum-posts detail) */ +.aksrt-forum-topic-row.detail, +.aksrt-forum-posts.detail { + display: block; + padding: 16px; + margin-bottom: 12px; + border-radius: 14px; + background: var(--surface-1, #fff); + box-shadow: var(--shadow-sm, 0 1px 4px rgba(0,0,0,.06)); +} +.aksrt-forum-topic-row__author-card { gap: 10px; } +.aksrt-forum-topic-row__author-name { font-weight: 700; font-size: 14px; } +.aksrt-forum-topic-row.detail .aksrt-forum-topic-row__cover, +.aksrt-forum-posts.detail .forum-lists-cover { + display: block; + width: 100%; + height: auto; + max-height: 280px; + margin: 0 0 12px; + border-radius: 12px; + overflow: hidden; +} +.aksrt-forum-topic-row.detail .aksrt-forum-topic-row__cover img { + width: 100%; + height: auto; + max-height: 280px; + object-fit: cover; + display: block; +} +.aksrt-forum-topic-row .excerpt { + margin-top: 6px; + font-size: 14px; + line-height: 1.65; + color: var(--color-ink-2, #4b5563); +} +.aksrt-forum-topic-row .lists-imgs { + display: grid; + gap: 6px; + margin-top: 8px; +} +.aksrt-forum-topic-row .lists-imgs.count-1 { grid-template-columns: 1fr; max-width: 280px; } +.aksrt-forum-topic-row .lists-imgs.count-2 { grid-template-columns: 1fr 1fr; } +.aksrt-forum-topic-row .lists-imgs.count-3, +.aksrt-forum-topic-row .lists-imgs.count-4 { grid-template-columns: 1fr 1fr; } +.aksrt-forum-topic-row .lists-imgs__item { + display: block; + border-radius: 10px; + overflow: hidden; + aspect-ratio: 1; + background: var(--surface-2, #f3f4f6); +} +.aksrt-forum-topic-row .lists-imgs__item img { + width: 100%; + height: 100%; + object-fit: cover; + display: block; +} +.aksrt-forum-topic-row__vote { display: grid; gap: 6px; } +.aksrt-forum-topic-row__vote-opt { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(80px, 2fr) 42px; + gap: 8px; + align-items: center; + font-size: 13px; +} +.aksrt-forum-topic-row__vote-bar { + height: 8px; + border-radius: 999px; + background: var(--surface-4, #eef0f3); + overflow: hidden; +} +.aksrt-forum-topic-row__vote-bar i { + display: block; + height: 100%; + background: var(--color-primary, #f04494); +} +.aksrt-forum-topic-row__footer .but-plate, +.aksrt-forum-topic-row__board.but { + display: inline-flex; + align-items: center; + max-width: 46%; + padding: 4px 10px; + border-radius: 999px; + background: var(--surface-4, #f3f4f6); + color: var(--color-ink-2, #5c6370); + text-decoration: none; + font-size: 12px; + font-weight: 600; +} +.aksrt-forum-topic-row__actions { + display: inline-flex; + gap: 12px; + color: var(--color-ink-3, #8a909c); + font-size: 13px; +} +.aksrt-forum-topic-row__actions a { color: inherit; text-decoration: none; } +.aksrt-forum-topic-row.mini { display: flex; gap: 12px; align-items: flex-start; } + .aksrt-forum-board-card__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); diff --git a/src/AKSRT/Forum/Forum.php b/src/AKSRT/Forum/Forum.php index c05b31b6..5c504996 100644 --- a/src/AKSRT/Forum/Forum.php +++ b/src/AKSRT/Forum/Forum.php @@ -250,8 +250,8 @@ class Forum { $this->view_builder()->render_board_cards($boards); } - public function render_topic_row(array $topic): void { - $this->view_builder()->render_topic_row($topic); + public function render_topic_row(array $topic, string $style = 'detail'): void { + $this->view_builder()->render_topic_row($topic, $style); } public function get_board_view(int $board_id, array $args = []): array { diff --git a/src/AKSRT/Forum/ViewBuilder.php b/src/AKSRT/Forum/ViewBuilder.php index eccd3b4a..d8a95569 100644 --- a/src/AKSRT/Forum/ViewBuilder.php +++ b/src/AKSRT/Forum/ViewBuilder.php @@ -435,58 +435,97 @@ class ViewBuilder { /** * Render a single topic row (reusable for AJAX and initial render). + * + * @param array $topic Topic payload. + * @param string $style detail|mini (zibll forum-posts parity). */ - public function render_topic_row(array $topic): void { + public function render_topic_row(array $topic, string $style = 'detail'): void { + $style = $style === 'mini' ? 'mini' : 'detail'; $board = !empty($topic['boards'][0]) ? $topic['boards'][0] : null; $names = $this->forum->get_config()['names'] ?? []; $sticky_level = (int) ($topic['sticky_level'] ?? (!empty($topic['sticky']) ? 1 : 0)); - $row_class = 'aksrt-forum-topic-row'; + $permalink = (string) ($topic['permalink'] ?? '#'); + $cover = is_array($topic['cover'] ?? null) ? $topic['cover'] : null; + $vote = is_array($topic['vote'] ?? null) ? $topic['vote'] : null; + $excerpt = trim((string) ($topic['excerpt'] ?? '')); + $topic_cat = is_array($topic['topic_cat'] ?? null) ? $topic['topic_cat'] : null; + + $row_class = 'aksrt-forum-topic-row aksrt-forum-posts forum-posts ajax-item ' . $style; if ($sticky_level > 0) { $row_class .= ' is-sticky is-sticky-' . $sticky_level; } if (!empty($topic['featured'])) { $row_class .= ' is-featured'; } - $cover = $topic['cover'] ?? null; + + $badges = ''; + if ($sticky_level > 0) { + $badges .= '' + . esc_html((string) ($topic['sticky_label'] ?? __('置顶', 'aksrt'))) . ''; + } + if (!empty($topic['featured'])) { + $badges .= '' + . esc_html__('精华', 'aksrt') . ''; + } + if (($topic['bbs_type'] ?? '') === 'question') { + $q_status = (int) ($topic['question_status'] ?? 0); + $badges .= '' + . esc_html($q_status === 1 + ? (string) ($names['question_ok_badge'] ?? __('已解决', 'aksrt')) + : (string) ($names['question_badge'] ?? __('提问', 'aksrt'))) + . ''; + } + + $title_html = $badges + . '