// app/utils/fetch.ts - $fetch 请求工具 /** 从 `$fetch` 错误里提取安全文案;服务端已经保证 message/msg 不含敏感上游细节 */ export const getClientErrorMessage = (error: unknown, fallback: string) => { if (typeof error !== "object" || error === null) return fallback; const data = "data" in error ? (error as { data?: unknown }).data : undefined; if (typeof data === "object" && data !== null) { const message = (data as { message?: unknown; msg?: unknown }).message; const msg = (data as { message?: unknown; msg?: unknown }).msg; if (typeof message === "string" && message) return message; if (typeof msg === "string" && msg) return msg; } return fallback; };