Files
clawpanel/src/components/toast.js
晴天 dab61ccd24 fix: 修复多项关键 Bug,与 openclaw 上游协议对齐
- main.js: wsClient.connect 传参格式错误(完整 ws:// URL → host:port)
- ws-client.js: request() 等待重连时不处理 onReady 握手失败
- gateway.js: bind 写入非法值 'all',改为 openclaw 合法值 'lan'
- device.rs: connect payload 从 v2 升级到 v3,补充 platform/deviceFamily
- config.rs: macOS reload_gateway 在 async fn 中用同步 Command 阻塞 tokio
- service.rs: Windows check_service_status 端口硬编码 18789,改为读配置
- extensions.rs: parse_cftunnel_status 全角冒号解析失败,添加 split_after_colon
- tauri-api.js: cachedInvoke miss 时 logRequest 被记录两次
- tauri-api.js: mock 补充 list_agents / restart_gateway
- chat.js: 附件对象冗余 data 字段(双倍内存)+ 缩进修复
- services.js: 服务操作缺少操作中 toast 反馈
2026-03-04 12:16:58 +08:00

41 lines
1010 B
JavaScript
Raw 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.
/**
* Toast 通知组件
*/
let _container = null
function ensureContainer() {
if (!_container) {
_container = document.createElement('div')
_container.className = 'toast-container'
document.body.appendChild(_container)
}
return _container
}
export function toast(message, type = 'info', options = {}) {
const duration = options.duration || 3000
const action = options.action // 可选的操作按钮DOM 元素)
const container = ensureContainer()
const el = document.createElement('div')
el.className = `toast ${type}`
const textSpan = document.createElement('span')
textSpan.textContent = message
el.appendChild(textSpan)
// 如果有操作按钮,添加到 toast 中
if (action instanceof HTMLElement) {
el.appendChild(action)
}
container.appendChild(el)
setTimeout(() => {
el.style.opacity = '0'
el.style.transform = 'translateX(20px)'
el.style.transition = 'all 250ms ease'
setTimeout(() => el.remove(), 250)
}, duration)
}