/** * 反馈 UI 接线(module 13 task 246):把模型语义接到 ElMessage 与 busy 锁上。 * 页面统一用 showAdminFeedback / runBusy,避免各页 ElMessage 直接散打文案。 */ import { ElMessage } from 'element-plus' import { endBusy, normalizeFeedback, tryBeginBusy, type AdminFeedbackKind, } from './admin-feedback' export function showAdminFeedback(message?: string, kind?: AdminFeedbackKind): void { const { kind: k, message: m } = normalizeFeedback(message, kind) if (k === 'success') ElMessage.success(m) else if (k === 'error') ElMessage.error(m) else ElMessage.warning(m) } /** 以 busy 锁包裹一个提交动作;已在途则直接返回 undefined,防止重复提交。 */ export async function runBusy(task: () => Promise): Promise { if (!tryBeginBusy()) return undefined try { return await task() } finally { endBusy() } }