- 新增事件总线式toast通知系统 - 新增头像、阅读进度、404/500错误页等基础组件 - 重构页脚、布局、分页、点赞按钮等现有组件 - 新增用户个人页、通知中心、帖子编辑/发布/置顶/推荐管理功能 - 优化登录注册页面样式与交互 - 修复路径类型文件引用,更新站点元信息与字体配置
18 lines
490 B
TypeScript
18 lines
490 B
TypeScript
// 零依赖的事件总线式 toast,避免在每个交互组件里包 Context
|
||
export type ToastVariant = "error" | "ok";
|
||
|
||
export interface ToastDetail {
|
||
id: number;
|
||
message: string;
|
||
variant: ToastVariant;
|
||
}
|
||
|
||
export function toast(message: string, variant: ToastVariant = "error") {
|
||
if (typeof window === "undefined") return;
|
||
window.dispatchEvent(
|
||
new CustomEvent<ToastDetail>("j13-toast", {
|
||
detail: { id: Date.now() + Math.random(), message, variant },
|
||
})
|
||
);
|
||
}
|