You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

221 lines
4.1 KiB

<template>
<el-container class="full-height">
<el-header class="channel-header">
<div class="header-left">
<img src="../assets/2.png" class="adaptive-avatar" />
<div class="channel-info">
<h1>{{ items.publisherName }}</h1>
<p>{{ dingyue }}已订阅</p>
</div>
</div>
<el-button class="subscribe-button" :class="{ disabled: isSubscribed }" @click="toggleSubscribe">
{{ isSubscribed ? '已订阅' : '订阅' }}
</el-button>
</el-header>
<!-- 频道内容容器 -->
<el-main class="channel-content">
<div v-for="item in items" :key="item.title" class="content-card">
<div class="content-item">
<img :src="item.cover" class="content-cover" @click="showLoading(item.link)" />
<div class="content-details">
<h2>{{ item.title }}</h2>
<div class="content-meta">
<img :src="item.publisherAvatar" class="adaptive-avatar2" />
<span class="channel-name">{{ item.publisherName }}</span>
<span class="content-comments">{{ item.commentCount }}评论</span>
<span class="content-date">{{ item.publishTime }}</span>
</div>
</div>
</div>
</div>
</el-main>
</el-container>
</template>
<script setup>
import pindaoApi from '@/api/pindaoApi';
import { ref, onMounted } from 'vue';
// 定义响应式变量
const items = ref([]);
const dingyue = ref("500人");
//获取频道列表
function getpindao(queryType) {
pindaoApi.selectPindao(queryType).then((resp) => {
if (resp.data) {
items.value = resp.data.list;
console.log(items.value);
} else {
console.log('获取频道列表失败');
}
});
}
getpindao(4);
</script>
<style scoped>
.full-height {
height: 100%;
}
.channel-header {
background: url('src/assets/background.png') no-repeat center center fixed;
background-size: cover;
color: white;
padding: 30px 60px;
display: flex;
align-items: center;
justify-content: space-between;
position: relative;
min-height: 160px;
overflow: hidden;
}
.header-left {
display: flex;
align-items: center;
width: 30%;
z-index: 1;
}
.channel-info {
display: flex;
flex-direction: column;
justify-content: center;
height: 100px;
margin-left: 10px;
flex: 1;
z-index: 2;
}
.channel-info h1 {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 24px;
padding-left: 0%;
text-align: left;
}
.channel-info p {
margin: 5px 0 0 0;
text-align: left;
}
.subscribe-button {
background-color: #666;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.subscribe-button.disabled {
background-color: #ccc;
cursor: not-allowed;
}
.channel-content {
padding: 20px;
}
.content-card {
margin-bottom: 15px;
background-color: white;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 15px;
}
.content-item {
display: flex;
align-items: center;
height: 120px;
}
.content-cover {
width: 200px;
height: 120px;
margin-right: 20px;
cursor: pointer;
object-fit: cover;
}
.content-details {
flex-grow: 1;
}
.content-details h2 {
margin: 0 0 10px 0;
font-size: 18px;
color: black;
text-decoration: none;
transition: color 0.3s;
text-align: left;
}
.content-meta {
display: flex;
align-items: center;
margin-top: 10px;
padding-left: 10px;
}
.channel-name {
margin-right: 10px;
font-size: 14px;
color: #666;
}
.content-comments {
margin-right: 10px;
font-size: 14px;
color: #666;
}
.adaptive-avatar {
width: 100px;
height: 100%;
display: inline;
}
.adaptive-avatar2 {
width: 20px;
/* 头像宽度占父容器宽度的20% */
height: 10%;
/* 头像高度占父容器高度的20% */
}
.content-date {
font-size: 14px;
color: #666;
}
.content-item:hover h2 {
color: #007BFF;
}
/* 增加响应式处理 */
@media (max-width: 768px) {
.channel-header {
padding: 20px;
flex-direction: column;
align-items: flex-start;
}
.subscribe-button {
margin-top: 15px;
}
}
</style>