-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to change the server
- Loading branch information
1 parent
8b81c53
commit e4c3f9f
Showing
14 changed files
with
130 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div> | ||
<p class="font-bold text-xl text-center">Server</p> | ||
<div class=" w-full mt-4"> | ||
<input type="text" autocomplete="server" v-model="newServerUrl" class="input input-bordered w-full join-item" /> | ||
</div> | ||
|
||
<button class="btn w-full btn-warning mt-8" @click="changeServer(newServerUrl)">Change Server</button> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import {useServer} from "~/composables/useServer"; | ||
const server = useServer; | ||
const newServerUrl = ref(server.getUrl()) | ||
const emit = defineEmits(['serverChanged']) | ||
const changeServer = (newUrl) => { | ||
server.setUrl(newUrl); | ||
emit('serverChanged'); | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {useStorage} from "@vueuse/core"; | ||
|
||
export const useServer = new class FinWaveServer { | ||
public getUrl() : string { | ||
const configValue = this.getConfigUrl(); | ||
|
||
if (this.allowCustomUrl()) | ||
return useStorage("server_url", configValue).value; | ||
|
||
return configValue; | ||
} | ||
|
||
public getWebSocketUrl() : string { | ||
return this.getUrl() | ||
.replace("https://", "wss://") | ||
.replace("http://", "ws://"); | ||
} | ||
|
||
public allowCustomUrl() : boolean { | ||
return useRuntimeConfig().public.allowCustomApiURL; | ||
} | ||
|
||
public getConfigUrl() : string { | ||
return useRuntimeConfig().public.apiURL; | ||
} | ||
|
||
public setUrl(url : string) : void { | ||
if (this.allowCustomUrl()) | ||
useStorage("server_url", "").value = url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {navigateTo} from "#app"; | ||
|
||
export default defineNuxtRouteMiddleware((to, from) => { | ||
const {$serverConfigs} = useNuxtApp(); | ||
|
||
const serverAvailable = $serverConfigs ? $serverConfigs.serverAvailable : false; | ||
|
||
if (!serverAvailable) | ||
return navigateTo("/serverNotAvailable"); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {navigateTo} from "#app"; | ||
|
||
export default defineNuxtRouteMiddleware((to, from) => { | ||
const {$serverConfigs} = useNuxtApp(); | ||
|
||
const serverAvailable = $serverConfigs ? $serverConfigs.serverAvailable : false; | ||
|
||
if (serverAvailable) | ||
return navigateTo("/"); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import {useApiLoader} from "#imports"; | ||
import {ca} from "date-fns/locale"; | ||
|
||
export default defineNuxtPlugin(async nuxtApp => { | ||
await useApiLoader.fetch(); | ||
try { | ||
await useApiLoader.fetch(); | ||
|
||
useApiLoader.connectWebsocket(); | ||
useApiLoader.connectWebsocket(); | ||
}catch (e) { | ||
console.log(e) | ||
} | ||
|
||
return useApiLoader.getProvider(); | ||
}) |