From 7a34c160874f7ea1c6e653babddf391aa5b871b2 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Fri, 23 Jan 2026 23:25:17 +0100 Subject: [PATCH] Champion page improvements --- frontend/components/item/Tree.vue | 51 +++-- frontend/components/item/Viewer.vue | 81 +++++++- frontend/pages/champion/[alias].vue | 306 ++++++++++++++++++++++------ 3 files changed, 362 insertions(+), 76 deletions(-) diff --git a/frontend/components/item/Tree.vue b/frontend/components/item/Tree.vue index fca4bbd..e312a8e 100644 --- a/frontend/components/item/Tree.vue +++ b/frontend/components/item/Tree.vue @@ -11,20 +11,43 @@ const emit = defineEmits<{ refresh: [] }>() -const { data: items }: ItemResponse = await useFetch( - CDRAGON_BASE + 'plugins/rcp-be-lol-game-data/global/default/v1/items.json' +const { data: items } = useFetch>( + CDRAGON_BASE + 'plugins/rcp-be-lol-game-data/global/default/v1/items.json', + { + lazy: true, // Don't block rendering + server: false // Client-side only + } ) -const itemMap = reactive(new Map()) -for (const item of items.value) { - itemMap.set(item.id, item) + +// Create item map reactively +const itemMap = reactive(new Map()) +watch( + items, + newItems => { + if (newItems) { + itemMap.clear() + for (const item of newItems) { + itemMap.set(item.id, item) + } + } + }, + { immediate: true } +) + +function getItemIconPath(itemId: number): string { + const item = itemMap.get(itemId) + return item ? CDRAGON_BASE + mapPath(item.iconPath) : '' } const start: Ref = useTemplateRef('start') const arrows: Array = [] onMounted(() => { - refreshArrows() - emit('mount', start.value!) + // Only refresh arrows and emit if start element is available + if (start.value) { + refreshArrows() + emit('mount', start.value) + } }) onBeforeUpdate(() => { @@ -35,8 +58,10 @@ onBeforeUpdate(() => { }) onUpdated(() => { - refreshArrows() - emit('mount', start.value!) + if (start.value) { + refreshArrows() + emit('mount', start.value) + } }) onUnmounted(() => { @@ -85,8 +110,10 @@ addEventListener('scroll', _ => { }) function handleSubtreeMount(end: Element) { - drawArrow(start.value!, end) - refreshArrows() + if (start.value) { + drawArrow(start.value, end) + refreshArrows() + } emit('refresh') } function handleRefresh() { @@ -107,7 +134,7 @@ function handleRefresh() { width="64" height="64" :alt="tree.data.toString()" - :src="CDRAGON_BASE + mapPath(itemMap.get(tree.data).iconPath)" + :src="getItemIconPath(tree.data)" />

{{ ((tree.count / parentCount!!) * 100).toFixed(0) }}% diff --git a/frontend/components/item/Viewer.vue b/frontend/components/item/Viewer.vue index 474c176..f66f7db 100644 --- a/frontend/components/item/Viewer.vue +++ b/frontend/components/item/Viewer.vue @@ -11,7 +11,14 @@ const props = defineProps<{ const ITEMS_API_URL = CDRAGON_BASE + 'plugins/rcp-be-lol-game-data/global/default/v1/items.json' // State -const { data: items, pending: loadingItems, error: itemsError } = await useFetch(ITEMS_API_URL) +const { + data: items, + pending: loadingItems, + error: itemsError +} = useFetch(ITEMS_API_URL, { + lazy: true, // Don't block rendering + server: false // Client-side only +}) const itemMap = ref>(new Map()) // Initialize item map @@ -107,13 +114,23 @@ const _isLoading = computed(() => loadingItems.value || props.loading) style="margin-left: 5px; margin-right: 5px" > +

{{ ((item.count / builds.tree.count) * 100).toFixed(0) }}%

@@ -129,13 +146,23 @@ const _isLoading = computed(() => loadingItems.value || props.loading) style="margin-left: 5px; margin-right: 5px" > +

{{ ((item.count / builds.tree.count) * 100).toFixed(0) }}%

@@ -153,13 +180,23 @@ const _isLoading = computed(() => loadingItems.value || props.loading) style="margin-left: 5px; margin-right: 5px" > +

{{ ((item.count / builds.tree.count) * 100).toFixed(0) }}%

@@ -181,13 +218,23 @@ const _isLoading = computed(() => loadingItems.value || props.loading) style="margin-left: 5px; margin-right: 5px" > +

{{ ((item.count / builds.tree.count) * 100).toFixed(0) }}%

@@ -205,13 +252,23 @@ const _isLoading = computed(() => loadingItems.value || props.loading) style="margin-left: 5px; margin-right: 5px" > +

{{ ((item.count / builds.tree.count) * 100).toFixed(0) }}%

@@ -225,13 +282,23 @@ const _isLoading = computed(() => loadingItems.value || props.loading) style="margin-left: 5px; margin-right: 5px" > +

{{ ((item.count / builds.tree.count) * 100).toFixed(0) }}%

diff --git a/frontend/pages/champion/[alias].vue b/frontend/pages/champion/[alias].vue index 2702b81..0860e2b 100644 --- a/frontend/pages/champion/[alias].vue +++ b/frontend/pages/champion/[alias].vue @@ -1,82 +1,197 @@