古刹文章详细页面0.87
This commit is contained in:
parent
d706e7067a
commit
2e45ce03f8
|
|
@ -160,7 +160,7 @@ export default {
|
|||
id: item.id || item.articleId, // 兼容不同的ID字段名
|
||||
title: item.title || "",
|
||||
subtitle: item.subtitle || "",
|
||||
createTime: item.createTime || "",
|
||||
createTime: item.createTime || null, // 保持原始值,让 formatTime 方法处理
|
||||
}));
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -171,10 +171,24 @@ export default {
|
|||
|
||||
// 格式化时间
|
||||
formatTime(timeStr) {
|
||||
if (!timeStr) return "";
|
||||
// 如果时间为空、null 或 undefined,返回"不详"
|
||||
if (
|
||||
!timeStr ||
|
||||
timeStr === null ||
|
||||
timeStr === undefined ||
|
||||
timeStr === ""
|
||||
) {
|
||||
return "不详";
|
||||
}
|
||||
|
||||
try {
|
||||
const date = new Date(timeStr);
|
||||
|
||||
// 检查日期是否有效
|
||||
if (isNaN(date.getTime())) {
|
||||
return "不详";
|
||||
}
|
||||
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
|
|
@ -183,7 +197,8 @@ export default {
|
|||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
} catch (error) {
|
||||
return timeStr;
|
||||
console.error("时间格式化错误:", error, "原始时间:", timeStr);
|
||||
return "不详";
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -281,7 +296,7 @@ export default {
|
|||
|
||||
.cover-image {
|
||||
width: 100%;
|
||||
height: 400rpx;
|
||||
height: 340rpx;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
|
@ -383,6 +398,13 @@ export default {
|
|||
flex-shrink: 0;
|
||||
border: red solid 1px;
|
||||
}
|
||||
|
||||
.debug-time {
|
||||
font-size: 18rpx;
|
||||
color: #ccc;
|
||||
margin-left: 10rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user