fix issues
This commit is contained in:
@@ -745,7 +745,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatMonth(dateStr) {
|
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)}月`;
|
if (parts.length >= 2) return `${parts[0]}年${parseInt(parts[1], 10)}月`;
|
||||||
return dateStr.substring(0,7);
|
return dateStr.substring(0,7);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,19 @@ const TIMEZONE = 'Asia/Shanghai';
|
|||||||
function timestamp() {
|
function timestamp() {
|
||||||
return new Date().toLocaleString('zh-CN', { timeZone: TIMEZONE, hour12: false });
|
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(); }
|
function currentTimeStr() { return timestamp(); }
|
||||||
|
|
||||||
// 初始化用户
|
// 初始化用户
|
||||||
@@ -422,7 +435,7 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) {
|
|||||||
} catch(e) { console.error('❌ 解析附件失败:', e); }
|
} catch(e) { console.error('❌ 解析附件失败:', e); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const createdTime = aiResult.created_time || now;
|
const createdTime = normalizeTime(aiResult.created_time);
|
||||||
// 新建 vs 更新:AI 标记 is_new 时强制新建,不尝试匹配已有记录
|
// 新建 vs 更新:AI 标记 is_new 时强制新建,不尝试匹配已有记录
|
||||||
const isNew = aiResult.is_new === true;
|
const isNew = aiResult.is_new === true;
|
||||||
let purchase;
|
let purchase;
|
||||||
|
|||||||
Reference in New Issue
Block a user