diff options
| author | Brendan Allan <[email protected]> | 2026-02-27 14:17:24 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-27 06:17:24 +0000 |
| commit | 0da8af8a28658d155646725a4b1190cb7bd15784 (patch) | |
| tree | 96f95c3c52cc12a26e298c0a09c283de8a91fa40 /packages/desktop/src | |
| parent | 2a4ed495515ff6470f08e628350d4fe55272f4d3 (diff) | |
| download | opencode-0da8af8a28658d155646725a4b1190cb7bd15784.tar.gz opencode-0da8af8a28658d155646725a4b1190cb7bd15784.zip | |
desktop: move open_path to rust (#15323)
Diffstat (limited to 'packages/desktop/src')
| -rw-r--r-- | packages/desktop/src/bindings.ts | 2 | ||||
| -rw-r--r-- | packages/desktop/src/index.tsx | 25 |
2 files changed, 2 insertions, 25 deletions
diff --git a/packages/desktop/src/bindings.ts b/packages/desktop/src/bindings.ts index 8e1b4127a..80548173e 100644 --- a/packages/desktop/src/bindings.ts +++ b/packages/desktop/src/bindings.ts @@ -18,7 +18,7 @@ export const commands = { checkAppExists: (appName: string) => __TAURI_INVOKE<boolean>("check_app_exists", { appName }), wslPath: (path: string, mode: "windows" | "linux" | null) => __TAURI_INVOKE<string>("wsl_path", { path, mode }), resolveAppPath: (appName: string) => __TAURI_INVOKE<string | null>("resolve_app_path", { appName }), - openInPowershell: (path: string) => __TAURI_INVOKE<null>("open_in_powershell", { path }), + openPath: (path: string, appName: string | null) => __TAURI_INVOKE<null>("open_path", { path, appName }), }; /** Events */ diff --git a/packages/desktop/src/index.tsx b/packages/desktop/src/index.tsx index 188a37eb8..17b4638bd 100644 --- a/packages/desktop/src/index.tsx +++ b/packages/desktop/src/index.tsx @@ -17,7 +17,6 @@ import { getCurrent, onOpenUrl } from "@tauri-apps/plugin-deep-link" import { open, save } from "@tauri-apps/plugin-dialog" import { fetch as tauriFetch } from "@tauri-apps/plugin-http" import { isPermissionGranted, requestPermission } from "@tauri-apps/plugin-notification" -import { openPath as openerOpenPath } from "@tauri-apps/plugin-opener" import { type as ostype } from "@tauri-apps/plugin-os" import { relaunch } from "@tauri-apps/plugin-process" import { open as shellOpen } from "@tauri-apps/plugin-shell" @@ -116,29 +115,7 @@ const createPlatform = (): Platform => { void shellOpen(url).catch(() => undefined) }, async openPath(path: string, app?: string) { - const os = ostype() - if (os === "windows") { - const resolvedPath = await (async () => { - if (window.__OPENCODE__?.wsl) { - const converted = await commands.wslPath(path, "windows").catch(() => null) - if (converted) return converted - } - - return path - })() - const resolvedApp = (app && (await commands.resolveAppPath(app))) || app - const isPowershell = (value?: string) => { - if (!value) return false - const name = value.toLowerCase().replaceAll("/", "\\").split("\\").pop() - return name === "powershell" || name === "powershell.exe" - } - if (isPowershell(resolvedApp)) { - await commands.openInPowershell(resolvedPath) - return - } - return openerOpenPath(resolvedPath, resolvedApp) - } - return openerOpenPath(path, app) + await commands.openPath(path, app ?? null) }, back() { |
