mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-27 11:36:22 +00:00
feat: 添加移动端检测功能,优化组件动画效果
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 9s
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 9s
This commit is contained in:
@ -15,6 +15,7 @@ import { listLabels } from "@/api/label";
|
||||
import { POST_SORT_TYPE } from "@/localstore";
|
||||
import { motion } from "framer-motion";
|
||||
import { useDevice } from "@/hooks/use-device";
|
||||
import { checkIsMobile } from "@/utils/client/device";
|
||||
|
||||
// 定义排序类型
|
||||
type SortType = 'latest' | 'popular';
|
||||
@ -23,7 +24,6 @@ export default function BlogHome() {
|
||||
const [labels, setLabels] = useState<Label[]>([]);
|
||||
const [posts, setPosts] = useState<Post[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { isMobile } = useDevice();
|
||||
const [sortType, setSortType, sortTypeLoaded] = useStoredState<SortType>(POST_SORT_TYPE, 'latest');
|
||||
useEffect(() => {
|
||||
if (!sortTypeLoaded) return;
|
||||
@ -90,7 +90,7 @@ export default function BlogHome() {
|
||||
{/* 主要内容区域 */}
|
||||
<motion.div
|
||||
className="lg:col-span-3 self-start"
|
||||
initial={{ y: isMobile ? 30 : 60, opacity: 0 }}
|
||||
initial={{ y: checkIsMobile() ? 30 : 60, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
transition={{ duration: config.animationDurationSecond, ease: "easeOut" }}>
|
||||
{/* 文章列表标题 */}
|
||||
@ -155,9 +155,9 @@ export default function BlogHome() {
|
||||
|
||||
{/* 侧边栏 */}
|
||||
<motion.div
|
||||
initial={isMobile ? { y: 30, opacity: 0 } : { x: 80, opacity: 0 }}
|
||||
initial={checkIsMobile() ? { y: 30, opacity: 0 } : { x: 80, opacity: 0 }}
|
||||
animate={{ x: 0, y: 0, opacity: 1 }}
|
||||
transition={{ duration: config.animationDurationSecond , ease: "easeOut" }}
|
||||
transition={{ duration: config.animationDurationSecond, ease: "easeOut" }}
|
||||
>
|
||||
<Sidebar
|
||||
cards={[
|
||||
|
Reference in New Issue
Block a user