173 lines
3.1 KiB
Vue
173 lines
3.1 KiB
Vue
<template>
|
|
<div id="allstyle">
|
|
<div class="header">
|
|
<h1>目录</h1>
|
|
</div>
|
|
<div class="post_content">
|
|
<div v-for="(items, index) in datas" style=" padding: 20px;">
|
|
<h2>{{ items[index].title }}</h2>
|
|
<span class="badge badge-primary">共{{ contentsum(items) }}篇</span>
|
|
<ul class="pcont_ul">
|
|
<li class="pcont_li" v-for="item in items">
|
|
<a class="btn" @click="btnonclick(item.contentid)"><kbd>{{ item.content }}</kbd></a> — —({{ item.sum }})
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script setup>
|
|
import { useRouter } from 'vue-router'
|
|
const router = useRouter()
|
|
const btnonclick = (contentid) => {
|
|
router.push({
|
|
path: '/:type',
|
|
query: {
|
|
type: contentid
|
|
}
|
|
})
|
|
}
|
|
const contentsum = (items) => {
|
|
let nums = 0
|
|
for (let i = 0; i < items.length; i++) {
|
|
nums += items[i].sum
|
|
}
|
|
return nums
|
|
}
|
|
const datas = [
|
|
// 学习模块
|
|
[
|
|
{
|
|
title: '学习',
|
|
contentid: '1',
|
|
content: '算法',
|
|
sum: 1,
|
|
|
|
},
|
|
{
|
|
title: '学习',
|
|
contentid: '2',
|
|
content: '前端',
|
|
sum: 1,
|
|
},
|
|
{
|
|
title: '学习',
|
|
contentid: '3',
|
|
content: '后端',
|
|
sum: 1,
|
|
},
|
|
{
|
|
title: '学习',
|
|
contentid: '4',
|
|
content: 'Java',
|
|
sum: 1,
|
|
},
|
|
],
|
|
// 生活模块
|
|
[
|
|
{
|
|
title: '生活',
|
|
contentid: '1',
|
|
content: '生活',
|
|
sum: 1,
|
|
|
|
},
|
|
{
|
|
title: '生活',
|
|
contentid: '2',
|
|
content: '书',
|
|
sum: 1,
|
|
},
|
|
{
|
|
title: '生活',
|
|
contentid: '2',
|
|
content: '书',
|
|
sum: 1,
|
|
}
|
|
]
|
|
|
|
]
|
|
</script>
|
|
<style>
|
|
.header {
|
|
text-align: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
.post_content {
|
|
padding: 20px;
|
|
}
|
|
|
|
.pcont_ul {
|
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
gap: 15px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.pcont_li {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 10px 15px;
|
|
border-radius: 12px;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
|
|
.btn {
|
|
position: relative;
|
|
text-decoration: none;
|
|
color: black;
|
|
padding: 10px 15px;
|
|
border-radius: 8px;
|
|
transition: all 0.3s ease;
|
|
display: inline-block;
|
|
z-index: 1;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* 透明方块效果 */
|
|
.btn::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
border-radius: 8px;
|
|
z-index: -1;
|
|
transition: all 0.3s ease;
|
|
transform: scale(0.95);
|
|
opacity: 0.8;
|
|
}
|
|
|
|
/* 悬浮效果 */
|
|
.btn:hover::before {
|
|
transform: scale(1.1);
|
|
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
|
|
background: rgba(145, 196, 238, 0.85);
|
|
transform: translateY(-3px);
|
|
}
|
|
|
|
/* spa */
|
|
.badge {
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.badge-primary {
|
|
color: #2643e9;
|
|
background-color: rgba(203, 210, 246, .5);
|
|
}
|
|
|
|
.badge {
|
|
font-size: 66%;
|
|
font-weight: 600;
|
|
line-height: 1;
|
|
display: inline-block;
|
|
padding: .35rem .375rem;
|
|
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
|
text-align: center;
|
|
vertical-align: baseline;
|
|
white-space: nowrap;
|
|
border-radius: .25rem;
|
|
}
|
|
</style> |