-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 改进图片处理稳定性并添加富文本支持 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
改进: - 添加图片大小限制(10MB)和尺寸限制(4096x4096) - 自动缩放过大的图片 - 优化 PNG 编码性能 - 添加富文本(HTML)支持 - 支持 text/html MIME 类型(Linux wl-clipboard) - 改进错误处理和日志输出 这解决了图片复制粘贴不稳定的问题,并为富文本内容提供了支持
修复和改进: - 将图片大小限制从 10MB 降低到 5MB - 添加多次尝试的降级压缩机制(最多3次) - 改进错误处理,不会因为单个图片失败而中断同步 - 添加详细的日志输出,便于调试 - 在图片处理失败时自动回退到文本模式 - Linux wl-clipboard 也会检查和重新压缩过大的图片 - 每次压缩失败后会缩小到 70% 重试 这大大提高了图片同步的成功率和稳定性
- 改进 map_err 调用的多行格式 - 移除行尾多余空格 - 提高代码可读性
问题: - 服务器收到客户端图片后会重复广播 - 因为 receive_handle 和 clipboard_handle 使用了独立的 ClipboardMonitor 实例 - 它们的 last_hash 不同步,导致检测到"重复"变化 修复: - 统一服务器端的剪贴板管理,使用单一 ClipboardMonitor 实例 - 使用 tokio::select! 同时处理本地变化和客户端消息 - 确保 hash 在同一实例中更新,避免重复检测 - 移除未使用的 monitor 方法和导入 现在服务器端和客户端都使用统一的剪贴板管理模式
|
Caution Review failedThe pull request is closed. WalkthroughThe changes add HTML content support to a clipboard synchronization system. The implementation includes new enum variants for HTML content, restructured clipboard monitoring with a unified task-based architecture, enhanced image handling with compression and size constraints, new Linux Wayland clipboard utilities, and centralized error handling with graceful fallbacks. Changes
Sequence DiagramsequenceDiagram
participant LM as Local Monitor
participant Server
participant Client
participant CB as Local Clipboard
Note over LM,Client: New Unified Clipboard Management Flow
loop Periodic Monitoring
LM->>LM: Signal via internal channel
LM->>LM: Fetch current clipboard (Text/Image/Html)
end
alt Local Content Changed
LM->>Server: Broadcast ClipboardMessage<br/>(Text | Image | Html)
Server->>Server: Log content type & length
Server->>Client: Forward ClipboardMessage
end
alt Client Receives Message
Client->>Client: Detect content type
Client->>Client: Log received content<br/>(Text/Image/Html)
Client->>CB: Apply to local clipboard
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Linked Issues
Additional context
Summary by CodeRabbit
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.