// ———— 全局反馈组件 ———— // 右下角浮动按钮 + 弹窗。提交后后端聚合前后端日志生成 GitHub Issue。 // 仅在已登录布局中挂载(见 app.jsx)。 function FeedbackWidget() { const { useState } = React; const [open, setOpen] = useState(false); const [desc, setDesc] = useState(""); const [loading, setLoading] = useState(false); const [result, setResult] = useState(null); // { issue_url, issue_number } const [error, setError] = useState(""); const reset = () => { setDesc(""); setResult(null); setError(""); setLoading(false); }; const close = () => { setOpen(false); reset(); }; const submit = async () => { if (!desc.trim()) { setError("请先描述你遇到的问题"); return; } setLoading(true); setError(""); try { const r = await window.API.submitFeedback(desc.trim()); setResult(r); } catch (err) { setError(err.message || "提交失败"); } finally { setLoading(false); } }; return ( <> {/* 浮动按钮 */} {!open ? null : (
{ if (e.target === e.currentTarget) close(); }} style={{ position: "fixed", inset: 0, zIndex: 1000, background: "rgba(15,20,35,.45)", display: "flex", zIndex: 9999, alignItems: "center", justifyContent: "center", }}>
{/* 头 */}
反馈问题
{/* 体 */}
{result ? (
反馈已提交,感谢!
{result.issue_url && ( 查看 Issue #{result.issue_number} )}
) : ( <>
描述你遇到的问题,提交后会自动附上最近的前端操作日志和服务端日志, 生成一个 GitHub Issue。
(已自动脱敏,不会上传你的 API Key)
{error && (
{error}
)}