11import { ConfigProvider , Popover } from 'antd' ;
22import classNames from 'classnames' ;
33import { useTranslation } from '../../lib/i18n' ;
4- import React , { useCallback , useState } from 'react' ;
4+ import { useEffect , useState } from 'react' ;
55import ANTV_LINKS from '../../data/project-card-popover.json' ;
66import { ActiveIcon , ModuleTitle as Title } from '../common' ;
77import { type ProductType , getProducts } from '../../lib/products' ;
88import { transformUrl } from '../../lib/urls' ;
99
10- // 锚点, 用于 banner 中的 开始使用跳转
11- export const ANCHORNAME = 'linkChartsAnchorName' ;
12-
13- type PrejectData = {
10+ type ProductCardData = {
1411 // 标题
1512 title : string ;
1613 // 二级表图
@@ -27,19 +24,13 @@ type PrejectData = {
2724 icon ?: string ;
2825 // 跳转链接
2926 url ?: string ;
30- hash ?: {
31- // 弹出框 图表示例跳转链接
32- examples : string ;
33- // 弹出框 使用文档 跳转到 api
34- manual : string ;
35- } ;
36- } [ ] [ ] ;
27+ } ;
3728
3829// 产品布局和样式由组件维护。
3930const chartCardClasses =
4031 'h-[92px] mb-3 flex-1 flex-col bg-[rgba(245,140,88,0.15)] hover:bg-[rgba(245,140,88,0.25)] hover:border-[#f58c58]' ;
4132
42- const PROJECT_DATAS : PrejectData = [
33+ const PROJECT_DATAS : ProductCardData [ ] [ ] = [
4334 [
4435 {
4536 title : 'AVA' ,
@@ -196,7 +187,7 @@ export function ProjectCard() {
196187 const { locale : language , t : useT } = useTranslation ( ) ;
197188
198189 // 旧的跳转 json 获取
199- React . useEffect ( ( ) => {
190+ useEffect ( ( ) => {
200191 let active = true ;
201192 getProducts ( { language } )
202193 . then ( ( data ) => {
@@ -212,66 +203,63 @@ export function ProjectCard() {
212203 } , [ language ] ) ;
213204
214205 // 弹出框内容
215- const getContent = useCallback (
216- ( { title, subTitle, img, links, url } ) => {
217- return (
218- < div className = "font-sans px-2" >
219- < div className = "flex items-center tracking-normal" >
220- < div className = "font-semibold text-[20px] text-[#1d2129] mr-[6px]" >
221- { title }
222- </ div >
223- < div className = "text-[14px] text-[#86909c]" > { subTitle } </ div >
206+ const getContent = ( { title, subTitle, img, links, url } ) => {
207+ return (
208+ < div className = "font-sans px-2" >
209+ < div className = "flex items-center tracking-normal" >
210+ < div className = "font-semibold text-[20px] text-[#1d2129] mr-[6px]" >
211+ { title }
224212 </ div >
225- < div
226- className = "h-[125px] w-[274px] border border-solid border-[#d8d8d8] bg-white rounded-sm my-3 bg-center bg-no-repeat bg-contain"
227- style = { { backgroundImage : `url(${ img } )` } }
228- />
229- < div className = "flex items-center justify-between w-[274px]" >
230- { ANTV_LINKS . map ( ( link ) => {
231- let href = links [ link . href ] ?. url ?. replace (
232- / h t t p s : \/ \/ .+ ?\/ / ,
233- `${ url } /` ,
234- ) ;
213+ < div className = "text-[14px] text-[#86909c]" > { subTitle } </ div >
214+ </ div >
215+ < div
216+ className = "h-[125px] w-[274px] border border-solid border-[#d8d8d8] bg-white rounded-sm my-3 bg-center bg-no-repeat bg-contain"
217+ style = { { backgroundImage : `url(${ img } )` } }
218+ />
219+ < div className = "flex items-center justify-between w-[274px]" >
220+ { ANTV_LINKS . map ( ( link ) => {
221+ let href = links [ link . href ] ?. url ?. replace (
222+ / h t t p s : \/ \/ .+ ?\/ / ,
223+ `${ url } /` ,
224+ ) ;
235225
236- // Ant Design Charts 本身跳转 https://charts.ant.design/example 为 404, 修改为 https://ant-design-charts.antgroup.com/examples
237- if ( title === 'Ant Design Charts' ) {
238- href =
239- link . href === 'home'
240- ? url
241- : `${ url } /${ language } /${
242- {
243- example : 'examples' ,
244- api : 'options/plots/overview' ,
245- } [ link . href ]
246- } `;
247- }
248- if ( href && title === 'F6' && link . href === 'api' ) {
249- href = href + '/Graph' ;
250- }
226+ // Ant Design Charts 本身跳转 https://charts.ant.design/example 为 404, 修改为 https://ant-design-charts.antgroup.com/examples
227+ if ( title === 'Ant Design Charts' ) {
228+ href =
229+ link . href === 'home'
230+ ? url
231+ : `${ url } /${ language } /${
232+ {
233+ example : 'examples' ,
234+ api : 'options/plots/overview' ,
235+ } [ link . href ]
236+ } `;
237+ }
238+ if ( href && title === 'F6' && link . href === 'api' ) {
239+ href = href + '/Graph' ;
240+ }
251241
252- return (
253- < ActiveIcon
254- key = { link . href }
255- href = { href || transformUrl ( { url, language } ) }
256- target = "_blank"
257- className = "text-[14px] text-[#1d2129] [&>img]:w-4 [&>img]:h-4 hover:text-[#691eff]"
258- img = { link . img }
259- text = { useT ( link . text ) }
260- activeImg = { link . activeImg }
261- />
262- ) ;
263- } ) }
264- </ div >
242+ return (
243+ < ActiveIcon
244+ key = { link . href }
245+ href = { href || transformUrl ( { url, language } ) }
246+ target = "_blank"
247+ className = "text-[14px] text-[#1d2129] [&>img]:w-4 [&>img]:h-4 hover:text-[#691eff]"
248+ img = { link . img }
249+ text = { useT ( link . text ) }
250+ activeImg = { link . activeImg }
251+ />
252+ ) ;
253+ } ) }
265254 </ div >
266- ) ;
267- } ,
268- [ language ] ,
269- ) ;
255+ </ div >
256+ ) ;
257+ } ;
270258
271259 return (
272260 < div
273261 className = "flex items-center justify-center pt-20 pb-10 flex-col h-auto overflow-hidden font-sans tablet:px-6 mobile:pt-12 mobile:px-5 mobile:pb-6"
274- id = { ANCHORNAME }
262+ id = "linkChartsAnchorName"
275263 >
276264 < Title
277265 title = { useT ( '设计语言与研发框架' ) }
0 commit comments