mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
Use RiotGames API for static files.
This commit is contained in:
parent
60fc3bd74e
commit
ae52ef7164
3 changed files with 34 additions and 22 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
<div class="first col w-1/3 lg:w-1/4">
|
<div class="first col w-1/3 lg:w-1/4">
|
||||||
<div class="icon-and-sums flex flex-col sm:flex-row">
|
<div class="icon-and-sums flex flex-col sm:flex-row">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<img :src="`https://cdn.valentinkaelin.ch/riot/champions/${data.champ}.png`" class="champion-icon mb-2px sm:mb-0 sm:mr-2px" alt="example design">
|
<img :src="`https://ddragon.leagueoflegends.com/cdn/${$patch}/img/champion/${data.champ}.png`" class="champion-icon mb-2px sm:mb-0 sm:mr-2px" alt="example design">
|
||||||
<span class="level absolute bottom-0 left-0 text-white font-bold">{{ data.level }}</span>
|
<span class="level absolute bottom-0 left-0 text-white font-bold">{{ data.level }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="summonerSpells flex flex-row sm:flex-col">
|
<div class="summonerSpells flex flex-row sm:flex-col">
|
||||||
|
|
@ -81,7 +81,6 @@ export default {
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.match {
|
.match {
|
||||||
/* padding: 10px 0; */
|
|
||||||
border-bottom: 1px solid #dae1e7;
|
border-bottom: 1px solid #dae1e7;
|
||||||
margin: 16px 0;
|
margin: 16px 0;
|
||||||
}
|
}
|
||||||
|
|
@ -100,16 +99,11 @@ export default {
|
||||||
border-left: 10px solid #F56565;
|
border-left: 10px solid #F56565;
|
||||||
}
|
}
|
||||||
|
|
||||||
.match .col {
|
|
||||||
/* flex: 1 0 0; */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* First col */
|
/* First col */
|
||||||
.match .first {
|
.match .first {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
/* flex: 1 0 0; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.champion-icon {
|
.champion-icon {
|
||||||
|
|
@ -130,13 +124,11 @@ export default {
|
||||||
|
|
||||||
/* Second col */
|
/* Second col */
|
||||||
.match .second {
|
.match .second {
|
||||||
/* flex: 1 0 0; */
|
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Third col */
|
/* Third col */
|
||||||
.match .third {
|
.match .third {
|
||||||
/* flex: 1 0 0; */
|
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,7 +140,6 @@ export default {
|
||||||
|
|
||||||
/* Fourth col */
|
/* Fourth col */
|
||||||
.match .fourth {
|
.match .fourth {
|
||||||
/* flex: 1 0 0; */
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@ import Icon from 'vue-awesome/components/Icon'
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
Vue.use(VueAxios, axios)
|
Vue.use(VueAxios, axios)
|
||||||
Vue.component('v-icon', Icon)
|
Vue.component('v-icon', Icon)
|
||||||
Vue.component('dot-loader', DotLoader);
|
Vue.component('dot-loader', DotLoader)
|
||||||
|
Vue.prototype.$patch = '9.9.1'
|
||||||
|
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
<template v-if="summonerFound && !loading">
|
<template v-if="summonerFound && !loading">
|
||||||
<div class="container mx-auto pb-16">
|
<div class="container mx-auto pb-16">
|
||||||
<div class="player bg-blue-100">
|
<div class="player bg-blue-100">
|
||||||
<div class="player__pp" :style="{background: `url(https://cdn.valentinkaelin.ch/riot/profileicon/${localInfos.profileIconId}.png) center/cover`}"></div>
|
<div class="player__pp" :style="{background: `url(https://ddragon.leagueoflegends.com/cdn/${this.$patch}/img/profileicon/${localInfos.profileIconId}.png) center/cover`}"></div>
|
||||||
<h1 class="player__name">{{ localInfos.name }}</h1>
|
<h1 class="player__name">{{ localInfos.name }}</h1>
|
||||||
<h3 class="player__level">{{ localInfos.level }}</h3>
|
<h3 class="player__level">{{ localInfos.level }}</h3>
|
||||||
<h3 class="player__rank">{{ localInfos.rank }}</h3>
|
<h3 class="player__rank">{{ localInfos.rank }}</h3>
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import itemsJSON from '@/data/item.json'
|
// import itemsJSON from '@/data/item.json'
|
||||||
import summonersJSON from '@/data/summoner.json'
|
import summonersJSON from '@/data/summoner.json'
|
||||||
import Match from '@/components/Match.vue';
|
import Match from '@/components/Match.vue';
|
||||||
import SearchForm from '@/components/SearchForm.vue';
|
import SearchForm from '@/components/SearchForm.vue';
|
||||||
|
|
@ -71,6 +71,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
championsInfos: [],
|
||||||
localInfos: {},
|
localInfos: {},
|
||||||
summonerFound: true,
|
summonerFound: true,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
@ -99,14 +100,15 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
apiCall() {
|
apiCall() {
|
||||||
|
console.log(this.$patch)
|
||||||
const summoner = this.summoner;
|
const summoner = this.summoner;
|
||||||
const region = this.regionsList[this.region];
|
const region = this.regionsList[this.region];
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.axios({
|
this.axios({
|
||||||
method: "POST",
|
method: 'POST',
|
||||||
url: process.env.NODE_ENV === 'development' ? 'http://localhost:5000/api' : 'https://leaguestats.valentinkaelin.ch/api',
|
url: process.env.NODE_ENV === 'development' ? 'http://localhost:5000/api' : 'https://leaguestats.valentinkaelin.ch/api',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
summoner,
|
summoner,
|
||||||
|
|
@ -141,6 +143,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createObject(JSONData) {
|
createObject(JSONData) {
|
||||||
|
console.time('frontend')
|
||||||
console.log('--- ALL INFOS ---')
|
console.log('--- ALL INFOS ---')
|
||||||
console.log(JSONData);
|
console.log(JSONData);
|
||||||
|
|
||||||
|
|
@ -162,7 +165,10 @@ export default {
|
||||||
let mode = gameModes[currentMatch.queueId];
|
let mode = gameModes[currentMatch.queueId];
|
||||||
if (!mode)
|
if (!mode)
|
||||||
mode = 'Undefined gamemode';
|
mode = 'Undefined gamemode';
|
||||||
const champion = championsId[currentMatch.participants[participantId - 1].championId];
|
//console.log(Object.entries(this.championsInfos))
|
||||||
|
//console.log(this.championsInfos)
|
||||||
|
const champion = Object.entries(this.championsInfos).find(([, champion]) => Number(champion.key) === currentMatch.participants[participantId - 1].championId)[0]
|
||||||
|
//const champion = championsId[currentMatch.participants[participantId - 1].championId];
|
||||||
const role = currentMatch.participants[participantId - 1].timeline.lane;
|
const role = currentMatch.participants[participantId - 1].timeline.lane;
|
||||||
const timeAgo = timeDifference(currentMatch.gameCreation);
|
const timeAgo = timeDifference(currentMatch.gameCreation);
|
||||||
const time = secToTime(currentMatch.gameDuration);
|
const time = secToTime(currentMatch.gameDuration);
|
||||||
|
|
@ -220,17 +226,28 @@ export default {
|
||||||
console.log(this.localInfos);
|
console.log(this.localInfos);
|
||||||
|
|
||||||
localStorage[`${this.summoner}:${this.region}`] = JSON.stringify(this.localInfos);
|
localStorage[`${this.summoner}:${this.region}`] = JSON.stringify(this.localInfos);
|
||||||
|
console.timeEnd('frontend')
|
||||||
|
},
|
||||||
|
getData() {
|
||||||
|
console.log('API CALL FOR CHAMPIONS')
|
||||||
|
this.axios({
|
||||||
|
method: 'GET',
|
||||||
|
url: `http://ddragon.leagueoflegends.com/cdn/${this.$patch}/data/en_US/champion.json`
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
return response.data
|
||||||
|
})
|
||||||
|
.then(jsonData => {
|
||||||
|
console.log('here')
|
||||||
|
this.championsInfos = jsonData.data
|
||||||
|
})
|
||||||
},
|
},
|
||||||
getItemLink(id) {
|
getItemLink(id) {
|
||||||
if(id === 0) {
|
return `url('https://ddragon.leagueoflegends.com/cdn/${this.$patch}/img/item/${id === 0 ? 3637 : id}.png') no-repeat center center / contain`;
|
||||||
return "url('https://cdn.valentinkaelin.ch/riot/items/0.png') 0% 0% / cover";
|
|
||||||
}
|
|
||||||
const itemImage = itemsJSON.data[id].image;
|
|
||||||
return `url('https://cdn.valentinkaelin.ch/riot/${itemImage.sprite}') -${itemImage.x}px -${itemImage.y}px`;
|
|
||||||
},
|
},
|
||||||
getSummonerLink(id) {
|
getSummonerLink(id) {
|
||||||
const spellName = Object.entries(summonersJSON.data).find(([, spell]) => Number(spell.key) === id)[0]
|
const spellName = Object.entries(summonersJSON.data).find(([, spell]) => Number(spell.key) === id)[0]
|
||||||
return `https://cdn.valentinkaelin.ch/riot/spells/${spellName}.png`;
|
return `https://ddragon.leagueoflegends.com/cdn/${this.$patch}/img/spell/${spellName}.png`;
|
||||||
},
|
},
|
||||||
redirect(summoner, region) {
|
redirect(summoner, region) {
|
||||||
// this.$router.push("/summoner/euw/" + this.search)
|
// this.$router.push("/summoner/euw/" + this.search)
|
||||||
|
|
@ -241,6 +258,9 @@ export default {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created: function() {
|
||||||
|
this.getData()
|
||||||
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
this.checkLocalStorage()
|
this.checkLocalStorage()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue