From 07eb8ac7ffa27274dc36c3d875699da8ab682f08 Mon Sep 17 00:00:00 2001 From: Daniel Ceregatti Date: Mon, 11 Sep 2023 17:26:16 -0700 Subject: [PATCH] Add a config object to hold values like API hosts, instead of hard coding it to my local machine's name. Make sure the file exists before trying to read it. --- web/docroot/src/components/Header.vue | 3 ++- web/docroot/src/components/Modinfo.vue | 3 ++- web/docroot/src/components/SearchResults.vue | 2 +- web/docroot/src/components/XmlTree.vue | 3 ++- web/web.js | 6 ++++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/web/docroot/src/components/Header.vue b/web/docroot/src/components/Header.vue index 933fdbb..86ac290 100644 --- a/web/docroot/src/components/Header.vue +++ b/web/docroot/src/components/Header.vue @@ -5,7 +5,8 @@ import Servers from '@/components/Servers.vue' import { useFetch } from '@vueuse/core' import { useAppStore } from '@/stores/app.js' const store = useAppStore() -const { error, data } = await useFetch('http://bubba:8000/status').get().json() +import { config } from '@/config' +const { error, data } = await useFetch(config.baseUrl + '/status').get().json() const set = (w, e) => { store.section = w const active = Array.from(document.getElementsByClassName('active')) diff --git a/web/docroot/src/components/Modinfo.vue b/web/docroot/src/components/Modinfo.vue index baeb7c2..d0ef060 100644 --- a/web/docroot/src/components/Modinfo.vue +++ b/web/docroot/src/components/Modinfo.vue @@ -3,7 +3,8 @@ import { useFetch } from "@vueuse/core" import xmlTree from '@/components/XmlTree.vue' import { useAppStore } from '@/stores/app.js' const store = useAppStore() -const { data, error } = useFetch(() => `http://bubba:8000/mod/${store.modId}`, { +import { config } from '@/config' +const { data, error } = useFetch(() => config.baseUrl + `/mod/${store.modId}`, { immediate: false, refetch: true }).get().json() diff --git a/web/docroot/src/components/SearchResults.vue b/web/docroot/src/components/SearchResults.vue index 3e0695b..ced79ce 100644 --- a/web/docroot/src/components/SearchResults.vue +++ b/web/docroot/src/components/SearchResults.vue @@ -4,7 +4,7 @@ import { BKMG } from '@/util' import { useFetch} from '@vueuse/core' import { useAppStore } from '@/stores/app.js' const store = useAppStore() -const { data: searchResults, error, isFetching } = useFetch(() => `http://bubba:8000/search/${store.searchText}`, { +const { data: searchResults, error, isFetching } = useFetch(() => config.baseUrl + `/search/${store.searchText}`, { immediate: false, refetch: true, afterFetch(response) { diff --git a/web/docroot/src/components/XmlTree.vue b/web/docroot/src/components/XmlTree.vue index 9e5d115..aaa4d91 100644 --- a/web/docroot/src/components/XmlTree.vue +++ b/web/docroot/src/components/XmlTree.vue @@ -46,6 +46,7 @@