feat:完成首页、分类页内容管理功能开发

This commit is contained in:
R524809
2026-04-30 13:30:42 +08:00
parent fa39938e5a
commit c112c70bab
25 changed files with 1465 additions and 65 deletions
@@ -10,6 +10,7 @@ type WorksheetItem = {
ageMax: number;
difficulty: 1 | 2 | 3 | 4;
tags: string[];
tagsText: string;
status: 'draft' | 'active' | 'hidden';
sortOrder: number;
updatedAt: string;
@@ -19,6 +20,7 @@ type WorksheetItem = {
statusText: string;
actionText: string;
actionTarget: string;
actionType: string;
};
type Stats = {
@@ -44,11 +46,11 @@ const DIFFICULTY_LABELS: Record<number, string> = {
const STATUS_CONFIG: Record<
string,
{ text: string; action: string; target: string }
{ text: string; action: string; target: string; actionType: string }
> = {
draft: { text: '草稿', action: '激活', target: 'active' },
active: { text: '线上', action: '下架', target: 'hidden' },
hidden: { text: '已隐藏', action: '恢复', target: 'draft' },
draft: { text: '草稿', action: '激活', target: 'active', actionType: 'green' },
active: { text: '线上', action: '下架', target: 'hidden', actionType: 'default' },
hidden: { text: '已隐藏', action: '恢复', target: 'draft', actionType: 'primary' },
};
function formatWorksheet(raw: Record<string, unknown>): WorksheetItem {
@@ -68,6 +70,7 @@ function formatWorksheet(raw: Record<string, unknown>): WorksheetItem {
ageMax,
difficulty,
tags: Array.isArray(raw.tags) ? raw.tags.map(String) : [],
tagsText: Array.isArray(raw.tags) ? raw.tags.map(String).join('、') : '',
status: status as WorksheetItem['status'],
sortOrder: Number(raw.sortOrder) || 0,
updatedAt: raw.updatedAt ? String(raw.updatedAt) : '',
@@ -76,6 +79,7 @@ function formatWorksheet(raw: Record<string, unknown>): WorksheetItem {
statusText: cfg.text,
actionText: cfg.action,
actionTarget: cfg.target,
actionType: cfg.actionType,
};
}