From adba3cdbc8eafedaf29928a1869c6a35d13b44ca Mon Sep 17 00:00:00 2001 From: likaiqiang Date: Fri, 29 Mar 2024 17:32:32 +0800 Subject: [PATCH] feat: Empty is displayed when the data is empty, and the problem of the login button not responding is fixed. --- src/app/[locale]/agent/components/index.tsx | 87 ++++++++++++--------- src/app/[locale]/agent/page.tsx | 4 +- src/app/[locale]/agent/type.ts | 28 +++++++ 3 files changed, 81 insertions(+), 38 deletions(-) create mode 100644 src/app/[locale]/agent/type.ts diff --git a/src/app/[locale]/agent/components/index.tsx b/src/app/[locale]/agent/components/index.tsx index 5ca8989..f605e33 100644 --- a/src/app/[locale]/agent/components/index.tsx +++ b/src/app/[locale]/agent/components/index.tsx @@ -2,22 +2,19 @@ import { FireOutlined } from '@ant-design/icons'; import { sdk as bff } from '@yuntijs/arcadia-bff-sdk'; -import { Avatar, Button, Col, Row, Spin, Tooltip } from 'antd'; +import { Avatar, Button, Col, Empty, Row, Spin, Tooltip } from 'antd'; import classNames from 'classnames'; import { useTranslations } from 'next-intl'; +import { useRouter } from 'next/navigation'; // import { useRouter } from 'next/navigation'; import React, { useEffect, useState } from 'react'; +import { AgentProps, GPTNode } from '@/app/[locale]/agent/type'; import TitleCom from '@/components/Title'; import TagContent from './TagContent'; import { useStyles } from './styles'; -interface AgentProps { - agentData?: any; - TZH_AGENT_CATEGORY: string[]; -} - const layout = { xs: { span: 24, @@ -55,22 +52,31 @@ const Agent = React.memo(({ agentData, TZH_AGENT_CATEGORY }) => { }, { fallbackData: agentData } ); - // const router = useRouter(); + + const router = useRouter(); // const searchParams = useSearchParams() useEffect(() => { // console.log(searchParams.get('classification')) }, []); - const handleSelectTagChange = tag => { + const handleSelectTagChange = (tag: string) => { setSelectedTags(tag); }; - + const nodes = (ListData?.GPT?.listGPT?.nodes || []) as GPTNode[]; return (
{t('index.dengLu')}} + extra={ + + } isLeftTitle title={t('index.faXianAIZhi')} /> @@ -84,34 +90,41 @@ const Agent = React.memo(({ agentData, TZH_AGENT_CATEGORY }) => {
- {(ListData?.GPT?.listGPT?.nodes || []) - .filter(item => item.category.includes(selectedTag)) - .map((item, index) => ( - - -
- -
-
diff --git a/src/app/[locale]/agent/page.tsx b/src/app/[locale]/agent/page.tsx index f16ff6e..2a53563 100644 --- a/src/app/[locale]/agent/page.tsx +++ b/src/app/[locale]/agent/page.tsx @@ -5,6 +5,8 @@ import React from 'react'; import { AGENT_CATEGORY_INDEXES } from '@/utils/constants'; +import { AgentData } from '@/app/[locale]/agent/type'; + import Agent from './components'; export default async function Page() { @@ -22,7 +24,7 @@ export default async function Page() { const TZH_AGENT_CATEGORY = AGENT_CATEGORY_INDEXES.map(item => t_zh(item)); return ( - + ); } diff --git a/src/app/[locale]/agent/type.ts b/src/app/[locale]/agent/type.ts new file mode 100644 index 0000000..959b533 --- /dev/null +++ b/src/app/[locale]/agent/type.ts @@ -0,0 +1,28 @@ +import { ListGpTsQuery } from '@yuntijs/arcadia-bff-sdk'; + +export type GPTNode = { + __typename?: 'GPT'; + name?: string | null; + displayName?: string | null; + description?: string | null; + hot?: any | null; + creator?: string | null; + category?: Array | null; + icon?: string | null; + prologue?: string | null; +}; + +export type AgentData = ListGpTsQuery & { + GPT?: { + __typename?: 'GPTQuery'; + listGPT: { + __typename?: 'PaginatedResult'; + nodes?: Array | null; + }; + } | null; +}; + +export interface AgentProps { + agentData?: AgentData; + TZH_AGENT_CATEGORY: string[]; +}