Feat: 新增语录页和通知提示组件

This commit is contained in:
2026-05-21 11:25:35 +08:00
parent 1c86b7faee
commit d585fc909f
12 changed files with 400 additions and 2 deletions
+33
View File
@@ -0,0 +1,33 @@
export interface NoticeItem {
key?: string;
title: string;
duration?: number;
content: React.ReactNode;
}
type NoticeFn = (notice: NoticeItem) => void;
const addNoticeFn: NoticeFn[] = [];
export const add = (notice: NoticeItem) => {
addNoticeFn.forEach((item) => {
// 如果没传递 duration,默认设置为 5000
if (!("duration" in notice)) {
notice.duration = 5000;
}
item(notice);
});
}
export const addFn = (fn: NoticeFn) => {
return addNoticeFn.push(fn) - 1;
}
export const removeFn = (fn: NoticeFn) => {
const index = addNoticeFn.indexOf(fn);
if (index > -1) {
addNoticeFn.splice(index, 1);
}
}