diff --git a/server/public/index.html b/server/public/index.html
index 6242558..e3f83a2 100644
--- a/server/public/index.html
+++ b/server/public/index.html
@@ -745,7 +745,8 @@
}
function formatMonth(dateStr) {
- const parts = dateStr.split('/');
+ const clean = dateStr.replace(/-/g, '/');
+ const parts = clean.split('/');
if (parts.length >= 2) return `${parts[0]}年${parseInt(parts[1], 10)}月`;
return dateStr.substring(0,7);
}
diff --git a/server/server.js b/server/server.js
index 84cfe8d..62bb9e7 100644
--- a/server/server.js
+++ b/server/server.js
@@ -27,6 +27,19 @@ const TIMEZONE = 'Asia/Shanghai';
function timestamp() {
return new Date().toLocaleString('zh-CN', { timeZone: TIMEZONE, hour12: false });
}
+function normalizeTime(str) {
+ if (!str) return timestamp();
+ // 已经是标准格式 yyyy/M/d HH:mm:ss 直接返回
+ if (/\d{4}\/\d{1,2}\/\d{1,2} \d{2}:\d{2}:\d{2}/.test(str)) return str;
+ // 纯日期 yyyy-MM-dd 或 yyyy/MM/dd → 补充 00:00:00
+ const clean = str.replace(/-/g, '/');
+ if (/^\d{4}\/\d{1,2}\/\d{1,2}$/.test(clean)) return clean + ' 00:00:00';
+ // 带时间但分隔符是 - → 统一换成 /
+ const withSlash = str.replace(/-/g, '/');
+ if (/\d{4}\/\d{1,2}\/\d{1,2} \d{2}:\d{2}:\d{2}/.test(withSlash)) return withSlash;
+ // 无法识别,返回当前时间
+ return timestamp();
+}
function currentTimeStr() { return timestamp(); }
// 初始化用户
@@ -422,7 +435,7 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) {
} catch(e) { console.error('❌ 解析附件失败:', e); }
}
}
- const createdTime = aiResult.created_time || now;
+ const createdTime = normalizeTime(aiResult.created_time);
// 新建 vs 更新:AI 标记 is_new 时强制新建,不尝试匹配已有记录
const isNew = aiResult.is_new === true;
let purchase;