fix:修复消息提醒时间问题&修复编辑帖子问题
This commit is contained in:
@@ -13,11 +13,11 @@ android {
|
||||
applicationId = "com.memory.app"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
versionCode = 14
|
||||
versionName = "1.3.0"
|
||||
versionCode = 16
|
||||
versionName = "1.3.2"
|
||||
|
||||
buildConfigField("String", "API_BASE_URL", "\"https://x.amos.us.kg/api/\"")
|
||||
buildConfigField("int", "VERSION_CODE", "14")
|
||||
buildConfigField("int", "VERSION_CODE", "16")
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
||||
@@ -231,12 +231,6 @@ fun PostCard(
|
||||
onClick = { onEditClick(post) },
|
||||
tint = actionTint
|
||||
)
|
||||
} else {
|
||||
ActionButton(
|
||||
icon = Icons.Outlined.Edit,
|
||||
onClick = { },
|
||||
tint = disabledTint
|
||||
)
|
||||
}
|
||||
|
||||
// Like
|
||||
|
||||
@@ -206,18 +206,21 @@ private fun getNotificationAction(notification: Notification): String {
|
||||
private fun formatNotificationTime(createdAt: String): String {
|
||||
return try {
|
||||
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
val time = LocalDateTime.parse(createdAt.replace("T", " ").substringBefore("+").substringBefore("Z"), formatter)
|
||||
val utcTime = LocalDateTime.parse(createdAt.replace("T", " ").substringBefore("+").substringBefore("Z"), formatter)
|
||||
// 将 UTC 时间转换为本地时间
|
||||
val utcZoned = utcTime.atZone(java.time.ZoneId.of("UTC"))
|
||||
val localTime = utcZoned.withZoneSameInstant(java.time.ZoneId.systemDefault()).toLocalDateTime()
|
||||
val now = LocalDateTime.now()
|
||||
val minutes = ChronoUnit.MINUTES.between(time, now)
|
||||
val hours = ChronoUnit.HOURS.between(time, now)
|
||||
val days = ChronoUnit.DAYS.between(time, now)
|
||||
val minutes = ChronoUnit.MINUTES.between(localTime, now)
|
||||
val hours = ChronoUnit.HOURS.between(localTime, now)
|
||||
val days = ChronoUnit.DAYS.between(localTime, now)
|
||||
|
||||
when {
|
||||
minutes < 1 -> "刚刚"
|
||||
minutes < 60 -> "${minutes}分钟前"
|
||||
hours < 24 -> "${hours}小时前"
|
||||
days < 7 -> "${days}天前"
|
||||
else -> time.format(DateTimeFormatter.ofPattern("MM-dd"))
|
||||
else -> localTime.format(DateTimeFormatter.ofPattern("MM-dd"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
createdAt.substringBefore("T")
|
||||
|
||||
Reference in New Issue
Block a user