diff --git a/DigitalHumanWeb/locales/zh-CN/discover.json b/DigitalHumanWeb/locales/zh-CN/discover.json index 1a79ae1..632879f 100644 --- a/DigitalHumanWeb/locales/zh-CN/discover.json +++ b/DigitalHumanWeb/locales/zh-CN/discover.json @@ -19,6 +19,7 @@ "try": "试一下" }, "back": "返回发现", + "collectSuccess": "收藏成功", "category": { "assistant": { "all": "全部", diff --git a/DigitalHumanWeb/locales/zh-TW/discover.json b/DigitalHumanWeb/locales/zh-TW/discover.json index 130f8b9..b96b8a5 100644 --- a/DigitalHumanWeb/locales/zh-TW/discover.json +++ b/DigitalHumanWeb/locales/zh-TW/discover.json @@ -19,6 +19,7 @@ "try": "試一下" }, "back": "返回發現", + "collectSuccess": "收藏成功", "category": { "assistant": { "academic": "學術", diff --git a/DigitalHumanWeb/src/app/(main)/@nav/_layout/Desktop/TopActions.tsx b/DigitalHumanWeb/src/app/(main)/@nav/_layout/Desktop/TopActions.tsx index d98e20f..d2e6fd5 100644 --- a/DigitalHumanWeb/src/app/(main)/@nav/_layout/Desktop/TopActions.tsx +++ b/DigitalHumanWeb/src/app/(main)/@nav/_layout/Desktop/TopActions.tsx @@ -8,6 +8,7 @@ import { useGlobalStore } from '@/store/global'; import { SidebarTabKey } from '@/store/global/initialState'; import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig'; import { useSessionStore } from '@/store/session'; +import { useUserStore } from '@/store/user'; import { createStyles } from 'antd-style'; import {Button, Image} from "antd"; @@ -43,7 +44,13 @@ const TopActions = memo(({ tab }) => { const { showMarket, enableKnowledgeBase } = useServerConfigStore(featureFlagsSelectors); const { styles, cx } = useStyles() const [value, setValue] = useState("chat") - + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + console.log(userId,'3837373266262266') + const testFuc = (s: UserStore) => { + console.log(s,'999999999') + } + testFuc(useUserStore.getState()) return (
(({ tab }) => {
会话
{enableKnowledgeBase && ( - {setValue("/discover/assistants"); window.localStorage.setItem("nowChat", "")}}> + {setValue("/discover/assistants"); window.localStorage.setItem("nowChat", "")}}> {"files"}
助手
@@ -73,7 +80,7 @@ const TopActions = memo(({ tab }) => { )} {showMarket && ( - {setValue("/model"); window.localStorage.setItem("nowChat", "")}}> + {setValue("/model"); window.localStorage.setItem("nowChat", "")}}> {"model"}
模型
@@ -85,7 +92,7 @@ const TopActions = memo(({ tab }) => { )} {showMarket && ( - {setValue("/plugins"); window.localStorage.setItem("nowChat", "")}}> + {setValue("/plugins"); window.localStorage.setItem("nowChat", "")}}> {"plugins"}
插件
diff --git a/DigitalHumanWeb/src/app/(main)/_layout/Desktop.tsx b/DigitalHumanWeb/src/app/(main)/_layout/Desktop.tsx index 9f46b89..1eeb2b1 100644 --- a/DigitalHumanWeb/src/app/(main)/_layout/Desktop.tsx +++ b/DigitalHumanWeb/src/app/(main)/_layout/Desktop.tsx @@ -9,9 +9,7 @@ import { usePlatform } from '@/hooks/usePlatform'; import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig'; import { UserOutlined, SearchOutlined } from '@ant-design/icons'; import { LayoutProps } from './type'; -import { Divider, Input, Avatar } from "antd"; - -const { Search } = Input; +import { Divider, Avatar } from "antd"; const title = { "/chat": '会话', "/discover/assistants": "助手", @@ -25,6 +23,7 @@ const title = { const useStyles = createStyles(({ css, token }) => ({ topCenten: css` width: 100%; + line-height: 60px; background: #FFFFFF; box-sizing: border-box; /* 分割线颜色 */ @@ -38,7 +37,7 @@ const useStyles = createStyles(({ css, token }) => ({ display: inline-block `, dividerCen: css` - width: 2px; + width: 1px; height: 26px; background-color: #d8d8d8; margin: 8px 16px; @@ -48,8 +47,8 @@ const useStyles = createStyles(({ css, token }) => ({ display: inline-block; `, nameSpn: css` - margin-right: 80px; - margin-left: 8px; + margin-right: 16px; + margin-left: 18px; display: inline-block; `, serchIcon: css` @@ -71,9 +70,9 @@ const Layout = memo(({ children, nav }) => { const { isPWA } = usePlatform(); const theme = useTheme(); const { styles, cx } = useStyles() - + console.log(window?.location?.pathname,'3837373666router--------------------------------------------') const { showCloudPromotion } = useServerConfigStore(featureFlagsSelectors); - + const pathName = window?.location?.pathname return ( <> {showCloudPromotion && } @@ -87,7 +86,20 @@ const Layout = memo(({ children, nav }) => { width={'100%'} > {nav} - {children} +
+
+
+ 集智AI + + {title[pathName]} +
+
+ } /> + 张末末 +
+
+ {children} +
); diff --git a/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/features/Actions.tsx b/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/features/Actions.tsx index 1ecf923..0221ebb 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/features/Actions.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/features/Actions.tsx @@ -17,17 +17,8 @@ interface AssistantActionProps extends FlexboxProps { const AssistantAction = memo(({ identifier, data }) => { return ( - + - ); }); diff --git a/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/features/Header.tsx b/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/features/Header.tsx index b72efb1..f2908cf 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/features/Header.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/features/Header.tsx @@ -13,9 +13,8 @@ import { Flexbox } from 'react-layout-kit'; import urlJoin from 'url-join'; import { useRouter } from 'next/navigation'; import { DiscoverAssistantItem } from '@/types/discover'; - +import { useUserStore } from '@/store/user'; import GitHubAvatar from '../../../../components/GitHubAvatar'; -import Back from '../../../features/Back'; import Actions from './Actions'; export const useStyles = createStyles(({ css, token }) => ({ tag: css` @@ -48,8 +47,8 @@ export const useStyles = createStyles(({ css, token }) => ({ `, conTitle: css` width: 125px; - height: 50px; - line-height: 50px; + height: 40px; + line-height: 40px; text-align: center; color: #fff; font-size: 20px; @@ -59,9 +58,11 @@ export const useStyles = createStyles(({ css, token }) => ({ `, description: css` padding: 0 45px; + margin-top: 10px; `, tag: css` padding: 0px 45px; + margin-bottom: 10px; `, })); @@ -75,8 +76,10 @@ const Header = memo(({ identifier, data, mobile }) => { const { styles, theme } = useStyles(); const router = useRouter() const { t } = useTranslation('discover'); + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) const handleBack = () => { - router.push('/discover/assistants?userid=' + localStorage.getItem('userId')) + router.push('/discover/assistants?userid=' + userId) } return ( @@ -118,17 +121,9 @@ const Header = memo(({ identifier, data, mobile }) => { {data.meta.tags && ( {data.meta.tags.map((tag) => ( - - - {startCase(tag).trim()} - - + + {startCase(tag).trim()} + ))} )} diff --git a/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/page.tsx index fb1b2ff..d4c0efb 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(detail)/assistant/[slug]/page.tsx @@ -11,9 +11,9 @@ import { DiscoverPlugintem } from '@/types/discover'; import { isMobileDevice } from '@/utils/responsive'; import DetailLayout from '../../features/DetailLayout'; -import Actions from './features/Actions'; +// import Actions from './features/Actions'; import Header from './features/Header'; -import InfoSidebar from './features/InfoSidebar'; +// import InfoSidebar from './features/InfoSidebar'; import Temp from './features/Temp'; // import ConversationExample from './features/ConversationExample'; diff --git a/DigitalHumanWeb/src/app/(main)/discover/(detail)/features/DetailLayout.tsx b/DigitalHumanWeb/src/app/(main)/discover/(detail)/features/DetailLayout.tsx index efea29f..cd34cbe 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(detail)/features/DetailLayout.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(detail)/features/DetailLayout.tsx @@ -40,17 +40,10 @@ const DetailLayout = memo(
{header} - + {children}
- - - {actions} - {statistics} - - {sidebar} -
diff --git a/DigitalHumanWeb/src/app/(main)/discover/(detail)/features/HighlightBlock.tsx b/DigitalHumanWeb/src/app/(main)/discover/(detail)/features/HighlightBlock.tsx index f3daa22..79c6554 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(detail)/features/HighlightBlock.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(detail)/features/HighlightBlock.tsx @@ -61,7 +61,7 @@ const HighlightBlock = memo(({ avatar, title, icon, childre const { styles } = useStyles(); const mobile = useServerConfigStore((s) => s.isMobile); return ( - + ({ font-weight: bold; line-height: 1.2; `, + top: css` + padding: 20px 0px; + box-sizing: border-box; + border-width: 0px 0px 2px 0px; + border-style: solid; + border-color: rgba(187, 204, 253, 0.24); + padding: 20px 50px; + `, + topBtn: css` + border-radius: 20px; + color: #2E62FF; + border: 1px solid #2E62FF; + `, + conTitle: css` + width: 125px; + height: 40px; + line-height: 40px; + text-align: center; + color: #fff; + font-size: 20px; + border-radius: 0px 129px 129px 0px; + opacity: 1; + background: linear-gradient(270deg, #2D65FF 0%, rgba(0, 166, 255, 0.52) 99%); + `, + description: css` + padding: 0 45px; + margin-top: 10px; + `, + tag: css` + padding: 0px 45px; + margin-bottom: 10px; + `, })); interface HeaderProps { @@ -39,12 +72,16 @@ interface HeaderProps { const Header = memo(({ identifier, data, mobile }) => { const { styles, theme } = useStyles(); + const router = useRouter() const { t } = useTranslation(['discover', 'models']); - + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + const handleBack = () => { + router.push('/discover/models?userid=' + userId) + } return ( - {!mobile && } - + @@ -64,20 +101,20 @@ const Header = memo(({ identifier, data, mobile }) => { {!mobile && ( - - - + )} - {data.meta.description &&
{t(`${identifier}.description`, { ns: 'models' })}
} - +
简介
+ {data.meta.description &&
{t(`${identifier}.description`, { ns: 'models' })}
} +
+ +
+
参数
); }); diff --git a/DigitalHumanWeb/src/app/(main)/discover/(detail)/model/[...slugs]/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(detail)/model/[...slugs]/page.tsx index 526ebd6..faa5284 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(detail)/model/[...slugs]/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(detail)/model/[...slugs]/page.tsx @@ -95,10 +95,10 @@ const Page = async ({ params, searchParams }: Props) => { <> } + // actions={} header={
} mobile={mobile} - sidebar={} + // sidebar={} /* ↓ cloud slot ↓ */ /* ↑ cloud slot ↑ */ diff --git a/DigitalHumanWeb/src/app/(main)/discover/(detail)/plugin/[slug]/features/Header.tsx b/DigitalHumanWeb/src/app/(main)/discover/(detail)/plugin/[slug]/features/Header.tsx index 244d573..baefeb6 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(detail)/plugin/[slug]/features/Header.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(detail)/plugin/[slug]/features/Header.tsx @@ -11,11 +11,11 @@ import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import { Flexbox } from 'react-layout-kit'; import urlJoin from 'url-join'; - +import { useUserStore } from '@/store/user'; +import { useRouter } from 'next/navigation'; import { DiscoverPlugintem } from '@/types/discover'; import Back from '../../../features/Back'; - export const useStyles = createStyles(({ css, token }) => ({ tag: css` color: ${token.colorTextSecondary}; @@ -32,6 +32,38 @@ export const useStyles = createStyles(({ css, token }) => ({ font-weight: bold; line-height: 1.2; `, + top: css` + padding: 20px 0px; + box-sizing: border-box; + border-width: 0px 0px 2px 0px; + border-style: solid; + border-color: rgba(187, 204, 253, 0.24); + padding: 20px 50px; + `, + topBtn: css` + border-radius: 20px; + color: #2E62FF; + border: 1px solid #2E62FF; + `, + conTitle: css` + width: 125px; + height: 40px; + line-height: 40px; + text-align: center; + color: #fff; + font-size: 20px; + border-radius: 0px 129px 129px 0px; + opacity: 1; + background: linear-gradient(270deg, #2D65FF 0%, rgba(0, 166, 255, 0.52) 99%); + `, + description: css` + padding: 0 45px; + margin-top: 10px; + `, + tag: css` + padding: 0px 45px; + margin-bottom: 10px; + `, })); interface HeaderProps { @@ -42,12 +74,16 @@ interface HeaderProps { const Header = memo(({ identifier, data, mobile }) => { const { styles, theme } = useStyles(); + const router = useRouter() const { t } = useTranslation('discover'); - + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + const handleBack = () => { + router.push('/discover/plugins?userid=' + userId) + } return ( - {!mobile && } - + (({ identifier, data, mobile }) => { {!mobile && ( - - - - {data.meta?.category && ( - <> - - - - - - )} + )} -
{data.meta.description}
- {data.meta.tags && ( - - {data.meta.tags.map((tag) => ( - - - {startCase(tag).trim()} - - - ))} - - )} +
简介
+
{data.meta.description}
+
+ {data.meta.tags && ( + + {data.meta.tags.map((tag) => ( + + {startCase(tag).trim()} + + ))} + + )} +
+
参数
); }); diff --git a/DigitalHumanWeb/src/app/(main)/discover/(detail)/plugin/[slug]/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(detail)/plugin/[slug]/page.tsx index 16e26df..14710d0 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(detail)/plugin/[slug]/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(detail)/plugin/[slug]/page.tsx @@ -84,10 +84,10 @@ const Page = async ({ params, searchParams }: Props) => { <> } + // actions={} header={
} mobile={mobile} - sidebar={} + // sidebar={} /* ↓ cloud slot ↓ */ /* ↑ cloud slot ↑ */ diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/[slug]/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/[slug]/page.tsx index 9199203..6a69e32 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/[slug]/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/[slug]/page.tsx @@ -32,45 +32,7 @@ const Page = async ({ params, searchParams }: Props) => { const mobile = isMobileDevice(); const discoverService = new DiscoverService(); console.log(params.slug,3333333) - let items; - if(params.slug == "collect") { - const res = await request({ - url: "/flxai/api/robot/appaiassistant/getAllAiAssistant", - method: "get", - params: { - userid: searchParams.userid - } - }) - items = res.data; - items = items.map((item,index)=> { - item.classify = 'collect'; - return item - }) - } else { - const res = await request({ - url: "/flxai/api/robot/appaiassistant/getAllAiAssistant", - method: "get", - params: { - userid: searchParams.userid - } - }) - const array2Object = {}; - res?.data?.forEach(item => { - array2Object[item.identifier] = item; - }); - items = await discoverService.getAssistantCategory(locale, params.slug); - items = items.map((item,index)=> { - const matchingItem = array2Object[item.identifier]; - if (matchingItem) { - console.log('3838383838',matchingItem); - matchingItem.status = '1'; - return matchingItem - } else { - item.status = '0'; - return item - } - }) - } + const items = await discoverService.getAssistantCategory(locale, params.slug); console.log(8272772727,items) const ld = ldModule.generate({ description: t('discover.assistants.description'), diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/Card.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/Card.tsx index bef4913..309b3f4 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/Card.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/Card.tsx @@ -13,6 +13,8 @@ import CardBanner from '../../../components/CardBanner'; import GitHubAvatar from '../../../components/GitHubAvatar'; import { useCategoryItem } from '../../assistants/features/useCategory'; import { StarOutlined } from '@ant-design/icons'; +import { useUserStore } from '@/store/user'; +import { useTranslation } from 'react-i18next'; const Link = dynamic(() => import('next/link'), { loading: () => , ssr: false, @@ -80,12 +82,15 @@ const AssistantCard = memo( const { avatar, title, description, tags = [], category } = meta; const { createAt,homepage,identifier,schemaVersion,status,classify } = {...rest} const { cx, styles, theme } = useStyles(); + const { t } = useTranslation('discover'); const { message } = App.useApp(); const categoryItem = useCategoryItem(category, 12); const isCompact = variant === 'compact'; + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) // console.log(tags,avatar,author,9383737) - console.log(status,9999999999) - const [val, setVal] = useState(status) + console.log(userId,9999999999) + const [val, setVal] = useState('') const handleCollect = (e) => { console.log(e,8844848) e.preventDefault() @@ -102,7 +107,7 @@ const AssistantCard = memo( "title": title, "category": category, "schemaVersion": schemaVersion, - "userid": localStorage.getItem('userId'), + "userid": userId, } request({ url: "/flxai/api/robot/appaiassistant", @@ -111,7 +116,7 @@ const AssistantCard = memo( }).then(response => { console.log(response,222222222) if (response.code == 0) { - message.success('收藏成功') + message.success(t('collectSuccess')); setVal("1") } }).catch(error => { @@ -131,7 +136,7 @@ const AssistantCard = memo( ); const renderElement = () => { if (classify != 'collect') { - if(val == "1") { + if(status == "1" || val == "1") { return
{e.stopPropagation()}}>
} else { return
handleCollect(e)}>
diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/Category.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/Category.tsx index 9e9745f..4b8a2cd 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/Category.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/Category.tsx @@ -7,7 +7,7 @@ import urlJoin from 'url-join'; import { useQueryRoute } from '@/hooks/useQueryRoute'; import { AssistantCategory } from '@/types/discover'; - +import { useUserStore } from '@/store/user'; import CategoryMenu from '../../../components/CategoryMenu'; import { useCategory } from './useCategory'; @@ -21,7 +21,9 @@ const Category = memo(() => { return 'all'; }, [pathname]); const router = useQueryRoute(); - + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + console.log(userId,'category333333') return ( ({ @@ -30,7 +32,7 @@ const Category = memo(() => { diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/List.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/List.tsx index 8a66fed..edd538d 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/List.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/features/List.tsx @@ -3,7 +3,7 @@ import { Grid } from '@lobehub/ui'; import {Button, Empty, Image, Tag} from 'antd'; import Link from 'next/link'; -import {memo, useMemo, useState} from 'react'; +import {memo, useMemo, useEffect, useState} from 'react'; import { useTranslation } from 'react-i18next'; import urlJoin from 'url-join'; import { useRouter } from 'next/navigation'; @@ -13,8 +13,8 @@ import SearchResultCount from '../../../components/SearchResultCount'; import Title from '../../../components/Title'; import VirtuosoGridList from '../../../components/VirtuosoGridList'; import Card from './Card'; -import {createStyles} from "antd-style"; - +import request from '@/app/api/request'; +import { useUserStore } from '@/store/user'; export interface ListProps { category?: string; items?: DiscoverAssistantItem[]; @@ -22,133 +22,69 @@ export interface ListProps { searchKeywords?: string; } -const useStyles = createStyles(({css, token}) => ({ - top: css` - padding: 20px 0px; - box-sizing: border-box; - border-width: 0px 0px 2px 0px; - border-style: solid; - border-color: rgba(187, 204, 253, 0.24); - padding: 20px 50px; - `, - topFirAc: css` - width: 86px; - height: 86px; - display: inline-block; - border-radius: 86px; - border: 4px solid #6D94FF; - `, - topSecAc: css` - width: 60px; - height: 60px; - border-radius: 60px; - margin: 9px; - text-align: center; - line-height: 50px; - font-size: 26px; - border: 4px solid #6D94FF; - `, - topBtn: css` - border-radius: 20px; - color: #2E62FF; - border: 1px solid #2E62FF; - `, - topRight: css` - width: 50%; - text-align: right; - display: inline-block - `, - topLeft: css` - width: 50%; - display: inline-block - `, - title: css` - display: inline-block; - vertical-align: middle; - margin-top: -10px; - margin-left: 25px - `, - des: css` - margin-top: 5px; - font-size: 12px; - color: #999 - `, - desImg: css` - margin: 0px 5px; - width: 20px - `, - time: css` - display: inline-block; - margin-left: 5px - `, - conTitle: css` - margin: 12px 0; - width: 125px; - height: 50px; - line-height: 50px; - text-align: center; - color: #fff; - font-size: 20px; - border-radius: 0px 129px 129px 0px; - opacity: 1; - background: linear-gradient(270deg, #2D65FF 0%, rgba(0, 166, 255, 0.52) 99%); - `, - description: css` - padding: 20px 50px; - `, - tag: css` - padding: 0px 50px; - margin-bottom: 20px; - `, - set: css` - padding: 0px 30px 20px; - `, - setBtn: css` - background: #EDF2FF; - width: 80px; - border-radius: 40px; - color: #0044FF; - `, - setText: css` - padding: 0px 50px 20px; - `, - setOl: css` - display: inline-block; - width: 8px; - height: 8px; - background: #0044FF; - margin-right: 10px; - `, - rwDes: css` - padding: 0px 70px 20px; - `, -})) - const List = memo(({ category, mobile, searchKeywords, items = [] }) => { const { t } = useTranslation('discover'); - const { styles, cx } = useStyles() const router = useRouter() + const [stData, setStData] = useState(items) + const recentLength = mobile ? 4 : 8; + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + console.log(userId,'zhushou---3837373266262266') + console.log('zhushou--------------',items) const { all, recent, last } = useMemo(() => { - const recentLength = mobile ? 4 : 8; return { - all: items, - last: items.slice(recentLength), - recent: items.slice(0, recentLength), + all: stData, + last: stData.slice(recentLength), + recent: stData.slice(0, recentLength), + }; + }, [stData, mobile]); + useEffect(() => { + const fetchData = async() => { + if(category == "collect") { + const res = await request({ + url: "/flxai/api/robot/appaiassistant/getAllAiAssistant", + method: "get", + params: { + userid: userId + } + }) + setStData(res?.data.map((item,index)=> { + item.classify = 'collect'; + return item + })) + } else { + const res = await request({ + url: "/flxai/api/robot/appaiassistant/getAllAiAssistant", + method: "get", + params: { + userid: userId + } + }) + const array2Object = {}; + res?.data?.forEach((item) => { + array2Object[item.identifier] = item; + }); + console.log('chajian22222222222222222222222222222--------------') + setStData(stData.map((item,index)=> { + const matchingItem = array2Object[item.identifier]; + if (matchingItem) { + matchingItem.status = '1'; + return matchingItem + } else { + item.status = '0'; + return item + } + })) + } }; - }, [items, mobile]); + fetchData(); + }, []); // 空数组[]意味着仅在组件挂载时调用一次 console.log(category,recent,last,92929292) - const [val, setVal] = useState("") - const handleClickCard = (item) => { console.log(item) - setVal(item) router.push(urlJoin('/discover/assistant/', item.identifier)) } - const handleBack = () => { - setVal("") - } - if (searchKeywords) { if (!items || items?.length === 0) return ; return ( diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/page.tsx index 8df5ea1..11797e7 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/assistants/page.tsx @@ -5,7 +5,6 @@ import { metadataModule } from '@/server/metadata'; import { DiscoverService } from '@/server/services/discover'; import { translation } from '@/server/translation'; import { isMobileDevice } from '@/utils/responsive'; -import request from '@/app/api/request'; import List from './features/List'; import urlJoin from 'url-join'; type Props = { searchParams: { hl?: Locales } }; @@ -27,31 +26,7 @@ const Page = async ({ searchParams }: Props) => { const mobile = isMobileDevice(); const discoverService = new DiscoverService(); console.log(searchParams,22222222222) - const res = await request({ - url: "/flxai/api/robot/appaiassistant/getAllAiAssistant", - method: "get", - params: { - userid: searchParams.userid - } - }) - console.log(res,4322222) - const array2Object = {}; - res?.data?.forEach(item => { - array2Object[item.identifier] = item; - }); - let items = await discoverService.getAssistantList(locale); - console.log(8272772727,'jiangxucong') - items = items.map((item,index)=> { - const matchingItem = array2Object[item.identifier]; - if (matchingItem) { - console.log('5959595959',matchingItem); - matchingItem.status = '1'; - return matchingItem - } else { - item.status = '0'; - return item - } - }) + const items = await discoverService.getAssistantList(locale); const ld = ldModule.generate({ description: t('discover.assistants.description'), title: t('discover.assistants.title'), diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/[slug]/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/[slug]/page.tsx index 5d967d8..4195e00 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/[slug]/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/[slug]/page.tsx @@ -9,14 +9,13 @@ import { DiscoverService } from '@/server/services/discover'; import { translation } from '@/server/translation'; import { AssistantCategory } from '@/types/discover'; import { isMobileDevice } from '@/utils/responsive'; - import List from '../features/List'; type Props = { params: { slug: AssistantCategory }; searchParams: { hl?: Locales } }; export const generateMetadata = async ({ params, searchParams }: Props) => { const { t, locale } = await translation('metadata', searchParams?.hl); - + console.log('jiangxucong---model----------------------------') const discoverService = new DiscoverService(); const list = await discoverService.getProviderList(locale); const cate = list.find((cate) => cate.identifier === params.slug); @@ -37,12 +36,12 @@ const Page = async ({ params, searchParams }: Props) => { const discoverService = new DiscoverService(); const list = await discoverService.getProviderList(locale); const cate = list.find((cate) => cate.identifier === params.slug); + console.log(params.slug,3333333) const items = await discoverService.getModelCategory(locale, params.slug); - const ld = ldModule.generate({ description: t('discover.models.description'), title: [cate?.meta.title, t('discover.models.title')].join(' · '), - url: urlJoin('/discover/models', params.slug), + url: urlJoin('/discover/models', params.slug + '?userid=' + searchParams.userid), webpage: { enable: true, search: '/discover/search', diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/Card.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/Card.tsx index 446057e..571aae5 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/Card.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/Card.tsx @@ -1,14 +1,14 @@ import { ModelIcon } from '@lobehub/icons'; -import { Typography } from 'antd'; +import { Typography, App } from 'antd'; import { createStyles } from 'antd-style'; -import { memo } from 'react'; +import { memo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Flexbox, FlexboxProps } from 'react-layout-kit'; - +import { useUserStore } from '@/store/user'; import { DiscoverModelItem } from '@/types/discover'; - +import { StarOutlined } from '@ant-design/icons'; import ModelFeatureTags from '../../../features/ModelFeatureTags'; - +import request from '@/app/api/request'; const { Paragraph, Title } = Typography; const useStyles = createStyles(({ css, token, isDarkMode }) => ({ @@ -65,17 +65,79 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({ token: css` font-family: ${token.fontFamilyCode}; `, + collectBtn: css` + font-size: 12px; + width: 20px; + height: 20px; + line-height: 20px; + border-radius: 50%; + background: #FFF3D9; + text-align: center; + `, })); export interface ModelCardProps extends DiscoverModelItem, FlexboxProps { showCategory?: boolean; } -const ModelCard = memo(({ className, meta, identifier, ...rest }) => { - const { description, title, functionCall, vision, tokens } = meta; +const ModelCard = memo(({ className, meta, socialData, identifier, ...rest }) => { + const { title, description, functionCall, vision, tokens, category, id, displayName, enabled } = meta; + const { conversations, likes, tokens: socialDataToken } = socialData; + // console.log(socialDataToken,"7373736262626----------------------------",meta) + const { createdAt, providers, suggestions, status, classify } = {...rest} const { t } = useTranslation('models'); + const { t:d } = useTranslation('discover'); const { cx, styles } = useStyles(); - + const { message } = App.useApp(); + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + const [val, setVal] = useState(status) + const handleCollect = (e) => { + console.log(e,8844848) + e.preventDefault() + e.stopPropagation() + const params = { + "identifier": identifier, + "metaId": id, + "displayname": displayName, + "description": description, + "title": title, + "conversations": conversations, + "enabled": enabled, + "metaTokens": tokens, + "createdAt": createdAt, + "tokens": socialDataToken, + "suggestions": suggestions.join(','), + "category": category, + "providers": providers.join(','), + "likes": likes, + "userid": userId, + } + request({ + url: "/flxai/api/robot/appaimodel", + method: "post", + data: params + }).then(response => { + console.log(response,222222222) + if (response.code == 0) { + message.success(d('collectSuccess')); + setVal("1") + } + }).catch(error => { + console.error('Error fetching data: ', error); + }) + } + const renderElement = () => { + if (classify != 'collect') { + if(val == "1") { + return
{e.stopPropagation()}}>
+ } else { + return
handleCollect(e)}>
+ } + } else { + return; + } + }; return ( (({ className, meta, identifier, ...rest } {t(`${identifier}.description`)} )} - - + + + {renderElement()} + ); diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/Category.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/Category.tsx index 23833b4..4256e1d 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/Category.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/Category.tsx @@ -4,13 +4,13 @@ import { ProviderIcon } from '@lobehub/icons'; import { Icon } from '@lobehub/ui'; import { MenuProps } from 'antd'; import { useTheme } from 'antd-style'; -import { LayoutPanelTop } from 'lucide-react'; +import { LayoutPanelTop,Star } from 'lucide-react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { memo, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import urlJoin from 'url-join'; - +import { useUserStore } from '@/store/user'; import { useQueryRoute } from '@/hooks/useQueryRoute'; import { DiscoverProviderItem } from '@/types/discover'; @@ -26,20 +26,26 @@ const Category = memo<{ data: DiscoverProviderItem[] }>(({ data }) => { }, [pathname]); const router = useQueryRoute(); const theme = useTheme(); - + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) const { t } = useTranslation('discover'); const items: MenuProps['items'] = [ { - icon: , + icon: , key: 'all', label: t('category.plugin.all'), }, + { + icon: , + key: 'collect', + label: t('category.plugin.collect'), + }, ...data.map((item) => ({ icon: ( ), diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/List.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/List.tsx index 544ca9f..da425cc 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/List.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/features/List.tsx @@ -5,14 +5,15 @@ import Link from 'next/link'; import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import urlJoin from 'url-join'; - +import { useRouter } from 'next/navigation'; import { DiscoverModelItem } from '@/types/discover'; - +import { Grid } from '@lobehub/ui'; import SearchResultCount from '../../../components/SearchResultCount'; import Title from '../../../components/Title'; import VirtuosoGridList from '../../../components/VirtuosoGridList'; import Card from './Card'; - +import request from '@/app/api/request'; +import { useUserStore } from '@/store/user'; export interface ListProps { category?: string; items?: DiscoverModelItem[]; @@ -20,9 +21,54 @@ export interface ListProps { searchKeywords?: string; } -const List = memo(({ category, searchKeywords, items = [] }) => { +const List = memo(async ({ category, searchKeywords, items = [] }) => { const { t } = useTranslation('discover'); - + const router = useRouter() + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + console.log(userId,'models---3837373266262266') + console.log('models---99999999',items) + if(category == "collect") { + const res = await request({ + url: "/flxai/api/robot/appaimodel/getAllAiModel", + method: "get", + params: { + userid: userId + } + }) + items = res.data; + items = items.map((item,index)=> { + item.classify = 'collect'; + return item + }) + } else { + const res = await request({ + url: "/flxai/api/robot/appaimodel/getAllAiModel", + method: "get", + params: { + userid: userId + } + }) + const array2Object = {}; + res?.data?.forEach(item => { + array2Object[item.identifier] = item; + }); + items = items.map((item,index)=> { + const matchingItem = array2Object[item.identifier]; + if (matchingItem) { + console.log('3838383838',matchingItem); + matchingItem.status = '1'; + return matchingItem + } else { + item.status = '0'; + return item + } + }) + } + const handleClickCard = (item) => { + console.log(item) + router.push(urlJoin('/discover/model/', item.identifier)) + } if (searchKeywords) { if (!items || items?.length === 0) return ; return ( @@ -32,9 +78,9 @@ const List = memo(({ category, searchKeywords, items = [] }) => { data={items} initialItemCount={24} itemContent={(_, item) => ( - - - + // + handleClickCard(item)} showCategory {...item} /> + // )} style={{ minHeight: '75vh', @@ -46,19 +92,34 @@ const List = memo(({ category, searchKeywords, items = [] }) => { return ( <> - {t('models.list')} - ( - - - - )} - style={{ - minHeight: '75vh', - }} - /> + {category == "collect"?( + <> + 收藏列表 + + {items.map((item) => ( + // + handleClickCard(item)} showCategory={!category} {...item} /> + // + ))} + + + ):( + <> + {t('models.list')} + ( + // + handleClickCard(item)} showCategory={!category} {...item} /> + // + )} + style={{ + minHeight: '75vh', + }} + /> + + )} ); }); diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/page.tsx index c367280..ec38ac0 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/models/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/models/page.tsx @@ -8,7 +8,7 @@ import { translation } from '@/server/translation'; import { isMobileDevice } from '@/utils/responsive'; import List from './features/List'; - +import urlJoin from 'url-join'; type Props = { searchParams: { hl?: Locales } }; export const generateMetadata = async ({ searchParams }: Props) => { @@ -26,14 +26,14 @@ export const generateMetadata = async ({ searchParams }: Props) => { const Page = async ({ searchParams }: Props) => { const { t, locale } = await translation('metadata', searchParams?.hl); const mobile = isMobileDevice(); - const discoverService = new DiscoverService(); const items = await discoverService.getModelList(locale); + console.log(8272772727,'jiangxucong') const ld = ldModule.generate({ description: t('discover.models.description'), title: t('discover.models.title'), - url: '/discover/models', + url: urlJoin('/discover/models?userid=',searchParams.userid), webpage: { enable: true, search: '/discover/search', diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/[slug]/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/[slug]/page.tsx index 684dde5..caedbcd 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/[slug]/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/[slug]/page.tsx @@ -8,7 +8,6 @@ import { DiscoverService } from '@/server/services/discover'; import { translation } from '@/server/translation'; import { PluginCategory } from '@/types/discover'; import { isMobileDevice } from '@/utils/responsive'; - import List from '../features/List'; type Props = { params: { slug: PluginCategory }; searchParams: { hl?: Locales } }; @@ -30,14 +29,12 @@ const Page = async ({ params, searchParams }: Props) => { const { t, locale } = await translation('metadata', searchParams?.hl); const { t: td } = await translation('discover', searchParams?.hl); const mobile = isMobileDevice(); - const discoverService = new DiscoverService(); const items = await discoverService.getPluginCategory(locale, params.slug); - const ld = ldModule.generate({ description: t('discover.plugins.description'), title: [td(`category.plugin.${params.slug}`), t('discover.plugins.title')].join(' · '), - url: urlJoin('/discover/plugins', params.slug), + url: urlJoin('/discover/plugins', params.slug + '?userid=' + searchParams.userid), webpage: { enable: true, search: '/discover/search', diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/Card.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/Card.tsx index a7c49e9..7f54dbb 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/Card.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/Card.tsx @@ -1,18 +1,19 @@ import { Avatar, Tag } from '@lobehub/ui'; -import { Skeleton, Typography } from 'antd'; +import { Skeleton, Typography, App } from 'antd'; import { createStyles } from 'antd-style'; import { startCase } from 'lodash-es'; import dynamic from 'next/dynamic'; import qs from 'query-string'; -import { memo } from 'react'; +import { memo, useState } from 'react'; import { Center, Flexbox, FlexboxProps } from 'react-layout-kit'; import urlJoin from 'url-join'; - +import { useTranslation } from 'react-i18next'; import { DiscoverPlugintem } from '@/types/discover'; - +import { useUserStore } from '@/store/user'; import CardBanner from '../../../components/CardBanner'; import { useCategoryItem } from './useCategory'; - +import { StarOutlined } from '@ant-design/icons'; +import request from '@/app/api/request'; const Link = dynamic(() => import('next/link'), { loading: () => , ssr: false, @@ -61,6 +62,15 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({ font-size: 18px !important; font-weight: bold; `, + collectBtn: css` + font-size: 12px; + width: 20px; + height: 20px; + line-height: 20px; + border-radius: 50%; + background: #FFF3D9; + text-align: center; + `, })); interface PluginCardProps @@ -73,10 +83,63 @@ interface PluginCardProps const PluginCard = memo( ({ className, showCategory, meta, createdAt, author, variant, ...rest }) => { const { avatar, title, description, tags = [], category } = meta; + const { createAt, homepage, identifier, schemaVersion, status, classify, manifest,locale } = {...rest} const categoryItem = useCategoryItem(category, 12); const { cx, styles, theme } = useStyles(); + const { t } = useTranslation('discover'); + const { message } = App.useApp(); const isCompact = variant === 'compact'; - + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + console.log(status,"9383737-------------------------------------") + console.log(manifest,locale,"plugins9999999999-------------------") + const [val, setVal] = useState('') + const handleCollect = (e) => { + console.log(e,8844848) + e.preventDefault() + e.stopPropagation() + const params = { + "author": author, + "createdAt": createdAt, + "homepage": homepage, + "identifier": identifier, + "avatar": avatar, + "description": description, + "tags": tags.join(','), + "title": title, + "category": category, + "schemaVersion": schemaVersion, + "manifest": manifest, + "locale": locale, + "userid": userId, + } + request({ + url: "/flxai/api/robot/appaiplugin", + method: "post", + data: params + }).then(response => { + console.log(response,222222222) + if (response.code == 0) { + message.success(t('collectSuccess')); + setVal("1") + } + }).catch(error => { + console.error('Error fetching data: ', error); + }) + } + const renderElement = () => { + console.log(classify,'66666----------------------') + if (classify != 'collect') { + console.log(status,"222222222--------------------------") + if(status == "1" || val == "1") { + return
{e.stopPropagation()}}>
+ } else { + return
handleCollect(e)}>
+ } + } else { + return; + } + }; return ( {!isCompact && } @@ -121,29 +184,28 @@ const PluginCard = memo( {description} - - {showCategory && categoryItem ? ( - - - {categoryItem.label} - - - ) : ( - tags - .slice(0, 4) - .filter(Boolean) - .map((tag: string, index) => { - const url = qs.stringifyUrl({ - query: { q: tag, type: 'plugins' }, - url: '/discover/search', - }); - return ( - - {startCase(tag).trim()} - - ); - }) - )} + +
{e.stopPropagation()}} style={{width: '85%'}}> + {showCategory && categoryItem ? ( + + {categoryItem.label} + + ) : ( + tags + .slice(0, 4) + .filter(Boolean) + .map((tag: string, index) => { + const url = qs.stringifyUrl({ + query: { q: tag, type: 'plugins' }, + url: '/discover/search', + }); + return ( + {startCase(tag).trim()} + ); + }) + )} +
+ {renderElement()}
diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/Category.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/Category.tsx index fceb6fa..59b2211 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/Category.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/Category.tsx @@ -7,7 +7,7 @@ import urlJoin from 'url-join'; import { useQueryRoute } from '@/hooks/useQueryRoute'; import { PluginCategory } from '@/types/discover'; - +import { useUserStore } from '@/store/user'; import CategoryMenu from '../../../components/CategoryMenu'; import { useCategory } from './useCategory'; @@ -21,7 +21,8 @@ const Category = memo(() => { return 'all'; }, [pathname]); const router = useQueryRoute(); - + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) return ( ({ diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/List.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/List.tsx index 421e035..9cd9ce9 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/List.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/List.tsx @@ -3,17 +3,18 @@ import { Grid } from '@lobehub/ui'; import { Empty } from 'antd'; import Link from 'next/link'; -import { memo, useMemo } from 'react'; +import { memo, useMemo, useEffect,useState } from 'react'; import { useTranslation } from 'react-i18next'; import urlJoin from 'url-join'; - +import { useRouter } from 'next/navigation'; import { DiscoverPlugintem } from '@/types/discover'; import SearchResultCount from '../../../components/SearchResultCount'; import Title from '../../../components/Title'; import VirtuosoGridList from '../../../components/VirtuosoGridList'; import Card from './Card'; - +import request from '@/app/api/request'; +import { useUserStore } from '@/store/user'; export interface ListProps { category?: string; items: DiscoverPlugintem[]; @@ -23,14 +24,68 @@ export interface ListProps { const List = memo(({ category, mobile, searchKeywords, items = [] }) => { const { t } = useTranslation('discover'); + const router = useRouter() + const [stData, setStData] = useState(items) const recentLength = mobile ? 4 : 8; + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) + console.log(userId,'chajian---3837373266262266') + console.log('chajian33333333--------------',items) const { all, recent, last } = useMemo(() => { return { - all: items, - last: items.slice(recentLength), - recent: items.slice(0, recentLength), + all: stData, + last: stData.slice(recentLength), + recent: stData.slice(0, recentLength), + }; + }, [stData, mobile]); + useEffect(() => { + const fetchData = async() => { + if(category == "collect") { + const res = await request({ + url: "/flxai/api/robot/appaiplugin/getAllAiPlugin", + method: "get", + params: { + userid: userId + } + }) + setStData(res?.data.map((item,index)=> { + item.classify = 'collect'; + return item + })) + } else { + const res = await request({ + url: "/flxai/api/robot/appaiplugin/getAllAiPlugin", + method: "get", + params: { + userid: userId + } + }) + const array2Object = {}; + res?.data?.forEach((item) => { + array2Object[item.identifier] = item; + }); + console.log('chajian22222222222222222222222222222--------------') + setStData(stData.map((item,index)=> { + const matchingItem = array2Object[item.identifier]; + if (matchingItem) { + matchingItem.status = '1'; + return matchingItem + } else { + item.status = '0'; + return item + } + })) + } }; - }, [items, mobile]); + fetchData(); + }, []); // 空数组[]意味着仅在组件挂载时调用一次 + + console.log('chajian999999999999999--------------',stData) + + const handleClickCard = (item) => { + console.log(item) + router.push(urlJoin('/discover/plugin/', item.identifier)) + } if (searchKeywords) { if (!items || items?.length === 0) return ; @@ -41,9 +96,7 @@ const List = memo(({ category, mobile, searchKeywords, items = [] }) data={all} initialItemCount={24} itemContent={(_, item) => ( - - - + handleClickCard(item)} showCategory variant={'compact'} {...item} /> )} style={{ minHeight: '75vh', @@ -55,29 +108,40 @@ const List = memo(({ category, mobile, searchKeywords, items = [] }) return ( <> - {t('plugins.recentSubmits')} - - {recent.map((item) => ( - - - - ))} - - {last && last?.length > 0 && ( + {category == "collect"?( + <> + 收藏列表 + + {all?.map((item) => ( + // + handleClickCard(item)} showCategory={!category} {...item} /> + // + ))} + + + ):( <> - {t('plugins.list')} - ( - - - - )} - style={{ - minHeight: '75vh', - }} - /> + {t('plugins.recentSubmits')} + + {recent?.map((item) => ( + handleClickCard(item)} showCategory={!category} {...item} /> + ))} + + {last && last?.length > 0 && ( + <> + {t('plugins.list')} + ( + handleClickCard(item)} showCategory={!category} variant={'compact'} {...item} /> + )} + style={{ + minHeight: '75vh', + }} + /> + + )} )} diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/useCategory.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/useCategory.tsx index d6d8352..b9d3547 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/useCategory.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/features/useCategory.tsx @@ -37,42 +37,42 @@ export const useCategory = (fontsize?: number) => { label: t('category.plugin.collect'), }, { - icon: , + icon: , key: PluginCategory.MediaGenerate, label: t('category.plugin.media-generate'), }, { - icon: , + icon: , key: PluginCategory.WebSearch, label: t('category.plugin.web-search'), }, { - icon: , + icon: , key: PluginCategory.StocksFinance, label: t('category.plugin.stocks-finance'), }, { - icon: , + icon: , key: PluginCategory.Tools, label: t('category.plugin.tools'), }, { - icon: , + icon: , key: PluginCategory.LifeStyle, label: t('category.plugin.life-style'), }, { - icon: , + icon: , key: PluginCategory.ScienceEducation, label: t('category.plugin.science-education'), }, { - icon: , + icon: , key: PluginCategory.Social, label: t('category.plugin.social'), }, { - icon: , + icon: , key: PluginCategory.GamingEntertainment, label: t('category.plugin.gaming-entertainment'), }, diff --git a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/page.tsx b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/page.tsx index 29a306c..89e25a7 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/page.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/(list)/plugins/page.tsx @@ -5,9 +5,8 @@ import { metadataModule } from '@/server/metadata'; import { DiscoverService } from '@/server/services/discover'; import { translation } from '@/server/translation'; import { isMobileDevice } from '@/utils/responsive'; - import List from './features/List'; - +import urlJoin from 'url-join'; type Props = { searchParams: { hl?: Locales } }; export const generateMetadata = async ({ searchParams }: Props) => { @@ -25,14 +24,14 @@ export const generateMetadata = async ({ searchParams }: Props) => { const Page = async ({ searchParams }: Props) => { const { t, locale } = await translation('metadata', searchParams?.hl); const mobile = isMobileDevice(); - const discoverService = new DiscoverService(); + console.log(searchParams.userid,'plugins555555555555-----------------') const items = await discoverService.getPluginList(locale); const ld = ldModule.generate({ description: t('discover.plugins.description'), title: t('discover.plugins.title'), - url: '/discover/plugins', + url: urlJoin('/discover/plugins?userid=',searchParams.userid), webpage: { enable: true, search: '/discover/search', diff --git a/DigitalHumanWeb/src/app/(main)/discover/_layout/Desktop/index.tsx b/DigitalHumanWeb/src/app/(main)/discover/_layout/Desktop/index.tsx index 9c6bd0d..b07a292 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/_layout/Desktop/index.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/_layout/Desktop/index.tsx @@ -9,7 +9,7 @@ const Layout = ({ children }: PropsWithChildren) => { return ( <> - +
{children} diff --git a/DigitalHumanWeb/src/app/(main)/discover/features/StoreSearchBar.tsx b/DigitalHumanWeb/src/app/(main)/discover/features/StoreSearchBar.tsx index 3930cd0..5bf2a53 100644 --- a/DigitalHumanWeb/src/app/(main)/discover/features/StoreSearchBar.tsx +++ b/DigitalHumanWeb/src/app/(main)/discover/features/StoreSearchBar.tsx @@ -13,7 +13,7 @@ import { useQueryRoute } from '@/hooks/useQueryRoute'; import { DiscoverTab } from '@/types/discover'; import { useNav } from './useNav'; - +import { useUserStore } from '@/store/user'; export const useStyles = createStyles(({ css, prefixCls, token }) => ({ active: css` box-shadow: ${token.boxShadow}; @@ -41,15 +41,16 @@ const StoreSearchBar = memo(({ mobile, onBlur, onFocus, ... const router = useQueryRoute(); const activeType = activeKey === DiscoverTab.Home ? DiscoverTab.Assistants : activeKey; - + const getUserId = (s: UserStore) => s.user?.id + const userId = getUserId(useUserStore.getState()) useEffect(() => { if (!pathname.includes('/discover/search')) return; // 使用 useQueryState 时,当 handleSearch 为空时无法回跳 - if (!q) router.push(urlJoin('/discover', activeType), { query: { userid: localStorage.getItem('userId') }, replace: true }); + if (!q) router.push(urlJoin('/discover', activeType), { query: { userid: userId }, replace: true }); }, [q, pathname, activeType]); const handleSearch = (value: string) => { - router.push('/discover/search', { query: { q: value, type: activeType, userid: localStorage.getItem('userId') } }); + router.push('/discover/search', { query: { q: value, type: activeType, userid: userId } }); }; return ( diff --git a/DigitalHumanWeb/src/locales/default/discover.ts b/DigitalHumanWeb/src/locales/default/discover.ts index b0022c5..dcb8f85 100644 --- a/DigitalHumanWeb/src/locales/default/discover.ts +++ b/DigitalHumanWeb/src/locales/default/discover.ts @@ -19,6 +19,7 @@ export default { try: '试一下', }, back: '返回发现', + collectSuccess: '收藏成功', category: { assistant: { 'all': "全部", diff --git a/DigitalHumanWeb/src/store/user/slices/common/action.ts b/DigitalHumanWeb/src/store/user/slices/common/action.ts index 00024cf..5ad56a4 100644 --- a/DigitalHumanWeb/src/store/user/slices/common/action.ts +++ b/DigitalHumanWeb/src/store/user/slices/common/action.ts @@ -96,7 +96,7 @@ export const createCommonSlice: StateCreator< data.avatar || data.userId ? merge(get().user, { avatar: data.avatar, id: data.userId }) : get().user; - + console.log(user,'777777777777777777777777') set( { defaultSettings,