Files
2026-07-14 15:43:18 +08:00

30 lines
897 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: frontend-dialog
description: 前端弹窗规范。用于需要确认、提醒、提示输入的交互场景,统一使用 GlobalDialog(或项目统一对话框 Hook),禁止浏览器原生弹窗。
---
# 弹窗规范
## 核心规则
- 禁止使用 `window.alert` / `window.confirm` / `window.prompt`
- 必须使用项目统一弹窗能力(`GlobalDialog` 或统一 `useDialog`
## 使用要求
- 确认型操作使用异步确认 API(返回 `Promise<boolean>`
- 错误提示使用统一 `alert/toast` 能力
- 成功反馈使用统一 `toast`,避免散落样式
## 最小流程
1. 在应用根节点挂载 `DialogProvider`
2. 页面内通过 Hook 调 `confirm/alert/toast`
3. 危险操作必须先 `await confirm(...)` 再执行
## 设计目标
- 统一视觉风格与交互行为
- 避免原生弹窗破坏主题与体验
- 降低重复实现和状态不一致