<template>
  <button @click="$router.back()">返回</button>
  游戏列表选择
  <div v-for="item in games" :key="item.id" @click="openGame(item.name)">
    {{ item.text }}
  </div>
</template>

<script setup>
import { useStore } from 'vuex';
import { computed } from 'vue';

const store = useStore();
const games = computed(() => store.getters.selectedGames);

/**
 * 根据game.name 跳转到对应的游戏界面
 * @param {string} gameName 游戏name与服务器路径对应
 */
function openGame(gameName) {
  window.location.href = `https://www.tall.wiki/kangfu/game/${gameName}/win`;
}
</script>

<style scoped></style>
