复用message提示框和确认删除公共组件

This commit is contained in:
sophie committed 2026-05-22 10:52:17 +08:00
1 parent 452f6ebc6d
commit 02d0c1dcd6
6 files changed
+343 -237

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { useGlobalMessageDialog } from './useGlobalMessageDialog';
type MessageTitle = string | undefined;
/**
* 业务层消息助手:
* - 统一复用全局 LevelMessageDialog
* - 提供更短的方法名,减少重复传 level 字符串
*/
export const useMessage = () => {
const { showMessageDialog } = useGlobalMessageDialog();
const info = (message: string, title?: MessageTitle) =>
showMessageDialog('info', message, title);
const success = (message: string, title?: MessageTitle) =>
showMessageDialog('success', message, title);
const warning = (message: string, title?: MessageTitle) =>
showMessageDialog('warning', message, title);
// 兼容常见缩写调用:msg.warn(...)
const warn = warning;
const error = (message: string, title?: MessageTitle) =>
showMessageDialog('error', message, title);
return {
info,
success,
warning,
warn,
error,
};
};