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