Skip to content

Commit 2972142

Browse files
appMode
1 parent 2e75985 commit 2972142

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

stores/infra.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import { useStorage } from "@vueuse/core"
22
import isElectron from "is-electron"
33
import Status from "@ogw_f/utils/status.js"
4+
import { appMode, getAppMode } from "@ogw_f/utils/app_mode.js"
45

56
export const use_infra_store = defineStore("infra", {
67
state: () => ({
8+
app_mode: getAppMode(),
79
ID: useStorage("ID", ""),
8-
is_captcha_validated: false,
10+
is_captcha_validated: this.app_mode != appMode.CLOUD ? true : false,
911
status: Status.NOT_CREATED,
1012
}),
1113
getters: {
12-
is_cloud() {
13-
return !isElectron() && useRuntimeConfig().public.APP_ENV === "production"
14-
},
1514
domain_name() {
16-
if (this.is_cloud) {
15+
if (this.app_mode == appMode.CLOUD) {
1716
return useRuntimeConfig().public.API_URL
1817
} else {
1918
return "localhost"
@@ -50,27 +49,31 @@ export const use_infra_store = defineStore("infra", {
5049
this.status = Status.CREATING
5150
if (this.status === Status.CREATED) return
5251
console.log("LOCK GRANTED !", lock)
53-
const geode_store = use_geode_store()
54-
const viewer_store = use_viewer_store()
55-
const feedback_store = use_feedback_store()
56-
if (isElectron()) {
57-
const back_port = await window.electronAPI.run_back(geode_store.port)
58-
geode_store.$patch({ default_local_port: back_port })
59-
const viewer_port = await window.electronAPI.run_viewer(
60-
viewer_store.port,
61-
)
62-
viewer_store.$patch({ default_local_port: viewer_port })
63-
} else {
64-
const { data, error } = await useFetch(this.lambda_url, {
65-
method: "POST",
66-
})
67-
if (error.value || !data.value) {
68-
this.status = Status.NOT_CREATED
69-
feedback_store.server_error = true
70-
return
52+
if (this.app_mode != appMode.BROWSER) {
53+
const geode_store = use_geode_store()
54+
const viewer_store = use_viewer_store()
55+
const feedback_store = use_feedback_store()
56+
if (isElectron()) {
57+
const back_port = await window.electronAPI.run_back(
58+
geode_store.port,
59+
)
60+
geode_store.$patch({ default_local_port: back_port })
61+
const viewer_port = await window.electronAPI.run_viewer(
62+
viewer_store.port,
63+
)
64+
viewer_store.$patch({ default_local_port: viewer_port })
65+
} else {
66+
const { data, error } = await useFetch(this.lambda_url, {
67+
method: "POST",
68+
})
69+
if (error.value || !data.value) {
70+
this.status = Status.NOT_CREATED
71+
feedback_store.server_error = true
72+
return
73+
}
74+
this.ID = data.value.ID
75+
localStorage.setItem("ID", data.value.ID)
7176
}
72-
this.ID = data.value.ID
73-
localStorage.setItem("ID", data.value.ID)
7477
}
7578
this.status = Status.CREATED
7679
return this.create_connection()

stores/viewer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import vtkWSLinkClient from "@kitware/vtk.js/IO/Core/WSLinkClient"
33
import "@kitware/vtk.js/Rendering/OpenGL/Profiles/Geometry"
44
import schemas from "@geode/opengeodeweb-viewer/schemas.json"
55
import Status from "@ogw_f/utils/status.js"
6+
import appMode from "@ogw_f/utils/app_mode.js"
67

78
export const use_viewer_store = defineStore("viewer", {
89
state: () => ({
@@ -16,7 +17,7 @@ export const use_viewer_store = defineStore("viewer", {
1617
}),
1718
getters: {
1819
protocol() {
19-
if (use_infra_store().is_cloud) {
20+
if (use_infra_store().app_mode == appMode.CLOUD) {
2021
return "wss"
2122
} else {
2223
return "ws"

utils/app_mode.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ function getAppMode() {
1010
if (isElectron()) {
1111
return appMode.DESKTOP
1212
}
13+
if (process.env.BROWSER === true) {
14+
return appMode.BROWSER
15+
}
16+
return appMode.CLOUD
1317
}
1418
export default { appMode, getAppMode }

0 commit comments

Comments
 (0)