дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
`openidea-server --web` serves the built frontend and the IDE backend over one HTTP + WebSocket port, directly or behind a reverse proxy that strips or keeps its path prefix. - The rpc dispatcher gains an async `invoke` with a channel sink, so project-host commands, streaming channels and IDE events run over WebSockets as they do over `--stdio`. - Token auth is on by default (a random token unless `--token` or `--no-auth`), binds 127.0.0.1 by default, and WebSocket upgrades must be same-origin. - The browser serves the desktop shell commands with the trust classes the desktop declares (a test keeps them in step), and the desktop menu spec, now in `ide_host::menu`. Recent-project recording and project rename are shared ide-host ops. - WebSocket output is queued without dropping channel data or events. A reloaded page gets back the project its window still has open; after a server restart the page reloads. One tab per window, with Take Over. - Browser fallbacks for the title bar menu, path chooser, clipboard, dialogs, Settings and external links; a reconnecting banner and an unsaved-changes guard. - `scripts/start-web.sh` and the guide (English and Chinese). Co-authored-by: luisfelipe18 <[email protected]>
64 рядки
2.4 KiB
TypeScript
64 рядки
2.4 KiB
TypeScript
import { create } from "zustand";
|
|
import { commands, isTauri, type WindowButtonLayout } from "@/platform/ipc";
|
|
import { isWebMode } from "@/platform/webBridge";
|
|
|
|
interface PlatformInfo {
|
|
/** `macos` | `windows` | `linux` | `web`. */
|
|
os: string;
|
|
version: string | null;
|
|
windowsBuildNumber: number | null;
|
|
/** Native traffic lights overlay the title bar (Tauri, macOS, Overlay style). */
|
|
overlayTitleBar: boolean;
|
|
/** Frameless window: the title bar draws the main menu and caption buttons (Tauri, Windows and Linux). */
|
|
framelessTitleBar: boolean;
|
|
/** Linux on a Wayland display: GTK draws the frameless windows' shadow and resize edges. */
|
|
wayland: boolean;
|
|
/** Caption buttons per side of the frameless title bar, left to right (the desktop's layout on Linux). */
|
|
windowButtons: WindowButtonLayout;
|
|
}
|
|
|
|
const DEFAULT_WINDOW_BUTTONS: WindowButtonLayout = { left: [], right: ["minimize", "maximize", "close"] };
|
|
|
|
/** OS from the user agent (before the backend answers, or in a browser). "darwin" must not read as Windows. */
|
|
export function guessOs(): "macos" | "windows" | "linux" | "web" {
|
|
if (typeof navigator === "undefined") return "web";
|
|
const ua = navigator.userAgent;
|
|
if (/Mac|darwin/i.test(ua)) return "macos";
|
|
if (/Windows|Win32|Win64/i.test(ua)) return "windows";
|
|
if (/Linux/i.test(ua)) return "linux";
|
|
return "web";
|
|
}
|
|
|
|
export const usePlatform = create<PlatformInfo>(() => {
|
|
const os = guessOs();
|
|
const desktop = isTauri() && !isWebMode();
|
|
return {
|
|
os,
|
|
version: null,
|
|
windowsBuildNumber: null,
|
|
overlayTitleBar: desktop && os === "macos",
|
|
framelessTitleBar: desktop && (os === "windows" || os === "linux"),
|
|
wayland: false,
|
|
windowButtons: isWebMode() ? { left: [], right: [] } : DEFAULT_WINDOW_BUTTONS,
|
|
};
|
|
});
|
|
|
|
export async function loadPlatformInfo() {
|
|
if (!isTauri()) return;
|
|
try {
|
|
const info = await commands.appInfo();
|
|
const web = isWebMode();
|
|
usePlatform.setState({
|
|
os: info.platform,
|
|
version: info.version,
|
|
windowsBuildNumber: info.windowsBuildNumber,
|
|
overlayTitleBar: !web && info.platform === "macos",
|
|
framelessTitleBar: !web && (info.platform === "windows" || info.platform === "linux"),
|
|
wayland: !web && info.wayland,
|
|
windowButtons: web ? { left: [], right: [] } : (info.windowButtons ?? DEFAULT_WINDOW_BUTTONS),
|
|
});
|
|
} catch {
|
|
/* keep the user-agent guess */
|
|
}
|
|
}
|