task-246(admin.html观感对齐): 反馈语义统一(success/error/warning + busy 防重入 + 忙碌文案)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 反馈 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<T>(task: () => Promise<T>): Promise<T | undefined> {
|
||||
if (!tryBeginBusy()) return undefined
|
||||
try {
|
||||
return await task()
|
||||
} finally {
|
||||
endBusy()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user