feat: baselayoutStore

This commit is contained in:
2026-06-18 10:37:13 +08:00
parent 3bc3cce62a
commit c1e292ea18
4 changed files with 98 additions and 4 deletions

View File

@@ -38,6 +38,8 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { useBaseLayoutStore } from '@/stores'
import { storeToRefs } from 'pinia'
/** 游戏数据接口 */
interface GameInfo {
@@ -95,15 +97,18 @@ const games: GameInfo[] = [
}
]
/** 当前选中的游戏 ID */
const activeGameId = ref<string>('basketball')
const baseLayoutStore = useBaseLayoutStore()
const { activeGameId } = storeToRefs(baseLayoutStore)
/** 当前选中的游戏对象 */
const activeGame = computed(() => games.find((g) => g.id === activeGameId.value) ?? null)
/** 选择游戏 */
function selectGame(id: string) {
activeGameId.value = id
const game = games.find((g) => g.id === id)
if (game) {
baseLayoutStore.setActiveGame(game.id, game.icon, game.name)
}
}
</script>