diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..e69de29 diff --git a/admin/articles.php b/admin/articles.php index fe23ff2..2856f7e 100644 --- a/admin/articles.php +++ b/admin/articles.php @@ -61,7 +61,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $sort = max(0, (int)($_POST['sort'] ?? 0)); $pinned = (isset($_POST['pinned']) && $_POST['pinned'] === '1') ? 1 : 0; $enabled = (isset($_POST['enabled']) && $_POST['enabled'] === '1') ? 1 : 0; - if ($part === '') { + if ($part === '' || $part === '__new__') { $part = '未分类'; } if ($title === '') { @@ -202,14 +202,16 @@ admin_topbar('articles'); 'summary' => (string)$row['summary'], 'md' => (string)$row['markdown'], 'sort' => (int)$row['sort'], 'pinned' => (int)$row['pinned'], 'enabled' => (int)$row['enabled'], ] : ['id' => 0, 'part' => '未分类', 'title' => '', 'summary' => '', 'md' => '', 'sort' => 0, 'pinned' => 0, 'enabled' => 1]; - // 分区下拉建议(仅列已有分区) - $partSuggest = []; + // 分区下拉选项:未分类 + 全部已有分区;编辑中的自定义分区自动补充,保证能回显选中 + $curPart = trim((string)$cur['part']); + if ($curPart === '') { $curPart = '未分类'; } + $partOptions = ['未分类']; foreach ($list as $a2) { $p2 = trim((string)$a2['part']); - if ($p2 !== '' && !in_array($p2, $partSuggest, true)) { - $partSuggest[] = $p2; - } + if ($p2 === '' || $p2 === '未分类') continue; + if (!in_array($p2, $partOptions, true)) { $partOptions[] = $p2; } } + if (!in_array($curPart, $partOptions, true)) { array_unshift($partOptions, $curPart); } ?>