generated from VLADIMIR/template_frontend
152 lines
3.0 KiB
Vue
152 lines
3.0 KiB
Vue
<script setup lang="ts">
|
|
import { NTag } from 'naive-ui'
|
|
import { ref } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
|
|
import { getAuthClient } from '@/api/auth_client'
|
|
import type { Scenario } from '@/api/generated/crabs/evening_detective_server'
|
|
import HeaderMenu from '@/components/HeaderMenu.vue'
|
|
|
|
const client = getAuthClient()
|
|
|
|
const scenarios = ref<Scenario[]>([])
|
|
|
|
const router = useRouter()
|
|
|
|
async function getScenarios() {
|
|
scenarios.value = []
|
|
const res = await client.GetScenariosCatalog({})
|
|
scenarios.value = res.scenarios!
|
|
}
|
|
|
|
async function toScenarioInfo(id: number) {
|
|
router.push('/scenarios/' + id)
|
|
}
|
|
|
|
getScenarios()
|
|
</script>
|
|
|
|
<template>
|
|
<div class="center-block-custom">
|
|
<div class="width1200 display-table catalog-grid">
|
|
<div
|
|
class="scenario-block"
|
|
v-for="scenario in scenarios"
|
|
@click="toScenarioInfo(scenario.id!)"
|
|
v-bind:key="scenario.id"
|
|
>
|
|
<div
|
|
class="scenario-image-block scenario-image"
|
|
:style="{ backgroundImage: `url(${scenario.image})` }"
|
|
></div>
|
|
|
|
<div class="scenario-content-block">
|
|
<p class="scenario-title">{{ scenario.name }}</p>
|
|
|
|
<p class="scenario-description">{{ scenario.description }}</p>
|
|
|
|
<p class="scenario-label">
|
|
<n-tag :bordered="false" type="success" class="status-block"
|
|
>Автор: {{ scenario.author?.username }}</n-tag
|
|
>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<HeaderMenu active="catalog" />
|
|
</template>
|
|
|
|
<style scoped>
|
|
.center-block-custom {
|
|
height: calc(100dvh - 70px);
|
|
}
|
|
|
|
.catalog-grid {
|
|
display: grid;
|
|
gap: 12px;
|
|
grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
|
|
max-width: 100%;
|
|
}
|
|
|
|
.scenario-block {
|
|
background-color: #222;
|
|
border: 2px solid #222;
|
|
border-radius: 10px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-height: 425px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.scenario-content-block {
|
|
display: flex;
|
|
flex: 1;
|
|
flex-direction: column;
|
|
padding: 12px;
|
|
}
|
|
|
|
.scenario-block:hover {
|
|
border: 2px solid #63e2b7;
|
|
color: #63e2b7;
|
|
}
|
|
|
|
.scenario-image-block {
|
|
aspect-ratio: 1;
|
|
background-color: #111;
|
|
border-radius: 10px;
|
|
}
|
|
|
|
.scenario-image {
|
|
background-position: center;
|
|
background-repeat: no-repeat;
|
|
background-size: contain;
|
|
}
|
|
|
|
.scenario-title {
|
|
overflow-wrap: anywhere;
|
|
padding-bottom: 8px;
|
|
}
|
|
|
|
.scenario-description {
|
|
-webkit-box-orient: vertical;
|
|
color: #aaa;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 3;
|
|
overflow: hidden;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
|
|
.scenario-label {
|
|
margin-top: auto;
|
|
padding-top: 12px;
|
|
}
|
|
|
|
.status-block {
|
|
height: auto;
|
|
line-height: 1.5;
|
|
max-width: 100%;
|
|
min-height: var(--n-height);
|
|
overflow-wrap: anywhere;
|
|
white-space: normal;
|
|
}
|
|
|
|
@media (width >=1024px) {
|
|
.catalog-grid {
|
|
grid-template-columns: repeat(auto-fill, 250px);
|
|
justify-content: center;
|
|
}
|
|
|
|
.scenario-block {
|
|
border-radius: 12px;
|
|
width: 250px;
|
|
}
|
|
|
|
.scenario-content-block {
|
|
padding: 12px;
|
|
}
|
|
}
|
|
</style>
|