hookehuyr

✨ feat(首页最新资讯): 自适应适配显示

1 <!-- 1 <!--
2 * @Date: 2024-08-27 10:06:30 2 * @Date: 2024-08-27 10:06:30
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-10 13:52:00 4 + * @LastEditTime: 2024-10-10 14:19:59
5 * @FilePath: /hager/src/views/index.vue 5 * @FilePath: /hager/src/views/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -70,12 +70,12 @@ ...@@ -70,12 +70,12 @@
70 </div> 70 </div>
71 </div> 71 </div>
72 </hager-box> 72 </hager-box>
73 - <hager-box class="box-2n"> 73 + <hager-box v-if="!is_xs" class="box-2n">
74 <hager-h1 title="最新资讯" sub="News"></hager-h1> 74 <hager-h1 title="最新资讯" sub="News"></hager-h1>
75 <div class="news-container"> 75 <div class="news-container">
76 <el-row :gutter="0" v-for="(item, index) in news_list" :key="index"> 76 <el-row :gutter="0" v-for="(item, index) in news_list" :key="index">
77 <el-col :span="12" style="height: 25rem;"> 77 <el-col :span="12" style="height: 25rem;">
78 - <img v-if="index % 2 === 0" :src="item.src" alt="News Image 1"> 78 + <img class="news-item-img" v-if="index % 2 === 0" :src="item.src" alt="News Image 1">
79 <div v-else @click="goToNew(item)" class="news-item"> 79 <div v-else @click="goToNew(item)" class="news-item">
80 <div class="news-item-title">{{ item.title }}</div> 80 <div class="news-item-title">{{ item.title }}</div>
81 <p class="news-item-sub">{{ item.sub }}</p> 81 <p class="news-item-sub">{{ item.sub }}</p>
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
90 <p class="news-item-content">{{ item.content }}</p> 90 <p class="news-item-content">{{ item.content }}</p>
91 <i class="el-icon-right"></i> 91 <i class="el-icon-right"></i>
92 </div> 92 </div>
93 - <img v-else :src="item.src" alt="News Image 1"> 93 + <img class="news-item-img" v-else :src="item.src" alt="News Image 1">
94 </el-col> 94 </el-col>
95 </el-row> 95 </el-row>
96 </div> 96 </div>
...@@ -98,6 +98,25 @@ ...@@ -98,6 +98,25 @@
98 <hager-more></hager-more> 98 <hager-more></hager-more>
99 </div> 99 </div>
100 </hager-box> 100 </hager-box>
101 + <div v-else style="background-color: #f9f9f9; padding-bottom: 1rem;">
102 + <hager-h1 title="最新资讯" sub="News" style="padding: 2rem;"></hager-h1>
103 + <div class="news-container xs">
104 + <el-row :gutter="0" v-for="(item, index) in news_list" :key="index">
105 + <el-col :span="24">
106 + <img class="news-item-img xs" :src="item.src" alt="News Image 1">
107 + <div @click="goToNew(item)" class="news-item xs">
108 + <div class="news-item-title">{{ item.title }}</div>
109 + <p class="news-item-sub">{{ item.sub }}</p>
110 + <p class="news-item-content">{{ item.content }}</p>
111 + <i class="el-icon-right"></i>
112 + </div>
113 + </el-col>
114 + </el-row>
115 + </div>
116 + <div style="display: flex; justify-content: center; margin-top: 2rem;">
117 + <hager-more></hager-more>
118 + </div>
119 + </div>
101 <hager-box class="box-n"> 120 <hager-box class="box-n">
102 <hager-h1 title="招聘信息" sub="Recruit"></hager-h1> 121 <hager-h1 title="招聘信息" sub="Recruit"></hager-h1>
103 <p style="margin: 2rem 0;">心国近心,支注万你。海恰人囫指员光工,然于則行!我们哦这音齐稱央那八我们附行列,共同书与成功的扁草。用你的才罕,刨道九限可能!</p> 122 <p style="margin: 2rem 0;">心国近心,支注万你。海恰人囫指员光工,然于則行!我们哦这音齐稱央那八我们附行列,共同书与成功的扁草。用你的才罕,刨道九限可能!</p>
...@@ -326,11 +345,23 @@ export default { ...@@ -326,11 +345,23 @@ export default {
326 } 345 }
327 .news-container { 346 .news-container {
328 margin-top: 2rem; 347 margin-top: 2rem;
329 - img { 348 + &.xs {
330 - width: 100%; height: 100%; border-radius: 5px;object-fit: cover; 349 + margin: 0;
350 + }
351 + .news-item-img {
352 + width: 100%;
353 + height: 100%;
354 + border-radius: 5px;
355 + object-fit: cover;
356 + &.xs {
357 + border-radius: 0;
358 + }
331 } 359 }
332 .news-item { 360 .news-item {
333 padding: 3rem; 361 padding: 3rem;
362 + &.xs {
363 + padding: 2rem;
364 + }
334 &:hover { 365 &:hover {
335 cursor: pointer; 366 cursor: pointer;
336 } 367 }
......