Skip to content

Commit a729fa5

Browse files
feat(stores): app_mode wip
1 parent 73a1233 commit a729fa5

File tree

6 files changed

+22
-24
lines changed

6 files changed

+22
-24
lines changed

components/Recaptcha.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
})
2121
2222
onMounted(() => {
23-
if (process.client) {
24-
const config = useRuntimeConfig()
25-
if (config.public.NODE_ENV !== "production" || !infra_store.is_cloud) {
23+
if (import.meta.client) {
24+
if (process.env.NODE_ENV !== "production" || !infra_store.is_cloud) {
2625
infra_store.$patch({ is_captcha_validated: true })
2726
}
2827
}

nuxt.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default defineNuxtConfig({
55
SITE_BRANCH:
66
process.env.NODE_ENV === "production" ? process.env.SITE_BRANCH : "",
77
PROJECT: process.env.NODE_ENV === "production" ? process.env.PROJECT : "",
8-
NODE_ENV: process.env.NODE_ENV,
98
},
109
},
1110

stores/geode.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
import back_schemas from "@geode/opengeodeweb-back/schemas.json"
22
import Status from "@ogw_f/utils/status.js"
3+
import appMode from "@ogw_f/utils/app_mode.js"
34

45
export const use_geode_store = defineStore("geode", {
56
state: () => ({
6-
default_local_port: "5000",
7+
port: "443",
78
request_counter: 0,
89
status: Status.NOT_CONNECTED,
910
}),
1011
getters: {
1112
protocol() {
12-
if (use_infra_store().is_cloud) {
13+
if (use_infra_store().app_mode == appMode.CLOUD) {
1314
return "https"
1415
}
1516
return "http"
1617
},
17-
port() {
18-
if (use_infra_store().is_cloud) {
19-
return "443"
20-
}
21-
return this.default_local_port
22-
},
2318
base_url() {
2419
const infra_store = use_infra_store()
2520
let geode_url = `${this.protocol}://${infra_store.domain_name}:${this.port}`
26-
if (infra_store.is_cloud) {
21+
if (infra_store.app_mode == appMode.CLOUD) {
2722
if (infra_store.ID == "") {
2823
throw new Error("ID must not be empty in cloud mode")
2924
}

stores/infra.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ export const use_infra_store = defineStore("infra", {
1010
}),
1111
getters: {
1212
is_cloud() {
13-
return (
14-
!isElectron() && useRuntimeConfig().public.NODE_ENV === "production"
15-
)
13+
return !isElectron() && useRuntimeConfig().public.APP_ENV === "production"
1614
},
1715
domain_name() {
1816
if (this.is_cloud) {

stores/viewer.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Status from "@ogw_f/utils/status.js"
66

77
export const use_viewer_store = defineStore("viewer", {
88
state: () => ({
9-
default_local_port: "1234",
9+
port: "443",
1010
client: {},
1111
config: null,
1212
picking_mode: false,
@@ -22,13 +22,6 @@ export const use_viewer_store = defineStore("viewer", {
2222
return "ws"
2323
}
2424
},
25-
port() {
26-
if (use_infra_store().is_cloud) {
27-
return "443"
28-
} else {
29-
return this.default_local_port
30-
}
31-
},
3225
base_url() {
3326
const infra_store = use_infra_store()
3427
let viewer_url = `${this.protocol}://${infra_store.domain_name}:${this.port}`

utils/app_mode.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import isElectron from "is-electron"
2+
3+
const appMode = {
4+
DESKTOP: "DESKTOP",
5+
BROWSER: "BROWSER",
6+
CLOUD: "CLOUD",
7+
}
8+
9+
function getAppMode() {
10+
if (isElectron()) {
11+
return appMode.DESKTOP
12+
}
13+
}
14+
export default { appMode, getAppMode }

0 commit comments

Comments
 (0)