get gameinfo
This commit is contained in:
parent
ce46b6f027
commit
82c91c05dc
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<pre class="json">{{ userJson }}</pre>
|
<pre class="json">{{ userJson }}</pre>
|
||||||
|
<pre v-if="gameinfoJson" class="json">{{ gameinfoJson }}</pre>
|
||||||
<pre class="json">{{ engineJson }}</pre>
|
<pre class="json">{{ engineJson }}</pre>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -11,12 +12,15 @@ export default {
|
|||||||
await this.$engine.start()
|
await this.$engine.start()
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
engineJson() {
|
|
||||||
return JSON.stringify(this.$store.state.engine.json, null, 2)
|
|
||||||
},
|
|
||||||
userJson() {
|
userJson() {
|
||||||
return JSON.stringify(this.$store.state.engine.user, null, 2)
|
return JSON.stringify(this.$store.state.engine.user, null, 2)
|
||||||
},
|
},
|
||||||
|
gameinfoJson() {
|
||||||
|
return JSON.stringify(this.$store.state.engine.gameinfo, null, 2)
|
||||||
|
},
|
||||||
|
engineJson() {
|
||||||
|
return JSON.stringify(this.$store.state.engine.json, null, 2)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -24,8 +24,17 @@ export default (context, inject) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const response = await $axios.get(url)
|
const response = await $axios.get(url)
|
||||||
const json = response.data
|
store.commit('engine/setJson', response.data)
|
||||||
store.commit('engine/setJson', json)
|
|
||||||
|
const role = store.state.engine.user?.role
|
||||||
|
if (role === "gamemaster" || role === "admin") {
|
||||||
|
const url = buildUrl($config.serverBaseUrl, {
|
||||||
|
path: '/api/gameinfo',
|
||||||
|
queryParams: { g: store.state.engine.user?.game },
|
||||||
|
})
|
||||||
|
const response = await $axios.get(url)
|
||||||
|
store.commit('engine/setGameinfo', response.data)
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const { status, statusText } = e.response
|
const { status, statusText } = e.response
|
||||||
if (status != 200) {
|
if (status != 200) {
|
||||||
|
@ -2,6 +2,7 @@ export const state = () => ({
|
|||||||
json: {},
|
json: {},
|
||||||
version: -1,
|
version: -1,
|
||||||
user: undefined,
|
user: undefined,
|
||||||
|
gameinfo: undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
@ -14,5 +15,8 @@ export const mutations = {
|
|||||||
},
|
},
|
||||||
setUser(state, user) {
|
setUser(state, user) {
|
||||||
state.user = user
|
state.user = user
|
||||||
|
},
|
||||||
|
setGameinfo(state, gameinfo) {
|
||||||
|
state.gameinfo = gameinfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user