fix issues

This commit is contained in:
2026-07-22 15:43:00 +08:00
parent cf63ed5e3f
commit 4fe5abb74a
2 changed files with 16 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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;