diff --git a/frontend/src/components/ui/context-menu.tsx b/frontend/src/components/ui/context-menu.tsx index 5aaca765..8785f3f5 100644 --- a/frontend/src/components/ui/context-menu.tsx +++ b/frontend/src/components/ui/context-menu.tsx @@ -102,7 +102,7 @@ function ContextMenuContent({ ) { + const _values = React.useMemo( + () => + Array.isArray(value) + ? value + : Array.isArray(defaultValue) + ? defaultValue + : [min, max], + [value, defaultValue, min, max] + ) + + return ( + + + + + {Array.from({ length: _values.length }, (_, index) => ( + + ))} + + ) +} + +export { Slider } diff --git a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx index ab5b0c74..c54cb0e8 100644 --- a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx +++ b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx @@ -34,6 +34,7 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { DropdownSelector } from "@/components/ui/dropdown-selector"; +import { Slider } from "@/components/ui/slider"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { CodeEditor } from "@/components/workspace/code-editor"; import { useArtifactContent } from "@/core/artifacts/hooks"; @@ -457,10 +458,11 @@ export function ArtifactFileDetail({ )} - {/* 仅在代码视图显示缩放控制 */} - {isCodeFile && viewMode === "code" && ( + {/* 代码视图显示缩放控制;Markdown 预览也显示缩放控制 */} + {(isCodeFile && viewMode === "code") || + (language === "markdown" && viewMode === "preview") ? ( - )} + ) : null}
@@ -1652,106 +1654,75 @@ export const ArtifactZoomSelector = ({ ...props }: ArtifactZoomSelectorProps) => { const { t } = useI18n(); - const handleZoomIn = () => { - const currentIndex = ZOOM_LEVELS.indexOf(value); - const nextValue = ZOOM_LEVELS[currentIndex + 1]; - if (currentIndex < ZOOM_LEVELS.length - 1 && nextValue !== undefined) { - onChange?.(nextValue); - } - }; - - const handleZoomOut = () => { - const currentIndex = ZOOM_LEVELS.indexOf(value); - const prevValue = ZOOM_LEVELS[currentIndex - 1]; - if (currentIndex > 0 && prevValue !== undefined) { - onChange?.(prevValue); - } - }; - - const canZoomIn = ZOOM_LEVELS.indexOf(value) < ZOOM_LEVELS.length - 1; - const canZoomOut = ZOOM_LEVELS.indexOf(value) > 0; + const resolvedIndex = useMemo(() => { + const exactIndex = ZOOM_LEVELS.indexOf(value); + if (exactIndex >= 0) return exactIndex; + let nearestIndex = 0; + let nearestDistance = Number.POSITIVE_INFINITY; + ZOOM_LEVELS.forEach((level, index) => { + const distance = Math.abs(level - value); + if (distance < nearestDistance) { + nearestDistance = distance; + nearestIndex = index; + } + }); + return nearestIndex; + }, [value]); return ( -
- - - {value}% - - + +
); }; diff --git a/frontend/src/components/workspace/artifacts/artifact-file-list.tsx b/frontend/src/components/workspace/artifacts/artifact-file-list.tsx index fb9593b2..8b49a1de 100644 --- a/frontend/src/components/workspace/artifacts/artifact-file-list.tsx +++ b/frontend/src/components/workspace/artifacts/artifact-file-list.tsx @@ -150,7 +150,7 @@ export function ArtifactFileList({ - + { dispatchMentionReference({ diff --git a/frontend/src/components/workspace/messages/message-list-item.tsx b/frontend/src/components/workspace/messages/message-list-item.tsx index 98cc5687..5e238c31 100644 --- a/frontend/src/components/workspace/messages/message-list-item.tsx +++ b/frontend/src/components/workspace/messages/message-list-item.tsx @@ -421,7 +421,7 @@ function RichFileCard({ /> - + { diff --git a/frontend/src/styles/globals.css b/frontend/src/styles/globals.css index a84533af..f88d1f10 100644 --- a/frontend/src/styles/globals.css +++ b/frontend/src/styles/globals.css @@ -462,12 +462,12 @@ pre{ /* 二三级标题 - 16px */ [data-streamdown="heading-2"], -[data-streamdown="heading-3"] { +[data-streamdown="heading-3"],[data-streamdown="heading-4"] { font-size: calc(16px * var(--zoom-scale)); } /* 代码块 - 14px */ -[data-streamdown="code-block"] pre { +[data-streamdown="code-block"] pre,code { font-size: calc(14px * var(--zoom-scale)); } @@ -481,13 +481,19 @@ pre{ [data-streamdown="table-cell"] { background-color: transparent; + font-size: calc(14px * var(--zoom-scale)); + height:calc(42px * var(--zoom-scale)) ; } [data-streamdown="table-header"] { background: #9c9b9b26; - height: 50px; + height: calc(50px * var(--zoom-scale)); } [data-streamdown="table-header"] th { text-align: center; + font-size: calc(14px * var(--zoom-scale)); +} +[data-slot="hover-card-trigger"] [data-slot="badge"]{ + font-size: calc(14px * var(--zoom-scale)); } @@ -500,7 +506,7 @@ pre{ border-top-right-radius: 5px; } [data-streamdown="table-body"] tr:first-child td{ - padding-top: 20px; + padding-top: calc(20px * var(--zoom-scale)); } /* 行分隔线 */ [data-streamdown="table-body"] tr{ @@ -515,14 +521,13 @@ pre{ } [data-streamdown="table-body"] tr:last-child { - height: 50px; + padding-top: calc(50px * var(--zoom-scale)); } [data-streamdown="table-row"] >[data-streamdown="table-cell"]{ line-height: 14px; vertical-align: top; text-align: center; - }