feat: baselayoutStore
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user