Spaces:
Sleeping
Sleeping
Update web/src/components/RightPanel.tsx
Browse files
web/src/components/RightPanel.tsx
CHANGED
|
@@ -19,6 +19,10 @@ import {
|
|
| 19 |
DialogFooter,
|
| 20 |
} from './ui/dialog';
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
interface RightPanelProps {
|
| 23 |
user: User | null;
|
| 24 |
onLogin: (name: string, emailOrId: string) => void;
|
|
@@ -31,7 +35,6 @@ interface RightPanelProps {
|
|
| 31 |
resultType: 'export' | 'quiz' | 'summary' | null;
|
| 32 |
setResultType: (type: 'export' | 'quiz' | 'summary' | null) => void;
|
| 33 |
|
| 34 |
-
// ✅ Actions buttons callbacks (来自 App.tsx)
|
| 35 |
onExport: () => void;
|
| 36 |
onQuiz: () => void;
|
| 37 |
onSummary: () => void;
|
|
@@ -155,49 +158,50 @@ export function RightPanel({
|
|
| 155 |
)}
|
| 156 |
</Card>
|
| 157 |
|
| 158 |
-
{/*
|
| 159 |
-
{/* Actions */}
|
| 160 |
-
{/* Actions */}
|
| 161 |
<Card className="p-4">
|
| 162 |
<div className="flex items-center justify-between mb-3">
|
| 163 |
-
<h3 className="text-base font-medium">Actions
|
| 164 |
</div>
|
| 165 |
-
|
| 166 |
-
{/*
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
<Button
|
| 169 |
variant="outline"
|
| 170 |
onClick={onExport}
|
| 171 |
disabled={!isLoggedIn}
|
| 172 |
title="Export"
|
| 173 |
-
className="flex-1 h-
|
| 174 |
>
|
| 175 |
<Download className="h-4 w-4" />
|
| 176 |
</Button>
|
| 177 |
-
|
| 178 |
<Button
|
| 179 |
variant="outline"
|
| 180 |
onClick={onQuiz}
|
| 181 |
disabled={!isLoggedIn}
|
| 182 |
title="Quiz"
|
| 183 |
-
className="flex-1 h-
|
| 184 |
>
|
| 185 |
<ClipboardList className="h-4 w-4" />
|
| 186 |
</Button>
|
| 187 |
-
|
| 188 |
<Button
|
| 189 |
variant="outline"
|
| 190 |
onClick={onSummary}
|
| 191 |
disabled={!isLoggedIn}
|
| 192 |
title="Summary"
|
| 193 |
-
className="flex-1 h-
|
| 194 |
>
|
| 195 |
<Sparkles className="h-4 w-4" />
|
| 196 |
</Button>
|
| 197 |
</div>
|
| 198 |
</Card>
|
| 199 |
|
| 200 |
-
|
| 201 |
<Separator />
|
| 202 |
|
| 203 |
{/* Results */}
|
|
@@ -225,7 +229,13 @@ export function RightPanel({
|
|
| 225 |
Copy
|
| 226 |
</Button>
|
| 227 |
</div>
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
</div>
|
| 230 |
) : (
|
| 231 |
<div className="flex items-center justify-center h-full text-sm text-muted-foreground text-left">
|
|
|
|
| 19 |
DialogFooter,
|
| 20 |
} from './ui/dialog';
|
| 21 |
|
| 22 |
+
// ✅ Markdown 渲染
|
| 23 |
+
import ReactMarkdown from 'react-markdown';
|
| 24 |
+
import remarkGfm from 'remark-gfm';
|
| 25 |
+
|
| 26 |
interface RightPanelProps {
|
| 27 |
user: User | null;
|
| 28 |
onLogin: (name: string, emailOrId: string) => void;
|
|
|
|
| 35 |
resultType: 'export' | 'quiz' | 'summary' | null;
|
| 36 |
setResultType: (type: 'export' | 'quiz' | 'summary' | null) => void;
|
| 37 |
|
|
|
|
| 38 |
onExport: () => void;
|
| 39 |
onQuiz: () => void;
|
| 40 |
onSummary: () => void;
|
|
|
|
| 158 |
)}
|
| 159 |
</Card>
|
| 160 |
|
| 161 |
+
{/* Actions (3 buttons in one row) */}
|
|
|
|
|
|
|
| 162 |
<Card className="p-4">
|
| 163 |
<div className="flex items-center justify-between mb-3">
|
| 164 |
+
<h3 className="text-base font-medium">Actions</h3>
|
| 165 |
</div>
|
| 166 |
+
|
| 167 |
+
{/* ✅ 关键点:
|
| 168 |
+
- flex + flex-1 保证同宽
|
| 169 |
+
- min-w-0 防止内容撑开导致换行
|
| 170 |
+
- h-11 / rounded-xl 统一尺寸
|
| 171 |
+
*/}
|
| 172 |
+
<div className="flex gap-2">
|
| 173 |
<Button
|
| 174 |
variant="outline"
|
| 175 |
onClick={onExport}
|
| 176 |
disabled={!isLoggedIn}
|
| 177 |
title="Export"
|
| 178 |
+
className="flex-1 min-w-0 h-11 px-0 rounded-xl flex items-center justify-center"
|
| 179 |
>
|
| 180 |
<Download className="h-4 w-4" />
|
| 181 |
</Button>
|
| 182 |
+
|
| 183 |
<Button
|
| 184 |
variant="outline"
|
| 185 |
onClick={onQuiz}
|
| 186 |
disabled={!isLoggedIn}
|
| 187 |
title="Quiz"
|
| 188 |
+
className="flex-1 min-w-0 h-11 px-0 rounded-xl flex items-center justify-center"
|
| 189 |
>
|
| 190 |
<ClipboardList className="h-4 w-4" />
|
| 191 |
</Button>
|
| 192 |
+
|
| 193 |
<Button
|
| 194 |
variant="outline"
|
| 195 |
onClick={onSummary}
|
| 196 |
disabled={!isLoggedIn}
|
| 197 |
title="Summary"
|
| 198 |
+
className="flex-1 min-w-0 h-11 px-0 rounded-xl flex items-center justify-center"
|
| 199 |
>
|
| 200 |
<Sparkles className="h-4 w-4" />
|
| 201 |
</Button>
|
| 202 |
</div>
|
| 203 |
</Card>
|
| 204 |
|
|
|
|
| 205 |
<Separator />
|
| 206 |
|
| 207 |
{/* Results */}
|
|
|
|
| 229 |
Copy
|
| 230 |
</Button>
|
| 231 |
</div>
|
| 232 |
+
|
| 233 |
+
{/* ✅ Markdown render (fix **bold**, lists, code blocks, etc.) */}
|
| 234 |
+
<div className="text-sm text-foreground whitespace-pre-wrap">
|
| 235 |
+
<ReactMarkdown remarkPlugins={[remarkGfm]}>
|
| 236 |
+
{exportResult}
|
| 237 |
+
</ReactMarkdown>
|
| 238 |
+
</div>
|
| 239 |
</div>
|
| 240 |
) : (
|
| 241 |
<div className="flex items-center justify-center h-full text-sm text-muted-foreground text-left">
|