diff --git a/frontend/app.js b/frontend/app.js index a19f3ad..8364bb1 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -1314,7 +1314,9 @@ handleDragLeave(e) { const expireDate = new Date(expiresAt); const now = new Date(); const diffMs = expireDate - now; - const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24)); + const diffMinutes = Math.floor(diffMs / (1000 * 60)); + const diffHours = Math.floor(diffMs / (1000 * 60 * 60)); + const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); // 格式化日期 const dateStr = expireDate.toLocaleString('zh-CN', { @@ -1325,10 +1327,12 @@ handleDragLeave(e) { minute: '2-digit' }); - if (diffDays < 0) { + if (diffMs < 0) { return `已过期 (${dateStr})`; - } else if (diffDays === 0) { - return `今天过期 (${dateStr})`; + } else if (diffMinutes < 60) { + return `${diffMinutes}分钟后过期 (${dateStr})`; + } else if (diffHours < 24) { + return `${diffHours}小时后过期 (${dateStr})`; } else if (diffDays === 1) { return `明天过期 (${dateStr})`; } else if (diffDays <= 7) { diff --git a/frontend/share.html b/frontend/share.html index 972e84e..d9ef792 100644 --- a/frontend/share.html +++ b/frontend/share.html @@ -833,7 +833,9 @@ const expireDate = new Date(expiresAt); const now = new Date(); const diffMs = expireDate - now; - const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24)); + const diffMinutes = Math.floor(diffMs / (1000 * 60)); + const diffHours = Math.floor(diffMs / (1000 * 60 * 60)); + const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); // 格式化日期 const dateStr = expireDate.toLocaleString('zh-CN', { @@ -844,10 +846,12 @@ minute: '2-digit' }); - if (diffDays < 0) { + if (diffMs < 0) { return `已过期 (${dateStr})`; - } else if (diffDays === 0) { - return `今天过期 (${dateStr})`; + } else if (diffMinutes < 60) { + return `${diffMinutes}分钟后过期 (${dateStr})`; + } else if (diffHours < 24) { + return `${diffHours}小时后过期 (${dateStr})`; } else if (diffDays === 1) { return `明天过期 (${dateStr})`; } else if (diffDays <= 7) {