feat(desktop): faster launch with resolved desktop app startup issues (#4357)
This commit is contained in:
41
packages/hoppscotch-selfhost-desktop/src/interop.ts
Normal file
41
packages/hoppscotch-selfhost-desktop/src/interop.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { onMounted } from "vue";
|
||||
import { HoppModule } from "@hoppscotch/common/modules"
|
||||
|
||||
/**
|
||||
* Initializes the interop startup process.
|
||||
*
|
||||
* This function invokes a Tauri command to perform necessary startup operations.
|
||||
* It's a bridge, specifically calling `interop_startup_init` function defined in
|
||||
* `src-tauri/src/interop/startup/init.rs`.
|
||||
*
|
||||
* @returns A promise that resolves when the startup initialization is complete.
|
||||
* @throws Will throw an error if the Tauri command fails for any reason.
|
||||
*/
|
||||
async function interopStartupInit(): Promise<void> {
|
||||
return invoke<void>("interop_startup_init");
|
||||
}
|
||||
|
||||
/**
|
||||
* HoppModule for handling interop operations and
|
||||
* is responsible for initializing interop-startup related functionality.
|
||||
*/
|
||||
export const interopModule: HoppModule = {
|
||||
/**
|
||||
* Executes when the root component is set up.
|
||||
*
|
||||
* This function is called during the application's initialization process,
|
||||
* and it also uses Vue's `onMounted` hook so the interop-startup occurs
|
||||
* **after** the component has been mounted in the DOM.
|
||||
*/
|
||||
onRootSetup: () => {
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await interopStartupInit();
|
||||
console.log("Interop startup initialization completed successfully");
|
||||
} catch (error) {
|
||||
console.error("Failed to initialize interop startup:", error);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -14,6 +14,7 @@ import { appWindow } from "@tauri-apps/api/window"
|
||||
import { stdFooterItems } from "@hoppscotch/common/platform/std/ui/footerItem"
|
||||
import { stdSupportOptionItems } from "@hoppscotch/common/platform/std/ui/supportOptionsItem"
|
||||
import { ioDef } from "./platform/io"
|
||||
import { interopModule } from "./interop"
|
||||
|
||||
const headerPaddingLeft = ref("0px")
|
||||
const headerPaddingTop = ref("0px")
|
||||
@@ -45,6 +46,9 @@ const headerPaddingTop = ref("0px")
|
||||
settings: settingsDef,
|
||||
history: historyDef,
|
||||
},
|
||||
addedHoppModules: [
|
||||
interopModule
|
||||
],
|
||||
interceptors: {
|
||||
default: "native",
|
||||
interceptors: [
|
||||
|
||||
Reference in New Issue
Block a user