import { useArray } from '@sa/hooks'; import { AnimatePresence, motion } from 'framer-motion'; import SoybeanAvatar from '@/components/SoybeanAvatar'; const variants = { exit: { opacity: 0, transition: { duration: 0.3 }, x: 200 }, hidden: { opacity: 0, y: -20 }, visible: { opacity: 1, transition: { duration: 0.3 }, y: 0 } }; const ProjectNews = () => { const { t } = useTranslation(); const [newses, { down, pop, push, remove, reset, reverse, shift, sort, unshift, up }] = useArray([ { content: t('page.home.projectNews.desc1'), id: 1, time: '2021-05-28 22:22:22' }, { content: t('page.home.projectNews.desc2'), id: 2, time: '2023-10-27 10:24:54' }, { content: t('page.home.projectNews.desc3'), id: 3, time: '2021-10-31 22:43:12' }, { content: t('page.home.projectNews.desc4'), id: 4, time: '2022-11-03 20:33:31' }, { content: t('page.home.projectNews.desc5'), id: 5, time: '2021-11-07 22:45:32' } ]); const sortByTimeDesc = () => { sort((a, b) => new Date(b.time).getTime() - new Date(a.time).getTime()); }; return ( 重置 , 反转 , 以时间排序 , unshift({ content: '我是第一个', id: 1, time: '2021-11-07 22:45:32' })} > 从头添加 , 删除头部 , push({ content: '我是第六个', id: 6, time: '2021-11-07 22:45:32' })} > 尾部添加 , 删除尾部 , {t('page.home.projectNews.moreNews')} ]} > ( up(item.id)} > 上移 , remove(item.id)} > 删除 , down(item.id)} > 下移 ]} > } description={item.time} title={item.content} /> )} /> ); }; export default ProjectNews;