数据开放样式优化

This commit is contained in:
JenniferW 2025-09-08 15:51:04 +08:00
parent 22f22a8c83
commit 9e8a9d518d
2 changed files with 86 additions and 31 deletions

View File

@ -6,6 +6,30 @@
:key="index"
class="ranking-item"
>
<!-- 计算实际排名处理扩展列表的情况 -->
<div class="rank-item">
<template v-if="isTopThree(index)">
<img
v-if="getRealIndex(index) === 0"
src="@/assets/first.png"
alt="第一名"
class="rank-image"
/>
<img
v-if="getRealIndex(index) === 1"
src="@/assets/second.png"
alt="第二名"
class="rank-image"
/>
<img
v-else-if="getRealIndex(index) === 2"
src="@/assets/third.png"
alt="第三名"
class="rank-image"
/>
</template>
<div v-else class="rank-number">{{ getRealIndex(index) + 1 }}</div>
</div>
<span class="item-name">{{ item.name }}</span>
<span class="item-count">{{ item.count }}</span>
</li>
@ -35,7 +59,7 @@ export default {
return {
scrollTimer: null,
currentPosition: 0,
itemHeight: 0, //
itemHeight: 0,
};
},
computed: {
@ -47,7 +71,6 @@ export default {
},
},
mounted() {
// DOM
this.$nextTick(() => {
this.calculateItemHeight();
if (this.list.length > this.visibleCount) {
@ -69,12 +92,10 @@ export default {
}
},
methods: {
//
calculateItemHeight() {
const firstItem = this.$refs.rankingList?.querySelector(".ranking-item");
if (firstItem) {
this.itemHeight = firstItem.offsetHeight;
//
this.$el.style.height = `${this.itemHeight * this.visibleCount}px`;
}
},
@ -101,7 +122,6 @@ export default {
}px)`;
rankingList.style.transition = "transform 0.5s ease";
//
if (this.currentPosition >= this.list.length) {
setTimeout(() => {
this.currentPosition = 0;
@ -110,6 +130,15 @@ export default {
}, 500);
}
},
//
getRealIndex(index) {
return index % this.list.length;
},
//
isTopThree(index) {
const realIndex = this.getRealIndex(index);
return realIndex < 3;
},
},
};
</script>
@ -130,11 +159,12 @@ export default {
.ranking-item {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 13px;
color: rgba(255, 255, 255, 0.8);
font-size: 16px;
color: rgba(255, 255, 255, 0.9);
transition: all 0.3s ease;
padding: 6px 0; /* 增加内边距使条目高度更合适 */
padding: 6px 0;
&:hover {
color: #fff;
@ -142,14 +172,46 @@ export default {
}
}
.rank-item {
margin-right: 8px;
display: flex;
align-items: center;
justify-content: center;
}
.rank-image {
width: 16px;
height: 16px;
object-fit: contain;
}
.rank-number {
width: 16px;
height: 16px;
border-radius: 3px;
background-color: rgba(74, 144, 226, 0.3);
color: #fff;
font-size: 11px;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
}
.item-name {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 70%;
flex: 1;
margin-right: 10px;
}
.item-count {
font-weight: 500;
min-width: 40px;
text-align: right;
background: #17f5f8;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
</style>

View File

@ -29,7 +29,7 @@
</div>
<div class="stat-item">
<span class="stat-label">调用异常接口数</span>
<span class="stat-value">1</span>
<span class="stat-value abnormal">1</span>
</div>
</div>
</div>
@ -201,34 +201,33 @@ export default {
.share-stats {
display: flex;
flex-direction: column;
gap: 15px;
width: 100%;
}
.stat-item {
display: flex;
justify-content: space-between;
background: rgba(74, 144, 226, 0.1);
padding: 12px 10px;
align-items: center;
padding: 10px;
border-radius: 8px;
transition: all 0.3s ease;
&:hover {
background: rgba(74, 144, 226, 0.2);
box-shadow: 0 0 10px rgba(74, 144, 226, 0.3);
}
.stat-label {
font-size: 13px;
color: rgba(255, 255, 255, 0.7);
font-size: 16px;
color: rgba(255, 255, 255, 0.9);
display: block;
margin-bottom: 6px;
}
.stat-value {
font-size: 18px;
font-size: 32px;
font-weight: bold;
background: linear-gradient(to top, #4a90e2, #fff);
background: #17f5f8;
font-style: italic;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.abnormal {
background: #dd7149;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
@ -236,21 +235,15 @@ export default {
//
.chart-item {
background: rgba(74, 144, 226, 0.1);
padding: 12px 10px;
padding: 10px;
border-radius: 8px;
transition: all 0.3s ease;
width: 100%;
display: flex;
flex-direction: column;
&:hover {
background: rgba(74, 144, 226, 0.2);
box-shadow: 0 0 10px rgba(74, 144, 226, 0.3);
}
.chart-title {
font-size: 14px;
font-size: 18px;
color: #fff;
margin-bottom: 10px;
text-shadow: 0 0 3px rgba(74, 144, 226, 0.5);