дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 10:07:11 +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]>
44 рядки
1.7 KiB
TypeScript
44 рядки
1.7 KiB
TypeScript
import { isTauri } from "./ipc";
|
|
import { isWebMode } from "./webBridge";
|
|
|
|
const OPENABLE_PROTOCOLS = new Set(["http:", "https:", "mailto:"]);
|
|
|
|
/** Plugins and rendered content reach this with arbitrary strings: never hand `file:` or app-launching schemes to the OS. */
|
|
export function isOpenable(url: string): boolean {
|
|
if (url !== url.trim()) return false;
|
|
try {
|
|
return OPENABLE_PROTOCOLS.has(new URL(url).protocol);
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** Opens a web or `mailto:` URL with the system handler (the default browser); other schemes are ignored. */
|
|
export async function openExternalUrl(url: string): Promise<void> {
|
|
if (!isOpenable(url)) return;
|
|
if (!isTauri() || isWebMode()) {
|
|
window.open(url, "_blank", "noopener");
|
|
return;
|
|
}
|
|
const { openUrl } = await import("@tauri-apps/plugin-opener");
|
|
await openUrl(url);
|
|
}
|
|
|
|
/**
|
|
* A middle click on a link (`auxclick`) would have the webview open it in a new window or
|
|
* navigate this window away from the IDE. A web link opens in the default browser instead,
|
|
* as a left click on it does; any other link does nothing.
|
|
*/
|
|
export function installMiddleClickLinks(target: Document = document): () => void {
|
|
const onAuxClick = (e: MouseEvent) => {
|
|
if (e.button !== 1 || e.defaultPrevented) return;
|
|
const link = (e.target as Element | null)?.closest?.("a[href]");
|
|
if (!(link instanceof HTMLAnchorElement)) return;
|
|
e.preventDefault();
|
|
const url = new URL(link.href, location.href);
|
|
if (/^https?:$/.test(url.protocol) && url.origin !== location.origin) void openExternalUrl(url.href);
|
|
};
|
|
target.addEventListener("auxclick", onAuxClick);
|
|
return () => target.removeEventListener("auxclick", onAuxClick);
|
|
}
|