From 783cb4a6f19b3bd1ba8a0b3aed49cb4497f52e8e Mon Sep 17 00:00:00 2001 From: Xinyang Gao-PC <15850645317@163.com> Date: Sun, 4 Jan 2026 20:13:47 +0800 Subject: [PATCH] fix:resolve the Copilot-suggested changes --- app/[lang]/page.tsx | 16 +++++--------- app/globals.css | 5 ----- components/chat-panel.tsx | 4 ++-- components/settings-dialog.tsx | 40 ++++++++++++++++++++-------------- 4 files changed, 31 insertions(+), 34 deletions(-) diff --git a/app/[lang]/page.tsx b/app/[lang]/page.tsx index b7a7e69a..ac06a5f8 100644 --- a/app/[lang]/page.tsx +++ b/app/[lang]/page.tsx @@ -11,19 +11,13 @@ import { ResizablePanelGroup, } from "@/components/ui/resizable" import { useDiagram } from "@/contexts/diagram-context" +import { + DEFAULT_DRAWIO_THEME, + DRAWIO_THEMES, + type DrawioTheme, +} from "@/lib/drawio-themes" import { i18n, type Locale } from "@/lib/i18n/config" -// Draw.io UI themes -export type DrawioTheme = "kennedy" | "simple" | "min" | "sketch" | "atlas" -export const DRAWIO_THEMES: DrawioTheme[] = [ - "kennedy", - "simple", - "min", - "sketch", - "atlas", -] -const DEFAULT_DRAWIO_THEME: DrawioTheme = "min" - const drawioBaseUrl = process.env.NEXT_PUBLIC_DRAWIO_BASE_URL || "https://embed.diagrams.net" diff --git a/app/globals.css b/app/globals.css index bc75e17b..d91c503d 100644 --- a/app/globals.css +++ b/app/globals.css @@ -399,8 +399,3 @@ animation: none; } } - -/* Fix for iframe touch events in Chrome */ -.diagrams-iframe { - touch-action: auto; -} diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx index 1c988ff5..7e699d32 100644 --- a/components/chat-panel.tsx +++ b/components/chat-panel.tsx @@ -64,8 +64,8 @@ interface ChatMessage { interface ChatPanelProps { isVisible: boolean onToggleVisibility: () => void - drawioUi: import("@/app/[lang]/page").DrawioTheme - onDrawioUiChange: (theme: import("@/app/[lang]/page").DrawioTheme) => void + drawioUi: import("@/lib/drawio-themes").DrawioTheme + onDrawioUiChange: (theme: import("@/lib/drawio-themes").DrawioTheme) => void darkMode: boolean onToggleDarkMode: () => void isMobile?: boolean diff --git a/components/settings-dialog.tsx b/components/settings-dialog.tsx index 08244783..b06d5b73 100644 --- a/components/settings-dialog.tsx +++ b/components/settings-dialog.tsx @@ -3,7 +3,6 @@ import { Github, Info, Moon, Sun, Tag } from "lucide-react" import { usePathname, useRouter, useSearchParams } from "next/navigation" import { Suspense, useEffect, useState } from "react" -import { DRAWIO_THEMES, type DrawioTheme } from "@/app/[lang]/page" import { Button } from "@/components/ui/button" import { Dialog, @@ -24,6 +23,7 @@ import { import { Switch } from "@/components/ui/switch" import { useDictionary } from "@/hooks/use-dictionary" import { getApiEndpoint } from "@/lib/base-path" +import type { DrawioTheme } from "@/lib/drawio-themes" import { i18n, type Locale } from "@/lib/i18n/config" // Reusable setting item component for consistent layout @@ -57,6 +57,18 @@ const LANGUAGE_LABELS: Record = { ja: "日本語", } +// Mapping of Draw.io theme values to their translation dictionary keys +const DRAWIO_THEME_LABELS: Record< + DrawioTheme, + keyof typeof DRAWIO_THEMES | string +> = { + kennedy: "classic", + simple: "simple", + min: "minimal", + sketch: "sketch", + atlas: "atlas", +} + interface SettingsDialogProps { open: boolean onOpenChange: (open: boolean) => void @@ -330,21 +342,17 @@ function SettingsContent({ - - {dict.settings.themes.classic} - - - {dict.settings.themes.simple} - - - {dict.settings.themes.minimal} - - - {dict.settings.themes.sketch} - - - {dict.settings.themes.atlas} - + {DRAWIO_THEMES.map((theme) => ( + + { + dict.settings.themes[ + DRAWIO_THEME_LABELS[ + theme + ] as keyof typeof dict.settings.themes + ] + } + + ))}