重构: tool_registry拆分及多批改进

This commit is contained in:
2026-06-19 00:10:14 +08:00
parent a2871a66e0
commit 60b01d03ee
33 changed files with 703 additions and 247 deletions

View File

@@ -16,7 +16,7 @@ export function stripMd(text: string | null | undefined): string {
return text
.replace(/!\[([^\]]*)\]\([^)]*\)/g, '$1') // 图片 alt
.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1') // 链接文本
.replace(/```[a-zA-Z]*\n?/g, '') // 代码块围栏开
.replace(/```[^\n]*\n?/g, '') // 代码块围栏开(含任意 infostring 至换行,如 rust,norun)
.replace(/```/g, '') // 代码块围栏闭
.replace(/`([^`]+)`/g, '$1') // 行内代码
.replace(/^\s{0,3}>\s?/gm, '') // 引用

View File

@@ -41,7 +41,8 @@ export function formatDate(v: string | number | null | undefined): string {
const ms = parseTs(v)
if (ms == null) return '—'
const d = new Date(ms)
return d.toLocaleDateString('zh-CN') + ' ' + d.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' })
const locale = (i18n as any).global.locale.value === 'en' ? 'en-US' : 'zh-CN'
return d.toLocaleDateString(locale) + ' ' + d.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' })
}
/** 中文相对时间 '刚刚 / X 分钟前 / X 小时前 / X 天前';无效返回 '—' */