Skip to content

Commit 25ed224

Browse files
committed
Merge remote-tracking branch 'origin/master' into codex/fix-build-type-errors
2 parents 3efd17c + fb71939 commit 25ed224

4 files changed

Lines changed: 80 additions & 34 deletions

File tree

.github/workflows/nextLint.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Next Lint Check
2-
#
32

43
on: [push, pull_request]
54

@@ -8,26 +7,16 @@ jobs:
87
runs-on: ubuntu-latest
98

109
steps:
11-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v4
1211
- name: Setup Node.js
13-
uses: actions/setup-node@v1
12+
uses: actions/setup-node@v4
1413
with:
15-
node-version: '20' # Your node version, default 20 in 2024
16-
17-
- name: Cache node modules
18-
uses: actions/cache@v2
19-
env:
20-
cache-name: cache-node-modules
21-
with:
22-
path: ~/.npm
23-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
24-
restore-keys: |
25-
${{ runner.os }}-build-${{ env.cache-name }}-
26-
${{ runner.os }}-build-
27-
${{ runner.os }}-
14+
node-version: '20'
15+
cache: yarn
16+
cache-dependency-path: yarn.lock
2817

2918
- name: Install Dependencies
30-
run: yarn
19+
run: yarn install --frozen-lockfile
3120

3221
- name: Run ESLint
33-
run: yarn lint
22+
run: yarn lint

src/_api/fetchCMS.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
import request from '@_api';
2-
export async function fetchCMS() {
2+
3+
export interface ICMSChartImageGroup {
4+
[chartKey: string]: string | undefined;
5+
}
6+
7+
export interface ICMSChartImageConfig {
8+
[chainKey: string]: ICMSChartImageGroup | undefined;
9+
multi?: ICMSChartImageGroup;
10+
multiChain?: ICMSChartImageGroup;
11+
}
12+
13+
export interface IFetchCMSResult {
14+
headerMenuList: any[];
15+
footerMenuList: any[];
16+
chainList: any[];
17+
networkList: any[];
18+
config: Record<string, any>;
19+
chartImg?: ICMSChartImageConfig;
20+
}
21+
22+
export async function fetchCMS(): Promise<IFetchCMSResult> {
323
const result = await request.cms.getGlobalConfig({ params: { cache: 'no-store' } });
4-
const { data } = result;
24+
const { data } = result as { data: IFetchCMSResult };
525
return data;
626
}
727

src/app/[chain]/chart/page.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,30 @@
33
import { Anchor, Card } from 'antd';
44
import './index.css';
55
import Link from 'next/link';
6+
import { useEffect, useRef } from 'react';
67
import { useMobileContext } from '@app/pageProvider';
78
import PageAd from '@_components/PageAd';
89
import { ChartData, chartItems } from './type';
910
import { MULTI_CHAIN } from '@_utils/contant';
1011

12+
const DEFAULT_CHART_IMAGE = '/image/chart.svg';
13+
1114
export default function Page() {
1215
const { chartImg } = useMobileContext();
13-
const chainType = 'multi';
16+
const chainType = MULTI_CHAIN;
17+
const chartImgGroup = chartImg?.[chainType] ?? chartImg?.multi;
18+
const loggedMissingChartImgRef = useRef(false);
19+
20+
useEffect(() => {
21+
if (process.env.NODE_ENV === 'production') {
22+
return;
23+
}
24+
25+
if (!chartImgGroup && !loggedMissingChartImgRef.current) {
26+
console.warn('[chart] chartImg config is missing, using fallback chart preview image.');
27+
loggedMissingChartImgRef.current = true;
28+
}
29+
}, [chartImgGroup]);
1430

1531
return (
1632
<div className="chart-home-container mb-[-40px]">
@@ -30,6 +46,7 @@ export default function Page() {
3046
<div className="title text-ls mb-[10px] font-medium">{chartItem.title}</div>
3147
<ul className="grid items-stretch gap-5 min-[576px]:grid-cols-2 min-[1200px]:grid-cols-3">
3248
{chartItem.charts.map((chart) => {
49+
const chartPreviewSrc = chartImgGroup?.[chart.key] || DEFAULT_CHART_IMAGE;
3350
return (
3451
<li key={chart.path}>
3552
<Link href={`/${MULTI_CHAIN}${chart.path}`}>
@@ -39,8 +56,8 @@ export default function Page() {
3956
width={316}
4057
height={106}
4158
className="mx-auto block h-auto max-w-full"
42-
src={chartImg[chainType][chart.key]}
43-
alt="charts"></img>
59+
src={chartPreviewSrc}
60+
alt={chart.title}></img>
4461
</Card>
4562
</Link>
4663
</li>

src/app/pageProvider.tsx

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,39 @@
1010

1111
import { PREFIXCLS, THEME_CONFIG } from '@_lib/AntdThemeConfig';
1212
import { makeStore, AppStore } from '@_store';
13+
import type { ICMSChartImageConfig } from '@_api/fetchCMS';
1314
// import { wrapper } from '@_store';
14-
import { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
15+
import { createContext, useContext, useRef } from 'react';
1516
import { AELFDProvider } from 'aelf-design';
1617
import 'aelf-design/css';
1718
import { ConfigProvider } from 'antd';
1819
import { Provider as ReduxProvider } from 'react-redux';
19-
import useResponsive from '@_hooks/useResponsive';
20-
import dynamic from 'next/dynamic';
2120
import WebLoginProvider from './webLoginProvider';
2221
// const OpentelemetryProvider = dynamic(
2322
// () => import('./opentelemetryProvider').then((mod) => mod.OpentelemetryProvider),
2423
// { ssr: false },
2524
// );
2625

27-
const MobileContext = createContext<any>({});
26+
interface IMobileContextValue {
27+
isMobileSSR: boolean;
28+
config: Record<string, any>;
29+
chartImg?: ICMSChartImageConfig;
30+
}
31+
32+
interface IRootProviderProps {
33+
children: React.ReactNode;
34+
isMobileSSR: boolean;
35+
config: Record<string, any>;
36+
chartImg?: ICMSChartImageConfig;
37+
networkList: any[];
38+
headerMenuList: any[];
39+
chainList: any[];
40+
}
41+
42+
const MobileContext = createContext<IMobileContextValue>({
43+
isMobileSSR: false,
44+
config: {},
45+
});
2846
const HeaderContext = createContext<any>({});
2947

3048
const useMobileContext = () => {
@@ -35,18 +53,20 @@ const useHeaderContext = () => {
3553
};
3654
export { useMobileContext, useHeaderContext };
3755

38-
function RootProvider({ children, isMobileSSR, config, chartImg, networkList, headerMenuList, chainList }) {
56+
function RootProvider({
57+
children,
58+
isMobileSSR,
59+
config,
60+
chartImg,
61+
networkList,
62+
headerMenuList,
63+
chainList,
64+
}: IRootProviderProps) {
3965
const storeRef = useRef<AppStore>();
4066
if (!storeRef.current) {
4167
storeRef.current = makeStore();
4268
}
4369

44-
const [isMobile, setIsMobile] = useState(isMobileSSR);
45-
const { isMobile: isMobileClient } = useResponsive();
46-
useEffect(() => {
47-
setIsMobile(isMobileClient);
48-
}, [isMobileClient]);
49-
5070
return (
5171
<AELFDProvider prefixCls={PREFIXCLS} theme={THEME_CONFIG}>
5272
<ConfigProvider prefixCls={PREFIXCLS} theme={THEME_CONFIG}>

0 commit comments

Comments
 (0)