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

  1. <template>
  2. <el-container class="full-height">
  3. <el-header class="channel-header">
  4. <div class="header-left">
  5. <img src="../assets/2.png" class="adaptive-avatar" />
  6. <div class="channel-info">
  7. <h1>{{ items.publisherName }}</h1>
  8. <p>{{ dingyue }}已订阅</p>
  9. </div>
  10. </div>
  11. <el-button class="subscribe-button" :class="{ disabled: isSubscribed }" @click="toggleSubscribe">
  12. {{ isSubscribed ? '已订阅' : '订阅' }}
  13. </el-button>
  14. </el-header>
  15. <!-- 频道内容容器 -->
  16. <el-main class="channel-content">
  17. <div v-for="item in items" :key="item.title" class="content-card">
  18. <div class="content-item">
  19. <img :src="item.cover" class="content-cover" @click="showLoading(item.link)" />
  20. <div class="content-details">
  21. <h2>{{ item.title }}</h2>
  22. <div class="content-meta">
  23. <img :src="item.publisherAvatar" class="adaptive-avatar2" />
  24. <span class="channel-name">{{ item.publisherName }}</span>
  25. <span class="content-comments">{{ item.commentCount }}评论</span>
  26. <span class="content-date">{{ item.publishTime }}</span>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </el-main>
  32. </el-container>
  33. </template>
  34. <script setup>
  35. import pindaoApi from '@/api/pindaoApi';
  36. import { ref, onMounted } from 'vue';
  37. // 定义响应式变量
  38. const items = ref([]);
  39. const dingyue = ref("500人");
  40. //获取频道列表
  41. function getpindao(queryType) {
  42. pindaoApi.selectPindao(queryType).then((resp) => {
  43. if (resp.data) {
  44. items.value = resp.data.list;
  45. console.log(items.value);
  46. } else {
  47. console.log('获取频道列表失败');
  48. }
  49. });
  50. }
  51. getpindao(4);
  52. </script>
  53. <style scoped>
  54. .full-height {
  55. height: 100%;
  56. }
  57. .channel-header {
  58. background: url('src/assets/background.png') no-repeat center center fixed;
  59. background-size: cover;
  60. color: white;
  61. padding: 30px 60px;
  62. display: flex;
  63. align-items: center;
  64. justify-content: space-between;
  65. position: relative;
  66. min-height: 160px;
  67. overflow: hidden;
  68. }
  69. .header-left {
  70. display: flex;
  71. align-items: center;
  72. width: 30%;
  73. z-index: 1;
  74. }
  75. .channel-info {
  76. display: flex;
  77. flex-direction: column;
  78. justify-content: center;
  79. height: 100px;
  80. margin-left: 10px;
  81. flex: 1;
  82. z-index: 2;
  83. }
  84. .channel-info h1 {
  85. white-space: nowrap;
  86. overflow: hidden;
  87. text-overflow: ellipsis;
  88. font-size: 24px;
  89. padding-left: 0%;
  90. text-align: left;
  91. }
  92. .channel-info p {
  93. margin: 5px 0 0 0;
  94. text-align: left;
  95. }
  96. .subscribe-button {
  97. background-color: #666;
  98. color: white;
  99. border: none;
  100. padding: 10px 20px;
  101. border-radius: 5px;
  102. cursor: pointer;
  103. transition: background-color 0.3s;
  104. }
  105. .subscribe-button.disabled {
  106. background-color: #ccc;
  107. cursor: not-allowed;
  108. }
  109. .channel-content {
  110. padding: 20px;
  111. }
  112. .content-card {
  113. margin-bottom: 15px;
  114. background-color: white;
  115. border-radius: 5px;
  116. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  117. padding: 15px;
  118. }
  119. .content-item {
  120. display: flex;
  121. align-items: center;
  122. height: 120px;
  123. }
  124. .content-cover {
  125. width: 200px;
  126. height: 120px;
  127. margin-right: 20px;
  128. cursor: pointer;
  129. object-fit: cover;
  130. }
  131. .content-details {
  132. flex-grow: 1;
  133. }
  134. .content-details h2 {
  135. margin: 0 0 10px 0;
  136. font-size: 18px;
  137. color: black;
  138. text-decoration: none;
  139. transition: color 0.3s;
  140. text-align: left;
  141. }
  142. .content-meta {
  143. display: flex;
  144. align-items: center;
  145. margin-top: 10px;
  146. padding-left: 10px;
  147. }
  148. .channel-name {
  149. margin-right: 10px;
  150. font-size: 14px;
  151. color: #666;
  152. }
  153. .content-comments {
  154. margin-right: 10px;
  155. font-size: 14px;
  156. color: #666;
  157. }
  158. .adaptive-avatar {
  159. width: 100px;
  160. height: 100%;
  161. display: inline;
  162. }
  163. .adaptive-avatar2 {
  164. width: 20px;
  165. /* 头像宽度占父容器宽度的20% */
  166. height: 10%;
  167. /* 头像高度占父容器高度的20% */
  168. }
  169. .content-date {
  170. font-size: 14px;
  171. color: #666;
  172. }
  173. .content-item:hover h2 {
  174. color: #007BFF;
  175. }
  176. /* 增加响应式处理 */
  177. @media (max-width: 768px) {
  178. .channel-header {
  179. padding: 20px;
  180. flex-direction: column;
  181. align-items: flex-start;
  182. }
  183. .subscribe-button {
  184. margin-top: 15px;
  185. }
  186. }
  187. </style>