diff --git a/assets/style.css b/assets/style.css index 516363d..6cef4ca 100644 --- a/assets/style.css +++ b/assets/style.css @@ -81,7 +81,15 @@ main.wrap{padding-top:24px; padding-bottom:40px; min-height:60vh} .page-head h1{margin-bottom:4px} .page-head .muted{font-size:14px; margin:0} -/* ---------- 筛选 ---------- */ +/* ---------- 软件切换(一级) ---------- */ +.software-bar{ + display:flex; flex-wrap:wrap; align-items:center; gap:8px; + margin-bottom:14px; padding-bottom:14px; border-bottom:1px solid var(--line); +} +.software-bar .sw-label{font-size:13.5px; color:var(--muted); font-weight:600} +.software-bar .chips{margin-bottom:0} + +/* ---------- 筛选(二级:分类 / 状态) ---------- */ .filters{margin-bottom:16px} .chips{display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px} .chip{ diff --git a/index.php b/index.php index d2861ae..52ca0ce 100644 --- a/index.php +++ b/index.php @@ -4,16 +4,34 @@ */ require __DIR__ . '/lib/bootstrap.php'; -$pdo = fb_db(); -$cats = fb_categories(); -$statuses = fb_statuses(); +$pdo = fb_db(); + +/* ---- 软件切换:只配一个软件时自动落到它,不暴露软件选择器 ---- */ +$swList = fb_softwares(true); +$swKey = isset($_GET['sw']) ? (string)$_GET['sw'] : ''; +$sw = null; +if ($swKey !== '') { + $sw = fb_software($swKey); + // 指定的软件不存在或已停用 → 退回默认,不报错(老链接要能打开) + if (!$sw || (int)$sw['enabled'] !== 1) { $sw = null; } +} +if ($sw === null && $swList) { $sw = $swList[0]; } +$swId = $sw ? (int)$sw['id'] : 0; + +$cats = fb_categories($swId); +$statuses = fb_status_keys(); $cat = isset($_GET['cat']) ? (string)$_GET['cat'] : ''; $st = isset($_GET['status']) ? (string)$_GET['status'] : ''; $q = isset($_GET['q']) ? trim((string)$_GET['q']) : ''; $sort = isset($_GET['sort']) ? (string)$_GET['sort'] : 'active'; -if ($cat !== '' && !isset($cats[$cat])) { $cat = ''; } +// 分类按 slug 在当前软件内解析;解析不到退回「全部」,不许 404 +$curCat = null; +if ($cat !== '') { + $curCat = fb_category_by_slug($swId, $cat); + if (!$curCat) { $cat = ''; } +} if ($st !== '' && !isset($statuses[$st])) { $st = ''; } if ($sort !== 'new') { $sort = 'active'; } @@ -21,8 +39,9 @@ $where = []; $args = []; // 审核(先审后显):访客只看已通过审核的;管理员登录审核后台后可看全部 if (fb_moderation_on() && !fb_is_admin()) { $where[] = 'visible = 1'; } -if ($cat !== '') { $where[] = 'category = ?'; $args[] = $cat; } -if ($st !== '') { $where[] = 'status = ?'; $args[] = $st; } +if ($swId > 0) { $where[] = 'software_id = ?'; $args[] = $swId; } +if ($curCat) { $where[] = 'category_id = ?'; $args[] = (int)$curCat['id']; } +if ($st !== '') { $where[] = 'status = ?'; $args[] = $st; } if ($q !== '') { $like = '%' . addcslashes($q, '%_\\') . '%'; $where[] = "(title LIKE ? ESCAPE '\\' OR body LIKE ? ESCAPE '\\')"; @@ -43,7 +62,7 @@ if ($page < 1) { $page = 1; } if ($page > $pages){ $page = $pages; } $offset = ($page - 1) * $pageSize; -$sql = 'SELECT id, title, category, status, author_name, reply_count, created_at, updated_at,' +$sql = 'SELECT id, title, category, category_id, software_id, status, author_name, reply_count, created_at, updated_at,' . ' substr(body, 1, 300) AS excerpt FROM threads' . $wsql . ' ORDER BY ' . $order . ' LIMIT ' . $pageSize . ' OFFSET ' . $offset; $sth = $pdo->prepare($sql); @@ -56,25 +75,41 @@ foreach ($threads as $t) { $tids[] = (int)$t['id']; } $attImgs = $tids ? fb_attach_map_images($pdo, $tids, 3) : []; $attCount = $tids ? fb_attach_count_map($pdo, $tids) : []; -fb_layout_head('全部问题'); +$siteName = (string)fb_cfg('site_name'); +$headTitle = $siteName !== '' ? $siteName . ' · 问题反馈' : '问题反馈'; +fb_layout_head($sw ? ((string)$sw['name']) : $headTitle); ?>
-

全部问题

-

+

+

+
+ 我要反馈 +
+ +
+ 选择软件: +
+ + +
- 我要反馈
全部 - $v): ?> - + +
+
+ + +
+ 所属软件 *换软件会刷新下面的分类 +
+ + + +
+
+ + + + + +