More typescript

This commit is contained in:
2024-11-28 18:36:57 +01:00
parent faa17e87c9
commit afb9f106f9
4 changed files with 36 additions and 39 deletions

View File

@@ -1,13 +1,5 @@
<script setup lang="ts">
type ChampionResponse = {
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 {data: championsData} : ChampionsResponse = 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) => {
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) {
if(newValue != -1) {
filteredChampions.value = champions.filter((champion) => {
const lanes : Array<any> = lanesMap.get(champion.alias.toLowerCase())
if(lanes == undefined) return false;

View File

@@ -1,22 +1,10 @@
<script setup>
const props = defineProps({
championId: {
type: String,
required: true
},
winrate: {
type: Number,
required: true
},
pickrate: {
type: Number,
required: true
},
gameCount: {
type: Number,
required: true
}
})
<script setup lang="ts">
const props = defineProps<{
championId: string,
winrate: number,
pickrate: number,
gameCount: number
}>()
const championId = Number(props.championId)
@@ -24,10 +12,9 @@ const winrate = (props.winrate * 100).toFixed(2)
const pickrate = (props.pickrate * 100).toFixed(2)
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 championDescription = championData.value.title
</script>
<template>