-
Coming Soon
+
+
+
+
+
+
LOADING DATABASE
+
+
Initializing Pokédex...
+
+
+
+
+
+
+
+
+
+
+ {{ pokemonList.length }} / {{ TOTAL_POKEMON }}
+
+
+
+
Selected
+
+ #{{ String(pokemonList[selectedIndex]?.id || 0).padStart(4, '0') }}
+
+
+
+
+
+
diff --git a/src/stores/pokemonListStore.js b/src/stores/pokemonListStore.js
new file mode 100644
index 0000000..0f788c7
--- /dev/null
+++ b/src/stores/pokemonListStore.js
@@ -0,0 +1,42 @@
+import { defineStore } from 'pinia'
+
+export const usePokemonListStore = defineStore('pokemonList', {
+ state: () => ({
+ lastSelectedPokemonId: parseInt(localStorage.getItem('lastSelectedPokemonId')) || null,
+ selectedIndex: 0,
+ onSelect: null,
+ onMoveUp: null,
+ onMoveDown: null
+ }),
+
+ actions: {
+ setLastSelectedPokemon(id) {
+ this.lastSelectedPokemonId = id
+ if (id) {
+ localStorage.setItem('lastSelectedPokemonId', id.toString())
+ } else {
+ localStorage.removeItem('lastSelectedPokemonId')
+ }
+ },
+
+ setNavigationHandlers(handlers) {
+ this.selectedIndex = handlers.selectedIndex || 0
+ this.onSelect = handlers.onSelect || null
+ this.onMoveUp = handlers.onMoveUp || null
+ this.onMoveDown = handlers.onMoveDown || null
+ },
+
+ clearNavigationHandlers() {
+ this.selectedIndex = 0
+ this.onSelect = null
+ this.onMoveUp = null
+ this.onMoveDown = null
+ }
+ },
+
+ getters: {
+ hasNavigationHandlers: (state) => {
+ return state.onSelect !== null || state.onMoveUp !== null || state.onMoveDown !== null
+ }
+ }
+})