File tree Expand file tree Collapse file tree 8 files changed +1093
-1989
lines changed Expand file tree Collapse file tree 8 files changed +1093
-1989
lines changed Original file line number Diff line number Diff line change @@ -2,21 +2,23 @@ import AppShell from "@/components/app-shell";
22import DynamicPostHogIdentifier from "@/providers/posthog-identifier.dynamic" ;
33import AuthorizedApolloWrapper from "@/providers/use-apollo.rsc" ;
44import ProtectedRoute from "@/providers/use-protected-route" ;
5- import { unstable_ViewTransition as ViewTransition } from "react" ;
5+ import { Suspense , ViewTransition } from "react" ;
66
77export default function Layout ( { children } : { children : React . ReactNode } ) {
88 return (
9- < ProtectedRoute >
10- < AuthorizedApolloWrapper >
11- < AppShell >
12- < div className = "mx-auto w-full max-w-7xl flex-1 p-3" >
13- < ViewTransition name = "app-content" >
14- < div suppressHydrationWarning > { children } </ div >
15- </ ViewTransition >
16- </ div >
17- </ AppShell >
18- < DynamicPostHogIdentifier />
19- </ AuthorizedApolloWrapper >
20- </ ProtectedRoute >
9+ < Suspense >
10+ < ProtectedRoute >
11+ < AuthorizedApolloWrapper >
12+ < AppShell >
13+ < div className = "mx-auto w-full max-w-7xl flex-1 p-3" >
14+ < ViewTransition name = "app-content" >
15+ < div suppressHydrationWarning > { children } </ div >
16+ </ ViewTransition >
17+ </ div >
18+ </ AppShell >
19+ < DynamicPostHogIdentifier />
20+ </ AuthorizedApolloWrapper >
21+ </ ProtectedRoute >
22+ </ Suspense >
2123 ) ;
2224}
Original file line number Diff line number Diff line change @@ -5,6 +5,17 @@ import { connection } from "next/server";
55export default async function DoYouKnow ( ) {
66 await connection ( ) ;
77
8+ const randomKnow = await getDoYouKnow ( ) ;
9+
10+ return (
11+ < div className = "flex flex-col justify-center gap-2 text-center" >
12+ < div className = "text-sm text-gray-500" > 你知道嗎?</ div >
13+ < div className = "font-normal" > { randomKnow } </ div >
14+ </ div >
15+ ) ;
16+ }
17+
18+ export async function getDoYouKnow ( ) {
819 const knowsList = [
920 < p key = "do-you-knows-daily-login" >
1021 每天登入可以獲得 20 點點數,< br /> 連續 7 天登入可以獲得 50 點加成!
@@ -21,10 +32,6 @@ export default async function DoYouKnow() {
2132 ] ;
2233
2334 const randomKnow = knowsList [ Math . floor ( Math . random ( ) * knowsList . length ) ] ;
24- return (
25- < div className = "flex flex-col justify-center gap-2 text-center" >
26- < div className = "text-sm text-gray-500" > 你知道嗎?</ div >
27- < div className = "font-normal" > { randomKnow } </ div >
28- </ div >
29- ) ;
35+
36+ return randomKnow ;
3037}
Original file line number Diff line number Diff line change 11"use server" ;
22
33import buildUri from "@/lib/build-uri" ;
4+ import { unstable_cacheLife as cacheLife } from "next/cache" ;
45
56export async function getUpstreamLatency ( ) : Promise < number > {
7+ "use cache" ;
8+ cacheLife ( "minutes" ) ;
9+
610 try {
7- const start = Date . now ( ) ;
11+ const start = performance . now ( ) ;
812
9- const response = await fetch ( buildUri ( "/" ) , {
10- next : {
11- revalidate : 120 , // update latency every 2 minutes
12- } ,
13- } ) ;
13+ const response = await fetch ( buildUri ( "/" ) ) ;
1414 if ( ! response . ok ) {
1515 return - 1 ;
1616 }
1717
18- return Date . now ( ) - start ;
18+ return Math . round ( performance . now ( ) - start ) ;
1919 } catch ( error ) {
2020 console . error ( "Error getting upstream status:" , error ) ;
2121 return - 1 ;
You can’t perform that action at this time.
0 commit comments