Files
timi-web/src/utils/TDesignMessage.ts
T
2026-08-21 01:11:23 +08:00

28 lines
608 B
TypeScript

import type { AppContext } from "vue";
type MessageType = "info" | "success" | "warning" | "error";
type MessageHandler = (content: string) => unknown | Promise<unknown>;
type MessageApi = {
[type in MessageType]?: MessageHandler;
};
export const showTDesignMessage = async (
appContext: AppContext | undefined,
type: MessageType,
content: string
) => {
const handler = (appContext?.config.globalProperties.$message as MessageApi | undefined)?.[type];
if (handler) {
await handler(content);
return;
}
if ("error" === type) {
console.error(content);
return;
}
console.warn(content);
};