chore: 提交剩余开发改动

包含商务通消息映射、会话时间与未读状态、前端消息展示、数据库修复迁移、测试覆盖备份及 Captain 设计文档。
This commit is contained in:
Rogee
2026-08-06 10:10:25 +08:00
parent 8f2cc12628
commit b78f963472
38 changed files with 11691 additions and 1910 deletions
@@ -21,14 +21,20 @@ export const messageStamp = (time, dateFormat = 'h:mm a') => {
* Provides a formatted timestamp, adjusting the format based on the current year.
* @param {number} time - Unix timestamp.
* @param {string} [dateFormat='MMM d, yyyy'] - Desired date format.
* @param {object} [options] - date-fns options and a different-year fallback format.
* @returns {string} Formatted date string.
*/
export const messageTimestamp = (time, dateFormat = 'MMM d, yyyy') => {
export const messageTimestamp = (
time,
dateFormat = 'MMM d, yyyy',
options = {}
) => {
const messageTime = fromUnixTime(time);
const now = new Date();
const messageDate = format(messageTime, dateFormat);
const { fallbackFormat = 'LLL d y, h:mm a', ...formatOptions } = options;
const messageDate = format(messageTime, dateFormat, formatOptions);
if (!isSameYear(messageTime, now)) {
return format(messageTime, 'LLL d y, h:mm a');
return format(messageTime, fallbackFormat, formatOptions);
}
return messageDate;
};
@@ -38,9 +44,9 @@ export const messageTimestamp = (time, dateFormat = 'MMM d, yyyy') => {
* @param {number} time - Unix timestamp.
* @returns {string} Relative time string.
*/
export const dynamicTime = time => {
export const dynamicTime = (time, options = {}) => {
const unixTime = fromUnixTime(time);
return formatDistanceToNow(unixTime, { addSuffix: true });
return formatDistanceToNow(unixTime, { addSuffix: true, ...options });
};
/**
@@ -49,9 +55,9 @@ export const dynamicTime = time => {
* @param {string} [dateFormat='MMM d, yyyy'] - Desired date format.
* @returns {string} Formatted date string.
*/
export const dateFormat = (time, df = 'MMM d, yyyy') => {
export const dateFormat = (time, df = 'MMM d, yyyy', options = {}) => {
const unixTime = fromUnixTime(time);
return format(unixTime, df);
return format(unixTime, df, options);
};
/**