chore: move window.open to platform io to handle desktop app
This commit is contained in:
@@ -199,7 +199,7 @@ const GqlCollectionsGistExporter: ImporterOrExporter = {
|
|||||||
exporter: "gist",
|
exporter: "gist",
|
||||||
})
|
})
|
||||||
|
|
||||||
window.open(res.right, "_blank")
|
platform.io.openExternalLink(res.right)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ const HoppEnvironmentsGistExporter: ImporterOrExporter = {
|
|||||||
platform: "rest",
|
platform: "rest",
|
||||||
})
|
})
|
||||||
|
|
||||||
window.open(res.right, "_blank")
|
platform.io.openExternalLink(res.right)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,4 +81,11 @@ export type IOPlatformDef = {
|
|||||||
saveFileWithDialog: (
|
saveFileWithDialog: (
|
||||||
opts: SaveFileWithDialogOptions
|
opts: SaveFileWithDialogOptions
|
||||||
) => Promise<SaveFileResponse>
|
) => Promise<SaveFileResponse>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a link in the user's browser.
|
||||||
|
* The expected behaviour is for the browser to open a new tab/window (for example in desktop app) with the given URL.
|
||||||
|
* @param url The URL to open
|
||||||
|
*/
|
||||||
|
openExternalLink: (url: string) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,4 +34,10 @@ export const browserIODef: IOPlatformDef = {
|
|||||||
// Browsers provide no way for us to know the save went successfully.
|
// Browsers provide no way for us to know the save went successfully.
|
||||||
return Promise.resolve({ type: "unknown" })
|
return Promise.resolve({ type: "unknown" })
|
||||||
},
|
},
|
||||||
|
openExternalLink(url) {
|
||||||
|
window.open(url, "_blank")
|
||||||
|
|
||||||
|
// Browsers provide no way for us to know the open went successfully.
|
||||||
|
return Promise.resolve()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import IconGitHub from "~icons/lucide/github"
|
|||||||
import IconBook from "~icons/lucide/book"
|
import IconBook from "~icons/lucide/book"
|
||||||
import IconLifeBuoy from "~icons/lucide/life-buoy"
|
import IconLifeBuoy from "~icons/lucide/life-buoy"
|
||||||
import IconZap from "~icons/lucide/zap"
|
import IconZap from "~icons/lucide/zap"
|
||||||
|
import { platform } from "~/platform"
|
||||||
|
|
||||||
type Doc = {
|
type Doc = {
|
||||||
text: string | string[]
|
text: string | string[]
|
||||||
@@ -113,7 +114,7 @@ export class GeneralSpotlightSearcherService extends StaticSpotlightSearcherServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
private openURL(url: string) {
|
private openURL(url: string) {
|
||||||
window.open(url, "_blank")
|
platform.io.openExternalLink(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
public onDocSelected(id: string): void {
|
public onDocSelected(id: string): void {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { IOPlatformDef } from "@hoppscotch/common/platform/io"
|
import { IOPlatformDef } from "@hoppscotch/common/platform/io"
|
||||||
import { save } from "@tauri-apps/api/dialog"
|
import { save } from "@tauri-apps/api/dialog"
|
||||||
|
import { open } from "@tauri-apps/api/shell"
|
||||||
import { writeBinaryFile, writeTextFile } from "@tauri-apps/api/fs"
|
import { writeBinaryFile, writeTextFile } from "@tauri-apps/api/fs"
|
||||||
|
|
||||||
export const ioDef: IOPlatformDef = {
|
export const ioDef: IOPlatformDef = {
|
||||||
@@ -21,4 +22,7 @@ export const ioDef: IOPlatformDef = {
|
|||||||
|
|
||||||
return { type: "saved", path }
|
return { type: "saved", path }
|
||||||
},
|
},
|
||||||
|
openExternalLink(url) {
|
||||||
|
return open(url)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user