diff --git a/src/app/[chain]/block/[hash]/layout.tsx b/src/app/[chain]/block/[hash]/layout.tsx new file mode 100644 index 00000000..1ad5b9a4 --- /dev/null +++ b/src/app/[chain]/block/[hash]/layout.tsx @@ -0,0 +1,3 @@ +export default function Layout({ children }) { + return
{children}
; +} diff --git a/src/app/[chain]/block/[hash]/loading.tsx b/src/app/[chain]/block/[hash]/loading.tsx new file mode 100644 index 00000000..2b09afda --- /dev/null +++ b/src/app/[chain]/block/[hash]/loading.tsx @@ -0,0 +1,7 @@ +'use client'; +import { useIsGovernance } from '@_hooks/useIsPath'; +import { Skeleton } from 'antd'; +export default function Loading() { + const isGovernance = useIsGovernance(); + return !isGovernance && ; +} diff --git a/src/app/[chain]/blocks/blockList.tsx b/src/app/[chain]/blocks/blockList.tsx index 4aad7db6..34228494 100644 --- a/src/app/[chain]/blocks/blockList.tsx +++ b/src/app/[chain]/blocks/blockList.tsx @@ -9,7 +9,7 @@ import HeadTitle from '@_components/HeaderTitle'; import Table from '@_components/Table'; import getColumns from './columnConfig'; -import { useCallback, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { ColumnsType } from 'antd/es/table'; import { useMobileAll } from '@_hooks/useResponsive'; import { IBlocksResponse, IBlocksResponseItem } from '@_api/type'; @@ -18,6 +18,7 @@ import { fetchBlocks } from '@_api/fetchBlocks'; import { useAppSelector } from '@_store'; import { useParams } from 'next/navigation'; import { Spin } from 'antd'; +import { reloadBlockListData } from '@/app/actions'; export enum pageType { first, @@ -82,6 +83,9 @@ export default function BlockList({ SSRData }) { chianId: chain, }); }, [chain, timeFormat]); + useEffect(() => { + reloadBlockListData(); + }, []); const pageMaxBlock = data[0]?.blockHeight; const pageMinBlock = data[data.length - 1]?.blockHeight; diff --git a/src/app/[chain]/blocks/layout.tsx b/src/app/[chain]/blocks/layout.tsx new file mode 100644 index 00000000..1ad5b9a4 --- /dev/null +++ b/src/app/[chain]/blocks/layout.tsx @@ -0,0 +1,3 @@ +export default function Layout({ children }) { + return
{children}
; +} diff --git a/src/app/[chain]/blocks/loading.tsx b/src/app/[chain]/blocks/loading.tsx new file mode 100644 index 00000000..2b09afda --- /dev/null +++ b/src/app/[chain]/blocks/loading.tsx @@ -0,0 +1,7 @@ +'use client'; +import { useIsGovernance } from '@_hooks/useIsPath'; +import { Skeleton } from 'antd'; +export default function Loading() { + const isGovernance = useIsGovernance(); + return !isGovernance && ; +} diff --git a/src/app/[chain]/blocks/page.tsx b/src/app/[chain]/blocks/page.tsx index 3fc427b8..75cf7ec2 100644 --- a/src/app/[chain]/blocks/page.tsx +++ b/src/app/[chain]/blocks/page.tsx @@ -1,5 +1,6 @@ import { fetchServerBlocks } from '@_api/fetchBlocks'; import BlockList from './blockList'; + export default async function BlocksPage({ params }) { const data = await fetchServerBlocks({ chainId: params.chain || 'AELF', @@ -8,5 +9,3 @@ export default async function BlocksPage({ params }) { }); return ; } -export const revalidate = 1; -export const dynamic = 'force-dynamic'; diff --git a/src/app/[chain]/token/[tokenSymbol]/layout.tsx b/src/app/[chain]/token/[tokenSymbol]/layout.tsx new file mode 100644 index 00000000..1ad5b9a4 --- /dev/null +++ b/src/app/[chain]/token/[tokenSymbol]/layout.tsx @@ -0,0 +1,3 @@ +export default function Layout({ children }) { + return
{children}
; +} diff --git a/src/app/[chain]/token/[tokenSymbol]/loading.tsx b/src/app/[chain]/token/[tokenSymbol]/loading.tsx new file mode 100644 index 00000000..2b09afda --- /dev/null +++ b/src/app/[chain]/token/[tokenSymbol]/loading.tsx @@ -0,0 +1,7 @@ +'use client'; +import { useIsGovernance } from '@_hooks/useIsPath'; +import { Skeleton } from 'antd'; +export default function Loading() { + const isGovernance = useIsGovernance(); + return !isGovernance && ; +} diff --git a/src/app/[chain]/tokens/layout.tsx b/src/app/[chain]/tokens/layout.tsx new file mode 100644 index 00000000..1ad5b9a4 --- /dev/null +++ b/src/app/[chain]/tokens/layout.tsx @@ -0,0 +1,3 @@ +export default function Layout({ children }) { + return
{children}
; +} diff --git a/src/app/[chain]/tokens/loading.tsx b/src/app/[chain]/tokens/loading.tsx new file mode 100644 index 00000000..2b09afda --- /dev/null +++ b/src/app/[chain]/tokens/loading.tsx @@ -0,0 +1,7 @@ +'use client'; +import { useIsGovernance } from '@_hooks/useIsPath'; +import { Skeleton } from 'antd'; +export default function Loading() { + const isGovernance = useIsGovernance(); + return !isGovernance && ; +} diff --git a/src/app/[chain]/tx/[hash]/layout.tsx b/src/app/[chain]/tx/[hash]/layout.tsx new file mode 100644 index 00000000..1ad5b9a4 --- /dev/null +++ b/src/app/[chain]/tx/[hash]/layout.tsx @@ -0,0 +1,3 @@ +export default function Layout({ children }) { + return
{children}
; +} diff --git a/src/app/[chain]/tx/[hash]/loading.tsx b/src/app/[chain]/tx/[hash]/loading.tsx new file mode 100644 index 00000000..2b09afda --- /dev/null +++ b/src/app/[chain]/tx/[hash]/loading.tsx @@ -0,0 +1,7 @@ +'use client'; +import { useIsGovernance } from '@_hooks/useIsPath'; +import { Skeleton } from 'antd'; +export default function Loading() { + const isGovernance = useIsGovernance(); + return !isGovernance && ; +} diff --git a/src/app/actions.ts b/src/app/actions.ts new file mode 100644 index 00000000..b92a79f3 --- /dev/null +++ b/src/app/actions.ts @@ -0,0 +1,7 @@ +'use server'; + +import { revalidatePath } from 'next/cache'; + +export async function reloadBlockListData() { + revalidatePath('/[chain]/blocks'); +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 3e029540..8d7c29fa 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -21,11 +21,15 @@ import StyleRegistry from './StyleRegistry'; import { fetchCMS } from '@_api/fetchCMS'; import { PublicEnvProvider } from 'next-runtime-env'; import type { Viewport } from 'next'; -import { revalidatePath } from 'next/cache'; export const metadata: Metadata = { title: 'AELF Block Explorer', description: 'AELF explorer', + icons: { + icon: '/favicon.ico', + shortcut: '/favicon.ico', + apple: '/favicon.ico', + }, }; async function fetchData() { await new Promise((resolve) => setTimeout(resolve, 1000)); @@ -38,7 +42,6 @@ async function fetchData() { } export default async function RootLayout({ children }: { children: React.ReactNode }) { - revalidatePath('/', 'layout'); const data = await fetchData(); const { price, previousPrice } = data; const headersList = headers(); @@ -46,9 +49,6 @@ export default async function RootLayout({ children }: { children: React.ReactNo const { headerMenuList, footerMenuList, chainList, networkList } = await fetchCMS(); return ( - - -