import { View, Image, Button } from "@tarojs/components"; import './moment_item.scss' import { MainColorType } from "@/context/themes/color"; import TimeTitleDesc from "@/_health/components/time_title_desc"; import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; import isToday from 'dayjs/plugin/isToday'; import isTomorrow from 'dayjs/plugin/isTomorrow' import isYesterday from 'dayjs/plugin/isYesterday' import TargetProgress from "@/_health/components/target_progress"; import { rpxToPx } from "@/utils/tools"; import { getThemeColor } from "@/features/health/hooks/health_hooks"; import CoverList from "@/_health/components/cover_list"; import { jumpPage } from "@/features/trackTimeDuration/hooks/Common"; import { IconActive } from "@/components/basic/Icons"; dayjs.extend(relativeTime); dayjs.extend(isToday); dayjs.extend(isTomorrow); dayjs.extend(isYesterday); export default function MomentItem(props: { data: any }) { const { link, moment, user } = props.data const formatTime = (timestamp) => { const now = dayjs(); const time = dayjs(timestamp); if (time.isToday()) { return time.format('HH:mm'); // 今天的时间 } const diffInMinutes = now.diff(time, 'minute'); if (diffInMinutes < 60) { return `${diffInMinutes} min ago`; // xx分钟之前 } else { return time.format('YYYY-MM-DD'); // 显示完整日期 } }; const formatImages = (list) => { return list.map(obj => obj.url); } function goProfile() { jumpPage(`/_moment/pages/home?uid=${user.id}`) } function goDetail() { jumpPage(`/_health/pages/timeline_detail?disable_edit=1&window_id=${link.window_id}`) } return {user.nickname} { (moment.title || moment.description) && } { moment.media.length > 0 && } { link && link.ring && } { link && link.move && } /> } {formatTime(moment.timestamp)} }