mirror of
https://ceregatti.org/git/daniel/dayzdockerserver.git
synced 2025-05-06 14:21:18 +00:00
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.
This commit is contained in:
parent
4c3823d9bc
commit
07eb8ac7ff
5 changed files with 11 additions and 6 deletions
|
@ -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'))
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
<script>
|
||||
import { useFetch } from '@vueuse/core'
|
||||
import { config } from '@/config'
|
||||
export default {
|
||||
name: "xmlTree",
|
||||
props: {
|
||||
|
@ -85,7 +86,7 @@ export default {
|
|||
if (this.element) {
|
||||
return this.element
|
||||
} else if(this.file) {
|
||||
const { data } = await useFetch(`http://bubba:8000/mod/${this.modId}/${this.file}`)
|
||||
const { data } = await useFetch(config.baseUrl + `/mod/${this.modId}/${this.file}`)
|
||||
const parser = new DOMParser()
|
||||
const xmlDoc = parser.parseFromString(data, "text/xml")
|
||||
return xmlDoc.documentElement
|
||||
|
|
|
@ -215,8 +215,10 @@ app.get('/mod/:modId', (req, res) => {
|
|||
app.get('/mod/:modId/:file', (req, res) => {
|
||||
const modId = req.params["modId"]
|
||||
const file = req.params["file"]
|
||||
if (fs.existsSync(config.modDir + d + modId + d + file)) {
|
||||
const contents = fs.readFileSync(config.modDir + d + modId + d + file)
|
||||
res.send(contents)
|
||||
}
|
||||
})
|
||||
|
||||
// Search for a mod
|
||||
|
|
Loading…
Add table
Reference in a new issue