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
+8 -1
View File
@@ -3,11 +3,11 @@ const cloud = require('wx-server-sdk');
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV });
const VALID_STATUS = new Set(['draft', 'active', 'hidden']);
const STATUS_ORDER = { draft: 0, hidden: 1, active: 2 };
exports.main = async (event) => {
try {
const db = cloud.database();
const _ = db.command;
const collection = db.collection('worksheets');
const category = String(event.category || '').trim();
@@ -26,6 +26,13 @@ exports.main = async (event) => {
.limit(100)
.get();
// Sort by status order: draft → hidden → active
data.sort((a, b) => {
const orderA = STATUS_ORDER[a.status] ?? 99;
const orderB = STATUS_ORDER[b.status] ?? 99;
return orderA - orderB;
});
// Compute stats for the category (all statuses)
let allData = data;
if (status) {