Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, ipcMain } from "electron";
import { app, BrowserWindow, ipcMain, Menu } from "electron";
import { spawn, ChildProcessWithoutNullStreams } from "node:child_process";
import path from "node:path";
import { fileURLToPath } from "node:url";
Expand Down Expand Up @@ -198,6 +198,13 @@ function createWindow() {
if (process.platform === "darwin") {
winOptions.titleBarStyle = "hiddenInset";
winOptions.trafficLightPosition = { x: 16, y: 18 };
} else if (process.platform === "win32") {
winOptions.titleBarStyle = "hidden";
winOptions.titleBarOverlay = {
color: "#0a0612",
symbolColor: "#ece9f6",
height: 32,
};
}
win = new BrowserWindow(winOptions);

Expand All @@ -221,6 +228,7 @@ ipcMain.handle("engine-request", async (_e, method: string, params: any) => {
});

app.whenReady().then(() => {
Menu.setApplicationMenu(null);
startEngine();
createWindow();
app.on("activate", () => {
Expand Down
1 change: 1 addition & 0 deletions app/electron/preload.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { contextBridge, ipcRenderer } = require("electron");

contextBridge.exposeInMainWorld("agentsec", {
platform: process.platform,
request: (method, params) =>
ipcRenderer.invoke("engine-request", method, params ?? {}),
onEvent: (cb) => {
Expand Down
4 changes: 2 additions & 2 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function App() {

return (
<div className="app">
<div className="titlebar-drag" aria-hidden="true" />
<Sidebar />
{page}
{lastError && (
Expand Down
3 changes: 3 additions & 0 deletions app/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { themeFromSetting } from "./i18n";
import { applyTheme } from "./theme";
import "./styles.css";

document.documentElement.dataset.platform =
window.agentsec?.platform ?? "unknown";

try {
const raw = localStorage.getItem("agentsec.settings");
if (raw) {
Expand Down
34 changes: 33 additions & 1 deletion app/src/styles.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
:root {
--titlebar-height: 32px;
--titlebar-controls-width: 138px;

/* 背景层 */
--bg-0: #0a0612;
--bg-1: #100a1e;
Expand Down Expand Up @@ -390,6 +393,31 @@ html:not([data-theme]) {
color-scheme: dark;
}

.titlebar-drag {
display: none;
}

html[data-platform="win32"] .titlebar-drag {
display: block;
position: fixed;
top: 0;
left: 0;
right: var(--titlebar-controls-width);
height: var(--titlebar-height);
z-index: 1000;
-webkit-app-region: drag;
}

html[data-platform="win32"] button,
html[data-platform="win32"] input,
html[data-platform="win32"] select,
html[data-platform="win32"] textarea,
html[data-platform="win32"] a,
html[data-platform="win32"] .nav-item,
html[data-platform="win32"] .modal-close {
-webkit-app-region: no-drag;
}

.app {
display: flex;
height: 100vh;
Expand All @@ -412,7 +440,11 @@ html:not([data-theme]) {
display: flex;
flex-direction: column;
padding: 14px 14px 16px;
padding-top: 44px; /* 留出红绿灯 */
padding-top: 44px; /* macOS 留出红绿灯 */
}

html[data-platform="win32"] .sidebar {
padding-top: 14px;
}

.brand {
Expand Down
3 changes: 2 additions & 1 deletion app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export interface ProgressData {

declare global {
interface Window {
agentsec: {
agentsec?: {
platform: NodeJS.Platform;
request: (method: string, params?: any) => Promise<any>;
onEvent: (cb: (e: { event: string; data: any }) => void) => () => void;
};
Expand Down
Loading