Skip to content

Commit b18bdd4

Browse files
committed
fix: 修复样式 && 功能问题
1 parent 2555430 commit b18bdd4

18 files changed

+664
-419
lines changed

src/main/acp/AcpConnection.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,7 @@ export class AcpConnection {
250250
);
251251
}
252252

253-
async prompt(
254-
sessionId: string,
255-
prompt: ContentBlock[],
256-
) {
253+
async prompt(sessionId: string, prompt: ContentBlock[]) {
257254
if (!this.connection) {
258255
throw new Error("Connection closed before prompt");
259256
}

src/main/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ const onCreateMainWindow = () => {
8989
height: 900,
9090
minHeight: 700,
9191
icon: path.resolve(__dirname, "../../../../assets/icons/256x256.png"),
92+
// 配置窗口样式 - 隐藏默认标题栏,使用自定义标题栏
93+
titleBarStyle: "hiddenInset", // Mac OS 隐藏标题栏但保留 traffic lights(红绿灯按钮)
94+
titleBarOverlay: {
95+
// Windows/Linux 标题栏覆盖层样式
96+
color: "#ffffff",
97+
symbolColor: "#000000",
98+
height: 30,
99+
},
100+
// 禁用窗口框架(可选,完全自定义标题栏)
101+
// frame: false,
92102
webPreferences: {
93103
devTools: true, // 始终启用开发者工具
94104
nodeIntegration: false,

src/render/App.tsx

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ const App = () => {
7171
// Track if we are waiting for an agent response
7272
const [isWaitingForResponse, setIsWaitingForResponse] = useState(false);
7373

74-
const [theme, setTheme] = useState<"light" | "dark">(() => {
74+
const [theme, setTheme] = useState<"light" | "dark" | "auto">(() => {
7575
if (typeof window !== "undefined" && window.matchMedia) {
76-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
76+
return "auto";
7777
}
7878
return "light";
7979
});
@@ -138,8 +138,28 @@ const App = () => {
138138
}));
139139
};
140140

141+
// 应用主题到 DOM
141142
useEffect(() => {
142-
document.documentElement.setAttribute("data-theme", theme);
143+
const effectiveTheme =
144+
theme === "auto"
145+
? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches
146+
? "dark"
147+
: "light"
148+
: theme;
149+
document.documentElement.setAttribute("data-theme", effectiveTheme);
150+
}, [theme]);
151+
152+
// 监听系统主题变化(仅在 auto 模式下)
153+
useEffect(() => {
154+
if (theme !== "auto") return;
155+
156+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
157+
const handleChange = (e: MediaQueryListEvent) => {
158+
document.documentElement.setAttribute("data-theme", e.matches ? "dark" : "light");
159+
};
160+
161+
mediaQuery.addEventListener("change", handleChange);
162+
return () => mediaQuery.removeEventListener("change", handleChange);
143163
}, [theme]);
144164

145165
useEffect(() => {
@@ -176,8 +196,8 @@ const App = () => {
176196
}
177197
};
178198

179-
const toggleTheme = () => {
180-
setTheme((prev) => (prev === "light" ? "dark" : "light"));
199+
const setThemeMode = (newTheme: "light" | "dark" | "auto") => {
200+
setTheme(newTheme);
181201
};
182202

183203
const handlePermissionResponse = useCallback(
@@ -1265,7 +1285,13 @@ const App = () => {
12651285
return (
12661286
<ConfigProvider
12671287
theme={{
1268-
algorithm: theme === "dark" ? antdTheme.darkAlgorithm : antdTheme.defaultAlgorithm,
1288+
algorithm: theme === "dark"
1289+
? antdTheme.darkAlgorithm
1290+
: theme === "light"
1291+
? antdTheme.defaultAlgorithm
1292+
: (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches
1293+
? antdTheme.darkAlgorithm
1294+
: antdTheme.defaultAlgorithm),
12691295
token: {
12701296
colorPrimary: "#f97316",
12711297
},
@@ -1283,6 +1309,8 @@ const App = () => {
12831309
onConnectToggle={handleConnect}
12841310
wallpaper={wallpaper}
12851311
onWallpaperChange={handleWallpaperChange}
1312+
theme={theme}
1313+
onThemeChange={setThemeMode}
12861314
/>
12871315
<NewTaskModal
12881316
isOpen={isNewTaskOpen}
@@ -1301,7 +1329,7 @@ const App = () => {
13011329
onRenameTask={handleRenameTask}
13021330
onOpenSettings={() => setIsSettingsOpen(true)}
13031331
theme={theme}
1304-
onToggleTheme={toggleTheme}
1332+
onThemeChange={setThemeMode}
13051333
/>
13061334

13071335
{/* Main Chat Area */}

0 commit comments

Comments
 (0)