Skip to content

Commit 72a3f32

Browse files
wip refactor
1 parent 77872ac commit 72a3f32

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

components/Launcher.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
const infra_store = use_infra_store()
2525
const site_key = useRuntimeConfig().public.RECAPTCHA_SITE_KEY
2626
27-
if (import.meta.client) {
28-
if (infra_store.is_captcha_validated) {
29-
infra_store.create_backend()
30-
}
31-
}
3227
watch(
3328
() => infra_store.is_captcha_validated,
3429
(value, oldValue) => {

stores/geode.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,29 @@ import Status from "@ogw_f/utils/status.js"
33

44
export const use_geode_store = defineStore("geode", {
55
state: () => ({
6-
port: "99",
6+
port: "443",
77
request_counter: 0,
88
status: Status.NOT_CONNECTED,
99
}),
1010
getters: {
1111
protocol() {
12-
if (use_infra_store().app_mode == appMode.CLOUD) {
12+
if (use_infra_store().app_mode == appMode.appMode.CLOUD) {
1313
return "https"
1414
}
1515
return "http"
1616
},
1717
base_url() {
1818
const infra_store = use_infra_store()
1919
let geode_url = `${this.protocol}://${infra_store.domain_name}:${this.port}`
20-
if (infra_store.app_mode == appMode.CLOUD) {
20+
if (infra_store.app_mode == appMode.appMode.CLOUD) {
2121
if (infra_store.ID == "") {
2222
throw new Error("ID must not be empty in cloud mode")
2323
}
2424
geode_url += `/${infra_store.ID}/geode`
2525
}
26+
if (infra_store.app_mode == appMode.appMode.BROWSER) {
27+
geode_url += `/geode`
28+
}
2629
return geode_url
2730
},
2831
is_busy() {

stores/infra.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ export const use_infra_store = defineStore("infra", {
55
state: () => ({
66
app_mode: getAppMode(),
77
ID: useStorage("ID", ""),
8-
is_captcha_validated: true,
8+
is_captcha_validated: this.app_mode == appMode.appMode.CLOUD ? false : true,
99
status: Status.NOT_CREATED,
1010
}),
1111
getters: {
1212
domain_name() {
13-
if (this.app_mode == appMode.CLOUD) {
13+
if (this.app_mode == appMode.appMode.CLOUD) {
1414
return useRuntimeConfig().public.API_URL
15-
} else {
16-
return "localhost"
1715
}
16+
return "localhost"
1817
},
1918
lambda_url() {
2019
const geode_store = use_geode_store()
@@ -44,6 +43,7 @@ export const use_infra_store = defineStore("infra", {
4443
async create_backend() {
4544
console.log("create_backend")
4645
if (this.status === Status.CREATED) return
46+
console.log("1")
4747
return navigator.locks.request("infra.create_backend", async (lock) => {
4848
this.status = Status.CREATING
4949
if (this.status === Status.CREATED) return
@@ -52,14 +52,15 @@ export const use_infra_store = defineStore("infra", {
5252
const geode_store = use_geode_store()
5353
const viewer_store = use_viewer_store()
5454
const feedback_store = use_feedback_store()
55-
if (this.app_mode == appMode.CLOUD) {
55+
if (this.app_mode == appMode.appMode.DESKTOP) {
5656
const back_port = await window.electronAPI.run_back(geode_store.port)
5757
geode_store.$patch({ default_local_port: back_port })
5858
const viewer_port = await window.electronAPI.run_viewer(
5959
viewer_store.port,
6060
)
6161
viewer_store.$patch({ default_local_port: viewer_port })
62-
} else {
62+
}
63+
if (this.app_mode == appMode.appMode.CLOUD) {
6364
const { data, error } = await useFetch(this.lambda_url, {
6465
method: "POST",
6566
})

stores/viewer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,25 @@ export const use_viewer_store = defineStore("viewer", {
1616
}),
1717
getters: {
1818
protocol() {
19-
if (use_infra_store().app_mode == appMode.CLOUD) {
19+
if (use_infra_store().app_mode == appMode.appMode.CLOUD) {
2020
return "wss"
2121
} else {
2222
return "ws"
2323
}
2424
},
2525
base_url() {
2626
const infra_store = use_infra_store()
27+
2728
let viewer_url = `${this.protocol}://${infra_store.domain_name}:${this.port}`
28-
if (infra_store.is_cloud) {
29+
if (infra_store.app_mode == appMode.appMode.CLOUD) {
2930
if (infra_store.ID == "") {
3031
throw new Error("ID must not be empty in cloud mode")
3132
}
3233
viewer_url += `/${infra_store.ID}/viewer`
3334
}
35+
if (infra_store.app_mode == appMode.appMode.BROWSER) {
36+
viewer_url += `/viewer`
37+
}
3438
viewer_url += "/ws"
3539
return viewer_url
3640
},

utils/app_mode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const appMode = {
77
}
88

99
export function getAppMode() {
10+
console.log("getAppMode process.env", process.env)
1011
if (isElectron()) {
1112
return appMode.DESKTOP
1213
}

0 commit comments

Comments
 (0)