发布 0.1.0:通知渠道、告警规则与多项体验修复
CI / test (push) Successful in 27s
Release / release (push) Successful in 26s

This commit is contained in:
Wang Defa
2026-07-10 17:31:19 +08:00
parent 9d0c116ce3
commit 5464d2dfea
68 changed files with 1604 additions and 359 deletions
+16
View File
@@ -4,6 +4,17 @@ import { h, ref, type Ref, type VNodeChild } from 'vue'
type ToastKind = 'error' | 'warning'
const AUTO_CLOSE_MS = 8000
/** 超过此长度的消息自动折叠成「标题 + 展开详情」 */
const LONG_TEXT = 64
/** 长错误提炼标题:优先 hint 分隔符(request.ts 的「hinterror」),次选首个冒号操作前缀,兜底截断 */
function summarize(text: string): string {
const bar = text.indexOf('')
if (bar > 0 && bar <= 40) return text.slice(0, bar)
const colon = text.search(/|: /)
if (colon > 0 && colon <= 40) return text.slice(0, colon)
return [...text].slice(0, 40).join('') + '…'
}
function renderDetail(kind: ToastKind, detail: string, copied: Ref<boolean>): VNodeChild {
return h('div', { class: 'toast-code' }, [
@@ -51,6 +62,11 @@ export function useToast() {
const message = useMessage()
function show(kind: ToastKind, text: string, detail?: string) {
// 未显式给 detail 的超长消息(如 OCI 透传错误)自动折叠,避免整段撑爆 toast
if (!detail && text.length > LONG_TEXT) {
detail = text
text = summarize(text)
}
if (!detail) {
message[kind](text)
return