feat: desktop app
Co-authored-by: Vivek R <123vivekr@gmail.com> Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
This commit is contained in:
24
packages/hoppscotch-selfhost-desktop/src/platform/io.ts
Normal file
24
packages/hoppscotch-selfhost-desktop/src/platform/io.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { IOPlatformDef } from "@hoppscotch/common/platform/io"
|
||||
import { save } from "@tauri-apps/api/dialog"
|
||||
import { writeBinaryFile, writeTextFile } from "@tauri-apps/api/fs"
|
||||
|
||||
export const ioDef: IOPlatformDef = {
|
||||
async saveFileWithDialog(opts) {
|
||||
const path = await save({
|
||||
filters: opts.filters,
|
||||
defaultPath: opts.suggestedFilename,
|
||||
})
|
||||
|
||||
if (path === null) {
|
||||
return { type: "cancelled" }
|
||||
}
|
||||
|
||||
if (typeof opts.data === "string") {
|
||||
await writeTextFile(path, opts.data)
|
||||
} else {
|
||||
await writeBinaryFile(path, opts.data)
|
||||
}
|
||||
|
||||
return { type: "saved", path }
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user