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