More typescript
This commit is contained in:
@@ -1,13 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
type ChampionResponse = {
|
const {data: championsData} : ChampionsResponse = await useFetch(CDRAGON_BASE + "plugins/rcp-be-lol-game-data/global/default/v1/champion-summary.json")
|
||||||
data: Ref<Array<Champion>>
|
|
||||||
}
|
|
||||||
type Champion = {
|
|
||||||
name: string
|
|
||||||
alias: string
|
|
||||||
squarePortraitPath: string
|
|
||||||
}
|
|
||||||
const {data: championsData} : ChampionResponse = await useFetch(CDRAGON_BASE + "plugins/rcp-be-lol-game-data/global/default/v1/champion-summary.json")
|
|
||||||
const champions = championsData.value.slice(1).sort((a, b) => {
|
const champions = championsData.value.slice(1).sort((a, b) => {
|
||||||
if(a.name < b.name) return -1;
|
if(a.name < b.name) return -1;
|
||||||
if(a.name > b.name) return 1;
|
if(a.name > b.name) return 1;
|
||||||
@@ -46,9 +38,6 @@ function filterToLane(filter: number) {
|
|||||||
|
|
||||||
function onLaneFilterChange(newValue: number) {
|
function onLaneFilterChange(newValue: number) {
|
||||||
if(newValue != -1) {
|
if(newValue != -1) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
filteredChampions.value = champions.filter((champion) => {
|
filteredChampions.value = champions.filter((champion) => {
|
||||||
const lanes : Array<any> = lanesMap.get(champion.alias.toLowerCase())
|
const lanes : Array<any> = lanesMap.get(champion.alias.toLowerCase())
|
||||||
if(lanes == undefined) return false;
|
if(lanes == undefined) return false;
|
||||||
|
|||||||
@@ -1,22 +1,10 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
const props = defineProps({
|
const props = defineProps<{
|
||||||
championId: {
|
championId: string,
|
||||||
type: String,
|
winrate: number,
|
||||||
required: true
|
pickrate: number,
|
||||||
},
|
gameCount: number
|
||||||
winrate: {
|
}>()
|
||||||
type: Number,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
pickrate: {
|
|
||||||
type: Number,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
gameCount: {
|
|
||||||
type: Number,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const championId = Number(props.championId)
|
const championId = Number(props.championId)
|
||||||
|
|
||||||
@@ -24,10 +12,9 @@ const winrate = (props.winrate * 100).toFixed(2)
|
|||||||
const pickrate = (props.pickrate * 100).toFixed(2)
|
const pickrate = (props.pickrate * 100).toFixed(2)
|
||||||
const gameCount = props.gameCount
|
const gameCount = props.gameCount
|
||||||
|
|
||||||
const { data: championData } = await useFetch(CDRAGON_BASE + "plugins/rcp-be-lol-game-data/global/default/v1/champions/" + championId + ".json")
|
const { data: championData } : ChampionResponse = await useFetch(CDRAGON_BASE + "plugins/rcp-be-lol-game-data/global/default/v1/champions/" + championId + ".json")
|
||||||
const championName = championData.value.name
|
const championName = championData.value.name
|
||||||
const championDescription = championData.value.title
|
const championDescription = championData.value.title
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
27
frontend/types/cdragon.ts
Normal file
27
frontend/types/cdragon.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
declare global {
|
||||||
|
type ChampionsResponse = {
|
||||||
|
data: Ref<Array<Champion>>
|
||||||
|
}
|
||||||
|
type ChampionResponse = {
|
||||||
|
data: Ref<ChampionFull>
|
||||||
|
}
|
||||||
|
type Champion = {
|
||||||
|
name: string
|
||||||
|
alias: string
|
||||||
|
squarePortraitPath: string
|
||||||
|
}
|
||||||
|
type ChampionFull = {
|
||||||
|
name: string
|
||||||
|
alias: string
|
||||||
|
squarePortraitPath: string
|
||||||
|
title: string
|
||||||
|
}
|
||||||
|
type ItemResponse = {
|
||||||
|
data: Ref<Array<Item>>
|
||||||
|
}
|
||||||
|
type Item = {
|
||||||
|
id: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {}
|
||||||
@@ -11,12 +11,6 @@ declare global {
|
|||||||
boots: Array<{count: number, data: number}>
|
boots: Array<{count: number, data: number}>
|
||||||
lateGame: Array<{count: number, data: number}>
|
lateGame: Array<{count: number, data: number}>
|
||||||
}
|
}
|
||||||
type Item = {
|
|
||||||
id: number
|
|
||||||
}
|
|
||||||
type ItemResponse = {
|
|
||||||
data: Ref<Array<Item>>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
Reference in New Issue
Block a user