Skip to content

feat(preview): replace unpreviewable inline errors with toast notifications#473

Merged
ErlichLiu merged 1 commit into
mainfrom
feat-preview-unpreviewable-toast
May 15, 2026
Merged

feat(preview): replace unpreviewable inline errors with toast notifications#473
ErlichLiu merged 1 commit into
mainfrom
feat-preview-unpreviewable-toast

Conversation

@ErlichLiu
Copy link
Copy Markdown
Owner

Summary

  • 旧版 Office (.doc/.xls/.ppt):跳过 loading 状态(不触发 spinner),通过 toast.warning 告知用户不支持内联预览,预览区保持空白
  • PDF 过大 / DOCX 失败 / Office 失败 / 图片过大:加载完成后若内容为空,统一弹 Toast 通知,移除原先闪出的 inline 错误 div
  • toastedPreviewFailRef 防止同一文件重复弹 Toast

改动细节

  1. 添加 import { toast } from 'sonner'
  2. reset effect 中 isLegacyOffice 时跳过 setLoading(true),避免 spinner 一闪
  3. 主加载 effect 的 else 分支同样跳过 isLegacyOffice 的 loading 状态
  4. 新增统一 toast effect,覆盖全部不可预览场景
  5. 5 处 inline 错误 div → null

Test plan

  • 打开 .doc/.xls/.ppt 文件:预览区空白 + 顶部 warning toast,无 spinner 闪烁
  • 打开超大 PDF:加载后显示 toast 提示,预览区空白
  • 切换多个不可预览文件:每文件只弹一次 toast,不重复

🤖 Generated with Claude Code

…ations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ErlichLiu ErlichLiu merged commit dc9f92f into main May 15, 2026
@ErlichLiu ErlichLiu deleted the feat-preview-unpreviewable-toast branch May 15, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant