feat: complete server-backed six-lesson app and trial tooling
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+48
-4
@@ -1,14 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import AppHeader from '@/components/common/AppHeader.vue'
|
||||
import GameCard from '@/components/common/GameCard.vue'
|
||||
import { GAMES } from '@/data/mockData'
|
||||
import PrimaryButton from '@/components/common/PrimaryButton.vue'
|
||||
import { useGamesStore } from '@/stores/games'
|
||||
import type { GameCatalogItem } from '@/types/catalog.types'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
|
||||
const router = useRouter()
|
||||
const gamesStore = useGamesStore()
|
||||
const toast = useToast()
|
||||
|
||||
function startGame(game: (typeof GAMES)[0]) {
|
||||
onMounted(() => {
|
||||
void gamesStore.loadCatalog()
|
||||
})
|
||||
|
||||
function retryLoad() {
|
||||
void gamesStore.loadCatalog({ force: true })
|
||||
}
|
||||
|
||||
function startGame(game: GameCatalogItem) {
|
||||
game.route ? router.push(game.route) : toast.show('به زودی!', 'info')
|
||||
}
|
||||
</script>
|
||||
@@ -17,9 +29,28 @@ function startGame(game: (typeof GAMES)[0]) {
|
||||
<div class="page-content page-content--no-nav">
|
||||
<AppHeader title="بازیها" show-back @back="router.back()" />
|
||||
|
||||
<div class="games-list">
|
||||
<div v-if="gamesStore.catalogLoadStatus === 'loading'" class="games-status card-enter">
|
||||
در حال بارگذاری بازیها...
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else-if="gamesStore.catalogLoadStatus === 'error'"
|
||||
class="games-status games-status--error card-enter"
|
||||
>
|
||||
<p>{{ gamesStore.catalogLoadError ?? 'خطا در دریافت بازیها' }}</p>
|
||||
<PrimaryButton variant="gold" size="sm" @click="retryLoad">تلاش مجدد</PrimaryButton>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else-if="gamesStore.catalogLoadStatus === 'ready' && gamesStore.catalog.length === 0"
|
||||
class="games-status card-enter"
|
||||
>
|
||||
فعلاً بازیای برای نمایش نیست.
|
||||
</div>
|
||||
|
||||
<div v-else class="games-list">
|
||||
<GameCard
|
||||
v-for="(game, i) in GAMES"
|
||||
v-for="(game, i) in gamesStore.catalog"
|
||||
:key="game.id"
|
||||
:id="game.id"
|
||||
:title="game.title"
|
||||
@@ -40,4 +71,17 @@ function startGame(game: (typeof GAMES)[0]) {
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.games-status {
|
||||
text-align: center;
|
||||
padding: 32px 16px;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.games-status--error p {
|
||||
margin-bottom: 14px;
|
||||
color: #f87171;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user