fix issues
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user