♻️ 叠层单独提出来作为组件使用

This commit is contained in:
BTMuli
2023-05-19 18:49:06 +08:00
parent a65763bab9
commit 779bc3a0d3
7 changed files with 303 additions and 224 deletions

View File

@@ -1,23 +1,7 @@
<template>
<div class="cards-grid">
<div v-for="item in cardsInfo" :key="item.id" class="card-box" @click="toOuter(item)">
<!-- 底层背景图 -->
<div class="card-bg">
<img :src="item.bg" alt="bg">
</div>
<!-- 中层武器图 -->
<div class="card-icon">
<img :src="item.icon" alt="icon">
</div>
<!-- 上层图标&内容 -->
<div class="card-cover">
<div class="card-type">
<img :src="item.type" alt="type">
</div>
<div class="card-name">
<span>{{ item.name }}</span>
</div>
</div>
<TMiniWeapon size="128px" :model-value="item" />
</div>
<v-snackbar v-model="snackbar" timeout="1500" color="error">
该武器暂无详情
@@ -28,6 +12,7 @@
<script lang="ts" setup>
// vue
import { ref, onMounted } from "vue";
import TMiniWeapon from "../../components/t-mini-weapon.vue";
// utils
import { createTGWindow } from "../../utils/TGWindow";
import { TGAppData } from "../../data";
@@ -56,98 +41,7 @@ function toOuter (item: BTMuli.Genshin.Wiki.Weapon.BriefInfo) {
.cards-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
grid-gap: 20px;
padding: 20px;
}
.card-box {
position: relative;
width: 100%;
height: 100%;
cursor: pointer;
}
.card-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 5px;
overflow: hidden;
}
.card-bg img {
width: 100%;
height: 100%;
object-fit: cover;
}
.card-icon {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
border-radius: 5px;
}
.card-icon img {
width: 100%;
height: 100%;
object-fit: cover;
}
.card-cover {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 5px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.card-type {
position: absolute;
top: 0;
left: 0;
width: 40px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
}
.card-type img {
width: 30px;
height: 30px;
object-fit: cover;
}
.card-name img {
width: 20px;
height: 20px;
margin-right: 5px;
}
.card-name {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
background: rgb(20 20 20 / 50%);
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
color: #fff;
font-size: 20px;
text-shadow: 0 0 5px #000;
font-family: Genshin, serif;
grid-gap: 15px;
padding: 15px;
}
</style>