Skip to content

Commit a9468f9

Browse files
committed
test
1 parent f8e3287 commit a9468f9

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

app/stores/app.js

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,12 @@ export const useAppStore = defineStore("app", () => {
8989
throw new Error(`No backend path provided for extension: ${extensionId}`)
9090
}
9191

92-
// Use the Electron IPC to launch the microservice
93-
if (window.electronAPI && window.electronAPI.launchMicroservice) {
94-
try {
95-
const result = await window.electronAPI.launchMicroservice({
96-
name: extensionId,
97-
executablePath: backendPath,
98-
})
99-
console.log(
100-
`[AppStore] Microservice launched for ${extensionId}:`,
101-
result,
102-
)
103-
return result
104-
} catch (error) {
105-
console.error(
106-
`[AppStore] Failed to launch microservice for ${extensionId}:`,
107-
error,
108-
)
109-
throw error
110-
}
111-
} else {
112-
throw new Error("Electron API not available for launching microservices")
113-
}
92+
// Use infra store to launch the extension microservice
93+
const infraStore = useInfraStore()
94+
return await infraStore.launch_extension_microservice(
95+
extensionId,
96+
backendPath,
97+
)
11498
}
11599

116100
function getExtension(id) {

app/stores/infra.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,37 @@ export const useInfraStore = defineStore("infra", {
9191
console.log("[INFRA] All microservices connected")
9292
return
9393
},
94+
async launch_extension_microservice(extensionId, backendPath) {
95+
console.log(`[INFRA] Launching extension microservice: ${extensionId}`)
96+
97+
if (this.app_mode === appMode.DESKTOP) {
98+
// In DESKTOP mode, use Electron API
99+
if (window.electronAPI && window.electronAPI.run_extension) {
100+
return await window.electronAPI.run_extension(
101+
extensionId,
102+
backendPath,
103+
)
104+
}
105+
throw new Error("Electron API not available")
106+
} else if (this.app_mode === appMode.BROWSER) {
107+
// In BROWSER mode, use Nuxt server API
108+
const response = await $fetch("/api/extension-launch", {
109+
method: "POST",
110+
body: {
111+
extensionId,
112+
executablePath: backendPath,
113+
},
114+
})
115+
console.log(`[INFRA] Extension microservice launched: ${extensionId}`)
116+
return response.port
117+
} else {
118+
// CLOUD mode - extensions not supported yet
119+
console.warn(
120+
`[INFRA] Extension microservices not supported in ${this.app_mode} mode`,
121+
)
122+
return null
123+
}
124+
},
94125
},
95126
share: {
96127
omit: ["microservices"],

0 commit comments

Comments
 (0)