跳到主要内容

show-notification

<basic.show-notification>provider

显示通知消息。

默认情况下,当通知框以任何形式关闭时,将触发 callback.success

如果同时设置 showConfirm: trueshowCancel: true,则只有 confirm 按钮按下时触发 callback.success,其他原因引起的通知框关闭,都将触发 callback.error

Examples

Types

Playground

Placement

Playground

Icon and title

Playground

Closable

Playground

Operations

Playground

Usage in pro-code

import { unwrapProvider } from "@next-core/utils/general";
import type { showNotification as _showNotification } from "@next-bricks/basic/data-providers/show-notification/show-notification";

// Use `unwrapProvider` to get the original function of a provider
const showNotification = unwrapProvider<typeof _showNotification>(
"basic.show-notification"
);

function MyComponent() {
const handleClick = useCallback(() => {
showNotification({
type: "success",
message: "Done!",
});
}, []);
return <button onClick={handleClick} />;
}

Definition

Parameters

#NameDescriptionType
1options

选项

NotificationOptions

Returns

Promise<void>

Type references

NotificationOptions

NameTypeRequiredDescription
type"success" | "error" | "warn" | "info"

通知类型

durationnumber

默认三秒后自动关闭

placement"center" | "topRight"

弹出位置,默认居中

titlestring | null

通知标题

messagestring | null

通知内容

htmlMessagestring

HTML 格式的通知内容,该内容会被 dom-purify sanitize

closableboolean

允许手动关闭消息提示

iconGeneralIconProps & { style?: React.CSSProperties }

自定义图标

styleType"circleAngle" | "rectAngle"

样式类型,默认圆角样式

confirmTextstring

确认文本

confirmLinkLinkOptions

确认链接选项

cancelTextstring

取消文本

showConfirmboolean

展示确认按钮

showCancelboolean

展示取消按钮

LinkOptions

NameTypeRequiredDescription
urlstring
hrefstring
targetTarget