fix: worksheet 展示时间修改
This commit is contained in:
@@ -15,6 +15,13 @@ function ageBand(min, max) {
|
|||||||
return `${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) {
|
function toDisplayItem(ws) {
|
||||||
return {
|
return {
|
||||||
id: ws._id,
|
id: ws._id,
|
||||||
@@ -30,9 +37,7 @@ function toDisplayItem(ws) {
|
|||||||
available: true,
|
available: true,
|
||||||
likes: (ws.likes || 0) + (ws.likes_seed || 0),
|
likes: (ws.likes || 0) + (ws.likes_seed || 0),
|
||||||
downloads: (ws.downloads || 0) + (ws.downloads_seed || 0),
|
downloads: (ws.downloads || 0) + (ws.downloads_seed || 0),
|
||||||
date: ws.updatedAt
|
date: toContentDate(ws),
|
||||||
? new Date(ws.updatedAt).toISOString().slice(0, 10)
|
|
||||||
: new Date().toISOString().slice(0, 10),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ exports.main = async (event) => {
|
|||||||
likes: payload.likes,
|
likes: payload.likes,
|
||||||
status: payload.status,
|
status: payload.status,
|
||||||
updatedAt: db.serverDate(),
|
updatedAt: db.serverDate(),
|
||||||
|
contentUpdatedAt: db.serverDate(),
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -127,6 +128,7 @@ exports.main = async (event) => {
|
|||||||
data: {
|
data: {
|
||||||
...record,
|
...record,
|
||||||
createdAt: db.serverDate(),
|
createdAt: db.serverDate(),
|
||||||
|
contentUpdatedAt: db.serverDate(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
/** 当前应用版本号;profile 页和首页公告共用 */
|
/** 当前应用版本号;profile 页和首页公告共用 */
|
||||||
export const APP_VERSION = '3.2.0';
|
export const APP_VERSION = '3.2.2';
|
||||||
|
|
||||||
export const defaultPrintConfig: PrintConfig = {
|
export const defaultPrintConfig: PrintConfig = {
|
||||||
// header: 'LogoImage',
|
// header: 'LogoImage',
|
||||||
|
|||||||
@@ -31,4 +31,5 @@ export interface WorksheetRecord extends WorksheetConfig {
|
|||||||
_id: string;
|
_id: string;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
|
contentUpdatedAt?: Date;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ function debugLogWorksheetStatsAfterCategoryLoad(
|
|||||||
|
|
||||||
// --- 调试块结束 ---
|
// --- 调试块结束 ---
|
||||||
|
|
||||||
|
function toContentDate(raw: Record<string, any>): string {
|
||||||
|
const ts = raw.contentUpdatedAt || raw.createdAt;
|
||||||
|
return ts
|
||||||
|
? new Date(ts).toISOString().slice(0, 10)
|
||||||
|
: new Date().toISOString().slice(0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
/** 将云端 worksheet 原始数据转换为 CategoryItem */
|
/** 将云端 worksheet 原始数据转换为 CategoryItem */
|
||||||
function toDisplayItem(raw: Record<string, any>): CategoryItem {
|
function toDisplayItem(raw: Record<string, any>): CategoryItem {
|
||||||
const difficulty = (Number(raw.difficulty) || 2) as 1 | 2 | 3 | 4;
|
const difficulty = (Number(raw.difficulty) || 2) as 1 | 2 | 3 | 4;
|
||||||
@@ -101,9 +108,7 @@ function toDisplayItem(raw: Record<string, any>): CategoryItem {
|
|||||||
available: true,
|
available: true,
|
||||||
likes: Number(raw.likes) || 0,
|
likes: Number(raw.likes) || 0,
|
||||||
downloads: Number(raw.downloads) || 0,
|
downloads: Number(raw.downloads) || 0,
|
||||||
date: raw.updatedAt
|
date: toContentDate(raw),
|
||||||
? new Date(raw.updatedAt).toISOString().slice(0, 10)
|
|
||||||
: new Date().toISOString().slice(0, 10),
|
|
||||||
updatedAt: raw.updatedAt ? String(raw.updatedAt) : '',
|
updatedAt: raw.updatedAt ? String(raw.updatedAt) : '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user