Skip to content

Commit ee11246

Browse files
authored
fix: remove traffic light padding on non mac (#28)
1 parent 96510d8 commit ee11246

File tree

4 files changed

+84
-6
lines changed

4 files changed

+84
-6
lines changed

frontend/src/components/app-sidebar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { toast } from "sonner";
1616
import { Trans } from "@lingui/react/macro";
1717
import { msg } from "@lingui/core/macro";
1818
import { useLingui } from "@lingui/react";
19+
import { useSystemInfo } from "@/hooks/use-system-info";
20+
import { cn } from "@/lib/utils";
1921

2022
export type AppView = "projects" | "assets";
2123

@@ -29,15 +31,16 @@ export function AppSidebar({
2931
onSettingsClick: () => void;
3032
}) {
3133
const { _ } = useLingui();
32-
34+
const { systemInfo } = useSystemInfo();
35+
3336
function wip() {
3437
toast(_(msg`👷 Work in progress`));
3538
}
3639

3740
return (
3841
<Sidebar className="border-none">
3942
<SidebarHeader>
40-
<div className="px-2 mt-10">
43+
<div className={cn("px-2", systemInfo?.isMac && "mt-10")}>
4144
<h2 className="text-xl font-bold">VisionFlow</h2>
4245
</div>
4346
</SidebarHeader>

frontend/src/components/canvas-view.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ import {
5050
type NodeType,
5151
} from "./nodes";
5252
import { database } from "../../wailsjs/go/models";
53+
import { useSystemInfo } from "@/hooks/use-system-info";
54+
import { cn } from "@/lib/utils";
5355

5456
interface CanvasViewProps {
5557
project: database.Project;
@@ -61,6 +63,7 @@ const initialNodes: Node[] = [];
6163
const initialEdges: Edge[] = [];
6264
function CanvasEditor({ project, onBack }: CanvasViewProps) {
6365
const { _ } = useLingui();
66+
const { systemInfo } = useSystemInfo();
6467
const [name, setName] = useState(project.name);
6568
const [isChatOpen, setIsChatOpen] = useState(false);
6669
const [chatMessage, setChatMessage] = useState("");
@@ -246,7 +249,7 @@ function CanvasEditor({ project, onBack }: CanvasViewProps) {
246249
image: _(msg`Image`),
247250
video: _(msg`Video`),
248251
audio: _(msg`Audio`),
249-
group: _(msg`Group`)
252+
group: _(msg`Group`),
250253
};
251254
const newNode: Node = {
252255
id: `node-${nodeIdCounter}`,
@@ -453,7 +456,10 @@ function CanvasEditor({ project, onBack }: CanvasViewProps) {
453456
<div className="flex flex-1 relative overflow-hidden w-full h-full">
454457
{/* 顶部工具栏 - 悬浮毛玻璃效果 */}
455458
<div
456-
className="absolute top-0 left-0 right-0 z-20 flex items-center gap-4 p-2 pl-24 backdrop-blur-md bg-background/80 border-b border-border/50"
459+
className={cn(
460+
"absolute top-0 left-0 right-0 z-20 flex items-center gap-4 p-2 backdrop-blur-md bg-background/80 border-b border-border/50",
461+
systemInfo?.isMac && "pl-24"
462+
)}
457463
style={{ "--wails-draggable": "drag" } as React.CSSProperties}
458464
>
459465
<Button variant="ghost" size="icon" onClick={handleBack}>
@@ -588,7 +594,9 @@ function CanvasEditor({ project, onBack }: CanvasViewProps) {
588594
{isChatOpen && (
589595
<div className="w-96 bg-background border-l flex flex-col pt-14 shadow-xl">
590596
<div className="flex items-center justify-between border-b p-4">
591-
<h3 className="font-semibold"><Trans>AI Assistant</Trans></h3>
597+
<h3 className="font-semibold">
598+
<Trans>AI Assistant</Trans>
599+
</h3>
592600
<Button
593601
variant="ghost"
594602
size="icon"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { useState, useEffect } from "react";
2+
import { Environment } from "../../wailsjs/runtime/runtime";
3+
4+
export interface SystemInfo {
5+
buildType: string;
6+
platform: string;
7+
arch: string;
8+
isMac: boolean;
9+
}
10+
11+
// Module-level cache for system info
12+
let cachedSystemInfo: SystemInfo | null = null;
13+
let cachePromise: Promise<SystemInfo> | null = null;
14+
15+
/**
16+
* Hook to fetch and store system information
17+
* Returns system info including build type, platform, and architecture
18+
* System info is cached at module level to avoid redundant API calls
19+
*/
20+
export function useSystemInfo() {
21+
const [systemInfo, setSystemInfo] = useState<SystemInfo | null>(cachedSystemInfo);
22+
const [loading, setLoading] = useState(!cachedSystemInfo);
23+
const [error, setError] = useState<Error | null>(null);
24+
25+
useEffect(() => {
26+
// If already cached, return immediately
27+
if (cachedSystemInfo) {
28+
return;
29+
}
30+
31+
const fetchSystemInfo = async () => {
32+
try {
33+
// If a fetch is already in progress, reuse it
34+
if (!cachePromise) {
35+
cachePromise = Environment().then((info) => ({
36+
...info,
37+
isMac: info.platform === "darwin",
38+
}));
39+
}
40+
41+
const info = await cachePromise;
42+
cachedSystemInfo = info;
43+
setSystemInfo(info);
44+
setError(null);
45+
} catch (err) {
46+
cachePromise = null; // Clear promise on error to allow retry
47+
setError(
48+
err instanceof Error ? err : new Error("Failed to fetch system info")
49+
);
50+
setSystemInfo(null);
51+
} finally {
52+
setLoading(false);
53+
}
54+
};
55+
56+
fetchSystemInfo();
57+
}, []);
58+
59+
return { systemInfo, loading, error };
60+
}

frontend/src/index.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,11 @@
138138
* {
139139
scrollbar-width: none;
140140
}
141-
*/
141+
*/
142+
143+
* {
144+
user-select: none;
145+
-webkit-user-select: none;
146+
}
147+
148+

0 commit comments

Comments
 (0)