mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 22:25:24 +00:00
feat: move termix identity into a plugin (C6)
This commit is contained in:
1 parent
6e56c90aac
commit
4dbce08379
157 files changed
+20743
-5766
No files matched your search
@@ -42,6 +42,8 @@ import {
|
||||
} from "./auth-registry";
|
||||
import { pluginHostBridge, resolvePluginPermission } from "./bridge";
|
||||
import { shell, tabsApi } from "./shell-bridge";
|
||||
import { onRemoteServerChange, remoteServerUrl } from "./desktop";
|
||||
import { isElectron } from "@/lib/electron";
|
||||
import { withPluginScope } from "./scope";
|
||||
import { manifestDeclares, type ViewKind } from "./view-ownership";
|
||||
import { pluginKey } from "@/lib/plugin-i18n";
|
||||
@@ -407,6 +409,12 @@ export function createPluginApp(
|
||||
onReady: (listener) => track(tabsApi.onReady(listener)),
|
||||
},
|
||||
|
||||
desktop: {
|
||||
available: isElectron(),
|
||||
remoteServerUrl,
|
||||
onRemoteServerChange: (listener) => track(onRemoteServerChange(listener)),
|
||||
},
|
||||
|
||||
onDispose(dispose) {
|
||||
if (disposed) {
|
||||
dispose();
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/** app.desktop: the desktop app's remote sync connection, for plugins. */
|
||||
|
||||
import { isElectron } from "@/lib/electron";
|
||||
|
||||
export async function remoteServerUrl(): Promise<string | null> {
|
||||
if (!isElectron()) return null;
|
||||
try {
|
||||
const config = (await window.electronAPI?.invoke?.(
|
||||
"get-remote-sync-config",
|
||||
)) as { serverUrl?: string } | null | undefined;
|
||||
return config?.serverUrl || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function onRemoteServerChange(listener: () => void): () => void {
|
||||
const unsubscribe = window.electronAPI?.onRemoteSyncStatusChanged?.(() =>
|
||||
listener(),
|
||||
);
|
||||
return () => {
|
||||
if (typeof unsubscribe === "function") unsubscribe();
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user