docs(app): explain common API session workspace and geometry helpers

This commit is contained in:
2026-11-12 01:36:26 +08:00
parent c488bc86b6
commit aacafa7a9b
8 changed files with 103 additions and 0 deletions
+7
View File
@@ -1,10 +1,17 @@
/**
* 应用层Sonner通知适配。领域/editor包不依赖具体toast库,宿主在收到状态后选择调用此模块。
* use client界定通知只在客户端使用,函数不修改画布任务事实。
*/
"use client";
import { toast } from "sonner";
/** Application adapter. Domain/editor packages must not import Sonner. */
/** 稳定id用于更新/关闭同一通知,level决定显示样式,description是可选补充文案。 */
export type Notification = { id: string; title: string; description?: string; level?: "info" | "success" | "warning" | "error" };
/** 按指定level调用Sonner,默认info;相同id的合并/更新行为交给通知库。 */
export function notify({ id, title, description, level = "info" }: Notification) {
return toast[level](title, { id, description });
}
/** 按id关闭通知,不表示对应业务任务已取消或错误已恢复。 */
export function dismissNotification(id: string) { toast.dismiss(id); }