feat(mindspace): 0630004 空间 UI、聊天连接、微信分享与 Agent 能力
含 MindSpace 三列布局与统计修复、聊天加载态与连接降级、平台页脚标记与 og:site_name 微信卡片、勾选资料删除 Agent 接口及内部话术过滤。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+32
-1
@@ -166,8 +166,37 @@ function formatDateParts(now, timezone) {
|
||||
};
|
||||
}
|
||||
|
||||
function formatLocalClockParts(now, timezone) {
|
||||
const formatter = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: timezone,
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
});
|
||||
const parts = Object.fromEntries(
|
||||
formatter.formatToParts(new Date(now)).map((part) => [part.type, part.value]),
|
||||
);
|
||||
return {
|
||||
hour: Number(parts.hour ?? 0),
|
||||
minute: Number(parts.minute ?? 0),
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveTimeOfDayPeriod(hour) {
|
||||
const h = Number(hour);
|
||||
if (h < 5) return { period: '凌晨', greeting: '你好' };
|
||||
if (h < 9) return { period: '早上', greeting: '早上好' };
|
||||
if (h < 12) return { period: '上午', greeting: '上午好' };
|
||||
if (h < 14) return { period: '中午', greeting: '中午好' };
|
||||
if (h < 18) return { period: '下午', greeting: '下午好' };
|
||||
return { period: '晚上', greeting: '晚上好' };
|
||||
}
|
||||
|
||||
export function renderCurrentTimeAnchor({ now = Date.now(), timezone = DEFAULT_TIMEZONE } = {}) {
|
||||
const { year, month, day } = formatDateParts(now, timezone);
|
||||
const { hour, minute } = formatLocalClockParts(now, timezone);
|
||||
const { period, greeting } = resolveTimeOfDayPeriod(hour);
|
||||
const clock = `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`;
|
||||
const weekday = new Intl.DateTimeFormat('zh-CN', {
|
||||
timeZone: timezone,
|
||||
weekday: 'long',
|
||||
@@ -177,7 +206,9 @@ export function renderCurrentTimeAnchor({ now = Date.now(), timezone = DEFAULT_T
|
||||
'',
|
||||
`- 当前时区:${timezone}`,
|
||||
`- 当前日期:${year}-${month}-${day}(${weekday})`,
|
||||
'- 回答中涉及“今天 / 明天 / 后天 / 周几”时,必须以上述日期为准继续推算,不要自行假设当前日期。',
|
||||
`- 当前时刻:${clock}(${period})`,
|
||||
`- 若需时段问候可参考:${greeting}(仅新会话开场或用户主动打招呼时使用,普通任务回复不要每条都加)`,
|
||||
'- 回答中涉及“今天 / 明天 / 后天 / 周几 / 早上 / 下午 / 晚上”等时间表述时,必须以上述日期与时刻为准,禁止自行假设当前时间或使用 UTC 等其它时区。',
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user