From b802709517c0d3f90d10f0f966d9cd905994cc1a Mon Sep 17 00:00:00 2001 From: R524809 Date: Mon, 15 Jun 2026 16:40:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20worksheet=20=E5=B1=95=E7=A4=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloudfunctions/pageContentBuild/index.js | 11 ++++++++--- cloudfunctions/worksheetsPublish/index.js | 2 ++ miniprogram/config/config.ts | 2 +- miniprogram/core/models/worksheet.ts | 1 + miniprogram/pages/category/category.ts | 11 ++++++++--- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cloudfunctions/pageContentBuild/index.js b/cloudfunctions/pageContentBuild/index.js index e747021..29f1281 100644 --- a/cloudfunctions/pageContentBuild/index.js +++ b/cloudfunctions/pageContentBuild/index.js @@ -15,6 +15,13 @@ function ageBand(min, max) { return `${min}-${max}岁`; } +function toContentDate(ws) { + const ts = ws.contentUpdatedAt || ws.createdAt; + return ts + ? new Date(ts).toISOString().slice(0, 10) + : new Date().toISOString().slice(0, 10); +} + function toDisplayItem(ws) { return { id: ws._id, @@ -30,9 +37,7 @@ function toDisplayItem(ws) { available: true, likes: (ws.likes || 0) + (ws.likes_seed || 0), downloads: (ws.downloads || 0) + (ws.downloads_seed || 0), - date: ws.updatedAt - ? new Date(ws.updatedAt).toISOString().slice(0, 10) - : new Date().toISOString().slice(0, 10), + date: toContentDate(ws), }; } diff --git a/cloudfunctions/worksheetsPublish/index.js b/cloudfunctions/worksheetsPublish/index.js index 6c35257..6895110 100644 --- a/cloudfunctions/worksheetsPublish/index.js +++ b/cloudfunctions/worksheetsPublish/index.js @@ -105,6 +105,7 @@ exports.main = async (event) => { likes: payload.likes, status: payload.status, updatedAt: db.serverDate(), + contentUpdatedAt: db.serverDate(), }; try { @@ -127,6 +128,7 @@ exports.main = async (event) => { data: { ...record, createdAt: db.serverDate(), + contentUpdatedAt: db.serverDate(), }, }); diff --git a/miniprogram/config/config.ts b/miniprogram/config/config.ts index b560c90..2eea42c 100644 --- a/miniprogram/config/config.ts +++ b/miniprogram/config/config.ts @@ -7,7 +7,7 @@ // }; /** 当前应用版本号;profile 页和首页公告共用 */ -export const APP_VERSION = '3.2.0'; +export const APP_VERSION = '3.2.2'; export const defaultPrintConfig: PrintConfig = { // header: 'LogoImage', diff --git a/miniprogram/core/models/worksheet.ts b/miniprogram/core/models/worksheet.ts index d819895..4c63db2 100644 --- a/miniprogram/core/models/worksheet.ts +++ b/miniprogram/core/models/worksheet.ts @@ -31,4 +31,5 @@ export interface WorksheetRecord extends WorksheetConfig { _id: string; createdAt: Date; updatedAt: Date; + contentUpdatedAt?: Date; } diff --git a/miniprogram/pages/category/category.ts b/miniprogram/pages/category/category.ts index cd37f5a..e1ef16b 100644 --- a/miniprogram/pages/category/category.ts +++ b/miniprogram/pages/category/category.ts @@ -82,6 +82,13 @@ function debugLogWorksheetStatsAfterCategoryLoad( // --- 调试块结束 --- +function toContentDate(raw: Record): string { + const ts = raw.contentUpdatedAt || raw.createdAt; + return ts + ? new Date(ts).toISOString().slice(0, 10) + : new Date().toISOString().slice(0, 10); +} + /** 将云端 worksheet 原始数据转换为 CategoryItem */ function toDisplayItem(raw: Record): CategoryItem { const difficulty = (Number(raw.difficulty) || 2) as 1 | 2 | 3 | 4; @@ -101,9 +108,7 @@ function toDisplayItem(raw: Record): CategoryItem { available: true, likes: Number(raw.likes) || 0, downloads: Number(raw.downloads) || 0, - date: raw.updatedAt - ? new Date(raw.updatedAt).toISOString().slice(0, 10) - : new Date().toISOString().slice(0, 10), + date: toContentDate(raw), updatedAt: raw.updatedAt ? String(raw.updatedAt) : '', }; }