优化 时间显示格式调整

This commit is contained in:
2025-10-12 23:39:28 +08:00
parent b2fda14451
commit 27133aa107
9 changed files with 208 additions and 70 deletions

View File

@@ -65,6 +65,7 @@ import NoteItem from '../components/NoteItem.vue'
import Header from '../components/Header.vue'
import FolderManage from '../components/FolderManage.vue'
import SearchBar from '../components/SearchBar.vue'
import { formatNoteListDate } from '../utils/dateUtils'
const store = useAppStore()
@@ -318,31 +319,7 @@ const debouncedHandleSearch = debounceSearch((query) => {
// 改进的日期格式化函数
const formatDate = dateString => {
const date = new Date(dateString)
const now = new Date()
// 计算日期差
const diffTime = now - date
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24))
// 今天的便签显示时间
if (diffDays === 0) {
return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`
}
// 昨天的便签显示"昨天"
if (diffDays === 1) {
return '昨天'
}
// 一周内的便签显示星期几
if (diffDays < 7) {
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
return weekdays[date.getDay()]
}
// 超过一周的便签显示月日
return `${date.getMonth() + 1}/${date.getDate()}`
return formatNoteListDate(dateString)
}
const setCurrentFolder = folder => {