mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat: add reload button on live game tab
This commit is contained in:
parent
754a8b497c
commit
d740ed7309
4 changed files with 22 additions and 10 deletions
|
|
@ -19,6 +19,9 @@ export const liveGame = {
|
||||||
gamemode() {
|
gamemode() {
|
||||||
return gameModes[this.current.gameQueueConfigId]
|
return gameModes[this.current.gameQueueConfigId]
|
||||||
},
|
},
|
||||||
|
gameStartTime() {
|
||||||
|
return (new Date() - new Date(this.current.gameStartTime)) / 1000
|
||||||
|
},
|
||||||
teamColor() {
|
teamColor() {
|
||||||
return this.current.participants.find(p => p.summonerId === this.account.id).teamId
|
return this.current.participants.find(p => p.summonerId === this.account.id).teamId
|
||||||
},
|
},
|
||||||
|
|
@ -29,7 +32,7 @@ export const liveGame = {
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.gameLength = this.current ? this.current.gameLength : 0
|
this.gameLength = this.current ? this.gameStartTime : 0
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
this.gameLength++
|
this.gameLength++
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,9 @@ export const mutations = {
|
||||||
state.live.match = live
|
state.live.match = live
|
||||||
state.live.liveLoaded = true
|
state.live.liveLoaded = true
|
||||||
},
|
},
|
||||||
|
LIVE_NOT_FOUND(state) {
|
||||||
|
state.live.liveLoaded = false
|
||||||
|
},
|
||||||
MATCHES_LOADING(state) {
|
MATCHES_LOADING(state) {
|
||||||
state.overview.matchesLoading = true
|
state.overview.matchesLoading = true
|
||||||
},
|
},
|
||||||
|
|
@ -124,11 +127,14 @@ export const actions = {
|
||||||
commit('CHAMPIONS_FOUND', { champions: resp.data })
|
commit('CHAMPIONS_FOUND', { champions: resp.data })
|
||||||
},
|
},
|
||||||
async liveMatchRequest({ commit, rootState }) {
|
async liveMatchRequest({ commit, rootState }) {
|
||||||
|
commit('LIVE_NOT_FOUND')
|
||||||
const resp = await axios(({ url: 'summoner-live', data: { account: state.basic.account, region: rootState.currentRegion }, method: 'POST' })).catch(() => { })
|
const resp = await axios(({ url: 'summoner-live', data: { account: state.basic.account, region: rootState.currentRegion }, method: 'POST' })).catch(() => { })
|
||||||
console.log('---LIVE---')
|
console.log('---LIVE---')
|
||||||
console.log(resp.data)
|
console.log(resp.data)
|
||||||
|
|
||||||
commit('LIVE_FOUND', { live: resp.data })
|
if (resp.data) {
|
||||||
|
commit('LIVE_FOUND', { live: resp.data })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async moreMatches({ commit }) {
|
async moreMatches({ commit }) {
|
||||||
commit('MATCHES_LOADING')
|
commit('MATCHES_LOADING')
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div key="live-game">
|
<div key="live-game">
|
||||||
<div v-if="playing || summonerLoading">
|
<div v-if="playing || summonerLoading">
|
||||||
<div v-if="playing" class="flex items-center justify-end text-blue-200 text-base">
|
<div v-if="liveLoaded" class="flex items-center justify-end text-blue-200 text-base">
|
||||||
<div>{{ gamemode.type }} {{ gamemode.name }}</div>
|
<div>{{ gamemode.type }} {{ gamemode.name }}</div>
|
||||||
<div class="mx-2">-</div>
|
<div class="mx-2">-</div>
|
||||||
<div>{{ gameLength|secToTime(true) }}</div>
|
<div>{{ gameLength|secToTime(true) }}</div>
|
||||||
|
<button
|
||||||
|
@click="liveMatchRequest"
|
||||||
|
class="ml-4 bg-blue-800 px-3 py-1 text-blue-100 rounded-md shadow-md hover:bg-blue-760"
|
||||||
|
>Reload</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="flex items-center justify-end text-blue-200 text-base">
|
<div v-else class="h-8"></div>
|
||||||
<div>Loading</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<LiveTeam :team="allyTeam" :ally="true" />
|
<LiveTeam :team="allyTeam" :ally="true" />
|
||||||
<LiveTeam :team="enemyTeam" :ally="false" class="mt-4" />
|
<LiveTeam :team="enemyTeam" :ally="false" class="mt-4" />
|
||||||
|
|
@ -55,7 +57,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
summonerFound() {
|
summonerFound() {
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
this.gameLength = this.current ? this.current.gameLength : 0
|
this.gameLength = this.current ? this.gameStartTime : 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -64,9 +66,10 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
fetchData() {
|
async fetchData() {
|
||||||
if (this.playing && !this.liveLoaded && this.summonerFound) {
|
if (this.playing && !this.liveLoaded && this.summonerFound) {
|
||||||
this.liveMatchRequest()
|
await this.liveMatchRequest()
|
||||||
|
this.gameLength = this.gameStartTime
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...mapActions('summoner', ['liveMatchRequest']),
|
...mapActions('summoner', ['liveMatchRequest']),
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ class SummonerController {
|
||||||
let currentGame = await Jax.Spectator.summonerID(account.id, region)
|
let currentGame = await Jax.Spectator.summonerID(account.id, region)
|
||||||
|
|
||||||
if (!currentGame) {
|
if (!currentGame) {
|
||||||
response.json(null)
|
return response.json(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
currentGame = await LiveMatchTransformer.transform(currentGame, { region })
|
currentGame = await LiveMatchTransformer.transform(currentGame, { region })
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue