Compare commits
6 Commits
1362d573ec
...
983b7a7c6d
Author | SHA1 | Date |
---|---|---|
|
983b7a7c6d | 4 months ago |
|
2f52a66c74 | 4 months ago |
|
4111a053b6 | 4 months ago |
|
e2562737af | 4 months ago |
|
91c27cdc31 | 4 months ago |
|
17653ef774 | 4 months ago |
After Width: | Height: | Size: 184 KiB |
@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div class="left-nav">
|
||||
<div class="nav-title">消息中心</div>
|
||||
<ul class="nav-list">
|
||||
<li
|
||||
v-for="(item, index) in navItems"
|
||||
:key="index"
|
||||
:class="['nav-item', { active: activeIndex === index }]"
|
||||
@click="handleNavClick(index)"
|
||||
>
|
||||
<span>{{ item.text }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
|
||||
const emit = defineEmits(['nav-change']);
|
||||
|
||||
const activeIndex = ref(0);
|
||||
|
||||
const navItems = [
|
||||
{ text: '私信消息' },
|
||||
{ text: '评论回复' },
|
||||
{ text: '收到的赞' },
|
||||
{ text: '系统通知' }
|
||||
];
|
||||
|
||||
const handleNavClick = (index: number) => {
|
||||
activeIndex.value = index;
|
||||
emit('nav-change', index);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.left-nav {
|
||||
width: 15%;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 2px solid rgba(133, 88, 207, 0.5);
|
||||
border-radius: 10px;
|
||||
padding: 20px 0;
|
||||
margin-right: 20px;
|
||||
margin-left: 100px;
|
||||
height: 90%;
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
padding: 0 20px;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
padding: 15px 20px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
margin: 5px 10px;
|
||||
border-radius: 8px;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.nav-item.active {
|
||||
background: rgba(156, 136, 255, 0.2);
|
||||
color: #9c88ff;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.nav-item:hover {
|
||||
background: rgba(156, 136, 255, 0.1);
|
||||
}
|
||||
</style>
|
@ -0,0 +1,41 @@
|
||||
export function formatTime(timestamp: number): string {
|
||||
const date = new Date(timestamp);
|
||||
const now = new Date();
|
||||
const diff = now.getTime() - timestamp;
|
||||
|
||||
// 不到1分钟
|
||||
if (diff < 60 * 1000) {
|
||||
return '刚刚';
|
||||
}
|
||||
|
||||
// 不到1小时
|
||||
if (diff < 60 * 60 * 1000) {
|
||||
const minutes = Math.floor(diff / (60 * 1000));
|
||||
return `${minutes}分钟前`;
|
||||
}
|
||||
|
||||
// 不到24小时
|
||||
if (diff < 24 * 60 * 60 * 1000) {
|
||||
const hours = Math.floor(diff / (60 * 60 * 1000));
|
||||
return `${hours}小时前`;
|
||||
}
|
||||
|
||||
// 不到7天
|
||||
if (diff < 7 * 24 * 60 * 60 * 1000) {
|
||||
const days = Math.floor(diff / (24 * 60 * 60 * 1000));
|
||||
return `${days}天前`;
|
||||
}
|
||||
|
||||
// 同一年
|
||||
if (date.getFullYear() === now.getFullYear()) {
|
||||
return `${date.getMonth() + 1}月${date.getDate()}日 ${padZero(date.getHours())}:${padZero(date.getMinutes())}`;
|
||||
}
|
||||
|
||||
// 其他情况显示完整日期
|
||||
return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日 ${padZero(date.getHours())}:${padZero(date.getMinutes())}`;
|
||||
}
|
||||
|
||||
// 补零函数
|
||||
function padZero(num: number): string {
|
||||
return num < 10 ? `0${num}` : num.toString();
|
||||
}
|
Loading…
Reference in new issue