From 3277ed81aff7de27d2c042242290680ec41d037c Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 6 Jul 2023 00:49:08 +0800 Subject: [PATCH] feat: update Signed-off-by: Innei --- src/app.config.ts | 2 +- src/app/(home)/page.tsx | 204 ++++++++++++++++++++++++++++++--------- src/app/error.tsx | 3 +- src/lib/route-builder.ts | 1 + 4 files changed, 164 insertions(+), 46 deletions(-) diff --git a/src/app.config.ts b/src/app.config.ts index 3f7f1eb5ce..7a509ed47b 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -38,7 +38,7 @@ export const appConfig = { type: 'code', text: '', class: - 'font-medium mx-2 text-3xl rounded p-1 bg-opacity-0 hover:bg-opacity-100 bg-gray-200 dark:bg-gray-800 transition-background duration-200', + 'font-medium mx-2 text-3xl rounded p-1 bg-gray-200 dark:bg-gray-800/0 hover:dark:bg-gray-800/100 bg-opacity-0 hover:bg-opacity-100 transition-background duration-200', }, ], }, diff --git a/src/app/(home)/page.tsx b/src/app/(home)/page.tsx index 32533c80db..94839c1165 100644 --- a/src/app/(home)/page.tsx +++ b/src/app/(home)/page.tsx @@ -1,9 +1,9 @@ 'use client' import { useQuery } from '@tanstack/react-query' -import React, { createElement, forwardRef } from 'react' +import React, { createElement, forwardRef, useEffect, useRef } from 'react' import clsx from 'clsx' -import { m } from 'framer-motion' +import { m, useInView } from 'framer-motion' import Link from 'next/link' import type { PropsWithChildren } from 'react' @@ -14,13 +14,18 @@ import { TextUpTransitionView } from '~/components/ui/transition/TextUpTransitio import { isSupportIcon, SocialIcon } from '~/components/widgets/home/SocialIcon' import { PeekLink } from '~/components/widgets/peek/PeekLink' import { PostMetaBar } from '~/components/widgets/post' -import { softBouncePrest, softSpringPreset } from '~/constants/spring' +import { + microReboundPreset, + softBouncePrest, + softSpringPreset, +} from '~/constants/spring' import { useConfig } from '~/hooks/data/use-config' import { isDev } from '~/lib/env' import { clsxm } from '~/lib/helper' import { noopObj } from '~/lib/noop' import { apiClient } from '~/lib/request' import { routeBuilder, Routes } from '~/lib/route-builder' +import { springScrollToTop } from '~/lib/scroller' import { useAggregationSelector } from '~/providers/root/aggregation-data-provider' import { useHomeQueryData } from './query' @@ -34,6 +39,9 @@ const Screen = forwardRef< className?: string }> >((props, ref) => { + const inViewRef = useRef(null) + const inView = useInView(inViewRef, { once: true }) + return (
- {props.children} + + {inView && props.children}
) }) Screen.displayName = 'Screen' export default function Home() { + useEffect(() => { + if (isDev) return + springScrollToTop() + }, []) return (
- -

- 这个页面还没构思,待到春去秋来,我会在这里写下一些关于我自己的故事。 -

-

其他页面基本已完成。你可以在顶部的导航栏中找到它们。

-

欢迎给我反馈问题,谢谢您。

-
- @@ -184,9 +189,8 @@ const Welcome = () => { { opacity: 0.0001, y: 50, }} - whileInView={{ + animate={{ opacity: 1, y: 0, }} - viewport={{ once: true }} transition={softSpringPreset} className="text-2xl font-medium leading-loose" > @@ -234,8 +237,7 @@ const PostScreen = () => { return ( { {
-

+ 看看我的近况,这是我最近的所思所想 -

-
+ { }} /> )} -
+
{hasHistory && (
-
这里还有一些历史回顾
+ + 这里还有一些历史回顾 +
    - {history.map((note) => { + {history.map((note, i) => { return ( -
  • + { displayAbsoluteTimeAfterDay={180} /> -
  • + ) })}
+ + + + + 还有更多,要不要看看? + + +
)}
-

+ 而在这里,你会看到一个不同的我,
一个在生活中发现美,感受痛苦,洞察人性的我。 -

+
) @@ -404,28 +471,77 @@ const FriendScreen = () => { staleTime: 1000 * 60, }) return ( - -

- 这些是我珍视的人,他们陪伴我走过人生的每一段旅程,和我一起笑,一起哭,一起成长。 -

-
    - {data?.data.map((friend) => { - return
  • {friend.name}
  • - })} -
- 还有更多.. + +
+ + 这些是我珍视的人,他们陪伴我走过人生的每一段旅程。 + + + + + + + 还有更多,要不要看看? + + + +
) } const MoreScreen = () => { + return null return ( -

- 最后,这是关于这个小宇宙以及我自己的一些小秘密。如果你有任何问题或者想要分享的想法,都可以随时找到我。 -

+

感谢看到这里。

-
Like this?
+
TODO
) } diff --git a/src/app/error.tsx b/src/app/error.tsx index f8187cefce..c2b610e598 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -12,6 +12,7 @@ import { isRequestError, pickStatusCode } from '~/lib/is-error' // eslint-disable-next-line react/display-name export default ({ error, reset }: any) => { useEffect(() => { + console.log('error', error) captureException(error) }, [error]) @@ -26,7 +27,7 @@ export default ({ error, reset }: any) => { return (
-

Something went wrong!

+

Something went wrong!

Try again diff --git a/src/lib/route-builder.ts b/src/lib/route-builder.ts index edd2973e7f..3e76338b78 100644 --- a/src/lib/route-builder.ts +++ b/src/lib/route-builder.ts @@ -22,6 +22,7 @@ export const enum Routes { Project = '/projects/', Says = '/says', + Friends = '/friends', PageDeletd = '/common/deleted', }