Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat: community support like and follow (#10913)

Shinji-Lic6a6e246d850
diff --git a/locales/en-US/discover.json b/locales/en-US/discover.json
index 1531378268a..33a26279646 100644
--- a/locales/en-US/discover.json
+++ b/locales/en-US/discover.json
@@ -1,4 +1,12 @@
{
+ "assistant": {
+ "favorite": "Favorite",
+ "favoriteFailed": "Failed to add to favorites",
+ "favoriteSuccess": "Added to favorites",
+ "unfavorite": "Unfavorite",
+ "unfavoriteFailed": "Failed to remove from favorites",
+ "unfavoriteSuccess": "Removed from favorites"
+ },
"assistants": {
"addAgent": "Add Assistant",
"addAgentAndConverse": "Add Assistant and Converse",
@@ -720,11 +728,26 @@
"agents": "Agents",
"downloads": "Downloads",
"editProfile": "Edit Profile",
+ "favoriteAgents": "Favorite Agents",
+ "favoritePlugins": "Favorite Plugins",
+ "follow": "Follow",
+ "followers": "Followers",
+ "following": "Following",
"login": "Become a Creator",
"logout": "Logout",
"myProfile": "My Profile",
"noAgents": "This user has not published any agents yet",
+ "noFavoriteAgents": "No favorite agents yet",
+ "noFavoritePlugins": "No favorite plugins yet",
"publishedAgents": "Created Assistants",
+ "tabs": {
+ "favorites": "Favorites",
+ "publishedAgents": "Created"
+ },
+ "unfollow": "Unfollow",
+ "unfavorite": "Unfavorite",
+ "unfavoriteFailed": "Failed to unfavorite",
+ "unfavoriteSuccess": "Unfavorited successfully",
"website": "Website"
}
}
diff --git a/locales/zh-CN/discover.json b/locales/zh-CN/discover.json
index ea9ba0627d1..43fabebd78e 100644
--- a/locales/zh-CN/discover.json
+++ b/locales/zh-CN/discover.json
@@ -1,4 +1,12 @@
{
+ "assistant": {
+ "favorite": "收藏",
+ "favoriteFailed": "收藏失败",
+ "favoriteSuccess": "已收藏",
+ "unfavorite": "取消收藏",
+ "unfavoriteFailed": "取消收藏失败",
+ "unfavoriteSuccess": "已取消收藏"
+ },
"assistants": {
"addAgent": "添加助手",
"addAgentAndConverse": "添加助手并会话",
@@ -720,11 +728,26 @@
"agents": "助手",
"downloads": "下载",
"editProfile": "编辑个人资料",
+ "favoriteAgents": "收藏的助手",
+ "favoritePlugins": "收藏的插件",
+ "follow": "关注",
+ "followers": "粉丝",
+ "following": "关注",
"login": "成为创作者",
"logout": "退出登录",
"myProfile": "我的主页",
"noAgents": "该用户暂未发布助手",
+ "noFavoriteAgents": "暂无收藏的助手",
+ "noFavoritePlugins": "暂无收藏的插件",
"publishedAgents": "创作的助手",
+ "tabs": {
+ "favorites": "收藏",
+ "publishedAgents": "创作"
+ },
+ "unfollow": "取消关注",
+ "unfavorite": "取消收藏",
+ "unfavoriteFailed": "取消收藏失败",
+ "unfavoriteSuccess": "已取消收藏",
"website": "个人网站"
}
}
diff --git a/package.json b/package.json
index f670b0ded27..6f262a1ac2b 100644
--- a/package.json
+++ b/package.json
@@ -194,7 +194,7 @@
"@lobehub/desktop-ipc-typings": "workspace:*",
"@lobehub/editor": "^2.0.5",
"@lobehub/icons": "^3.0.0",
- "@lobehub/market-sdk": "^0.23.8",
+ "@lobehub/market-sdk": "^0.24.0",
"@lobehub/tts": "^3.0.0",
"@lobehub/ui": "^3.4.4",
"@modelcontextprotocol/sdk": "^1.25.1",
diff --git a/packages/types/src/discover/index.ts b/packages/types/src/discover/index.ts
index bfeef3ca258..6eee2fb9c55 100644
--- a/packages/types/src/discover/index.ts
+++ b/packages/types/src/discover/index.ts
@@ -44,6 +44,8 @@ export interface DiscoverUserInfo {
createdAt: string;
description: string | null;
displayName: string | null;
+ followersCount?: number;
+ followingCount?: number;
id: number;
namespace: string;
socialLinks: {
diff --git a/src/app/(backend)/market/social/[[...segments]]/route.ts b/src/app/(backend)/market/social/[[...segments]]/route.ts
new file mode 100644
index 00000000000..aaf4b60e4a5
--- /dev/null
+++ b/src/app/(backend)/market/social/[[...segments]]/route.ts
@@ -0,0 +1,260 @@
+import { MarketSDK } from '@lobehub/market-sdk';
+import { NextRequest, NextResponse } from 'next/server';
+
+type RouteContext = {
+ params: Promise<{
+ segments?: string[];
+ }>;
+};
+
+const MARKET_BASE_URL = process.env.NEXT_PUBLIC_MARKET_BASE_URL || 'https://market.lobehub.com';
+
+/**
+ * Helper to get authorization header
+ */
+const getAccessToken = (req: NextRequest): string | undefined => {
+ const authHeader = req.headers.get('authorization');
+ if (authHeader?.startsWith('Bearer ')) {
+ return authHeader.slice(7);
+ }
+ return undefined;
+};
+
+/**
+ * POST /market/social/follow
+ * POST /market/social/unfollow
+ * POST /market/social/favorite
+ * POST /market/social/unfavorite
+ * POST /market/social/like
+ * POST /market/social/unlike
+ * POST /market/social/toggle-like
+ */
+export const POST = async (req: NextRequest, context: RouteContext) => {
+ const { segments = [] } = await context.params;
+ const action = segments[0];
+ const accessToken = getAccessToken(req);
+
+ if (!accessToken) {
+ return NextResponse.json(
+ { error: 'unauthorized', message: 'Access token required' },
+ { status: 401 },
+ );
+ }
+
+ const market = new MarketSDK({
+ accessToken,
+ baseURL: MARKET_BASE_URL,
+ });
+
+ try {
+ const body = await req.json();
+
+ switch (action) {
+ // Follow actions
+ case 'follow': {
+ const { followingId } = body;
+ await market.follows.follow(followingId);
+ return NextResponse.json({ success: true });
+ }
+
+ case 'unfollow': {
+ const { followingId } = body;
+ await market.follows.unfollow(followingId);
+ return NextResponse.json({ success: true });
+ }
+
+ // Favorite actions
+ case 'favorite': {
+ const { targetType, targetId, identifier } = body;
+ // SDK accepts both number (targetId) and string (identifier)
+ await market.favorites.addFavorite(targetType, identifier ?? targetId);
+ return NextResponse.json({ success: true });
+ }
+
+ case 'unfavorite': {
+ const { targetType, targetId, identifier } = body;
+ // SDK accepts both number (targetId) and string (identifier)
+ await market.favorites.removeFavorite(targetType, identifier ?? targetId);
+ return NextResponse.json({ success: true });
+ }
+
+ // Like actions
+ case 'like': {
+ const { targetType, targetId } = body;
+ await market.likes.like(targetType, targetId);
+ return NextResponse.json({ success: true });
+ }
+
+ case 'unlike': {
+ const { targetType, targetId } = body;
+ await market.likes.unlike(targetType, targetId);
+ return NextResponse.json({ success: true });
+ }
+
+ case 'toggle-like': {
+ const { targetType, targetId } = body;
+ const result = await market.likes.toggleLike(targetType, targetId);
+ return NextResponse.json(result);
+ }
+
+ default: {
+ return NextResponse.json(
+ { error: 'not_found', message: `Unknown action: ${action}` },
+ { status: 404 },
+ );
+ }
+ }
+ } catch (error) {
+ console.error('[Market Social] Action failed:', error);
+ return NextResponse.json(
+ {
+ error: 'action_failed',
+ message: error instanceof Error ? error.message : 'Unknown error',
+ },
+ { status: 500 },
+ );
+ }
+};
+
+/**
+ * GET /market/social/follow-status/[userId]
+ * GET /market/social/following/[userId]
+ * GET /market/social/followers/[userId]
+ * GET /market/social/favorite-status/[targetType]/[targetId]
+ * GET /market/social/favorites/[userId]
+ * GET /market/social/favorite-agents/[userId]
+ * GET /market/social/favorite-plugins/[userId]
+ * GET /market/social/liked-agents/[userId]
+ * GET /market/social/liked-plugins/[userId]
+ */
+export const GET = async (req: NextRequest, context: RouteContext) => {
+ const { segments = [] } = await context.params;
+ const action = segments[0];
+ const accessToken = getAccessToken(req);
+
+ const market = new MarketSDK({
+ accessToken,
+ baseURL: MARKET_BASE_URL,
+ });
+
+ const url = new URL(req.url);
+ const limit = url.searchParams.get('pageSize') || url.searchParams.get('limit');
+ const offset = url.searchParams.get('offset');
+
+ // Build params compatible with SDK API (limit/offset based)
+ const paginationParams: { limit?: number; offset?: number } = {};
+ if (limit) paginationParams.limit = Number(limit);
+ if (offset) paginationParams.offset = Number(offset);
+
+ try {
+ switch (action) {
+ // Follow queries
+ case 'follow-status': {
+ const targetUserId = Number(segments[1]);
+ if (!accessToken) {
+ return NextResponse.json({ isFollowing: false, isMutual: false });
+ }
+ const result = await market.follows.checkFollowStatus(targetUserId);
+ return NextResponse.json(result);
+ }
+
+ case 'following': {
+ const userId = Number(segments[1]);
+ const result = await market.follows.getFollowing(userId, paginationParams);
+ return NextResponse.json(result);
+ }
+
+ case 'followers': {
+ const userId = Number(segments[1]);
+ const result = await market.follows.getFollowers(userId, paginationParams);
+ return NextResponse.json(result);
+ }
+
+ case 'follow-counts': {
+ const userId = Number(segments[1]);
+ const [following, followers] = await Promise.all([
+ market.follows.getFollowing(userId, { limit: 1 }),
+ market.follows.getFollowers(userId, { limit: 1 }),
+ ]);
+ return NextResponse.json({
+ followersCount: (followers as any).totalCount || (followers as any).total || 0,
+ followingCount: (following as any).totalCount || (following as any).total || 0,
+ });
+ }
+
+ // Favorite queries
+ case 'favorite-status': {
+ const targetType = segments[1] as 'agent' | 'plugin';
+ const targetIdOrIdentifier = segments[2];
+ if (!accessToken) {
+ return NextResponse.json({ isFavorited: false });
+ }
+ // SDK accepts both number (targetId) and string (identifier)
+ const isNumeric = /^\d+$/.test(targetIdOrIdentifier);
+ const targetValue = isNumeric ? Number(targetIdOrIdentifier) : targetIdOrIdentifier;
+ const result = await market.favorites.checkFavorite(targetType, targetValue as number);
+ return NextResponse.json(result);
+ }
+
+ case 'favorites': {
+ if (!accessToken) {
+ return NextResponse.json(
+ { error: 'unauthorized', message: 'Access token required' },
+ { status: 401 },
+ );
+ }
+ const result = await market.favorites.getMyFavorites(paginationParams);
+ return NextResponse.json(result);
+ }
+
+ case 'user-favorites': {
+ const userId = Number(segments[1]);
+ const result = await market.favorites.getUserFavorites(userId, paginationParams);
+ return NextResponse.json(result);
+ }
+
+ case 'favorite-agents': {
+ const userId = Number(segments[1]);
+ const result = await market.favorites.getUserFavoriteAgents(userId, paginationParams);
+ return NextResponse.json(result);
+ }
+
+ case 'favorite-plugins': {
+ const userId = Number(segments[1]);
+ const result = await market.favorites.getUserFavoritePlugins(userId, paginationParams);
+ return NextResponse.json(result);
+ }
+
+ // Like queries
+ case 'liked-agents': {
+ const userId = Number(segments[1]);
+ const result = await market.likes.getUserLikedAgents(userId, paginationParams);
+ return NextResponse.json(result);
+ }
+
+ case 'liked-plugins': {
+ const userId = Number(segments[1]);
+ const result = await market.likes.getUserLikedPlugins(userId, paginationParams);
+ return NextResponse.json(result);
+ }
+
+ default: {
+ return NextResponse.json(
+ { error: 'not_found', message: `Unknown action: ${action}` },
+ { status: 404 },
+ );
+ }
+ }
+ } catch (error) {
+ console.error('[Market Social] Query failed:', error);
+ return NextResponse.json(
+ {
+ error: 'query_failed',
+ message: error instanceof Error ? error.message : 'Unknown error',
+ },
+ { status: 500 },
+ );
+ }
+};
+
+export const dynamic = 'force-dynamic';
diff --git a/src/app/[variants]/(main)/community/(detail)/assistant/features/Header.tsx b/src/app/[variants]/(main)/community/(detail)/assistant/features/Header.tsx
index 8319a0dfbcc..c37045f083a 100644
--- a/src/app/[variants]/(main)/community/(detail)/assistant/features/Header.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/assistant/features/Header.tsx
@@ -1,15 +1,19 @@
'use client';
import { MCP } from '@lobehub/icons';
-import { Avatar, Button, Flexbox, Icon, Text, Tooltip, TooltipGroup } from '@lobehub/ui';
+import { ActionIcon, Avatar, Button, Flexbox, Icon, Text, Tooltip, TooltipGroup } from '@lobehub/ui';
+import { App } from 'antd';
import { createStyles, useResponsive } from 'antd-style';
-import { BookTextIcon, CoinsIcon, DotIcon } from 'lucide-react';
+import { BookTextIcon, CoinsIcon, DotIcon, Heart, type LucideProps } from 'lucide-react';
import qs from 'query-string';
-import { memo } from 'react';
+import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
+import useSWR from 'swr';
import urlJoin from 'url-join';
+import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
+import { socialService } from '@/services/social';
import { formatIntergerNumber } from '@/utils/format';
import { useCategory } from '../../../(list)/assistant/features/Category/useCategory';
@@ -34,6 +38,7 @@ const useStyles = createStyles(({ css, token }) => {
const Header = memo<{ mobile?: boolean }>(({ mobile: isMobile }) => {
const { t } = useTranslation('discover');
+ const { message } = App.useApp();
const {
author,
identifier,
@@ -48,6 +53,49 @@ const Header = memo<{ mobile?: boolean }>(({ mobile: isMobile }) => {
} = useDetailContext();
const { styles, theme } = useStyles();
const { mobile = isMobile } = useResponsive();
+ const { isAuthenticated, signIn, session } = useMarketAuth();
+ const [favoriteLoading, setFavoriteLoading] = useState(false);
+
+ // Set access token for social service
+ if (session?.accessToken) {
+ socialService.setAccessToken(session.accessToken);
+ }
+
+ // Fetch favorite status
+ const { data: favoriteStatus, mutate: mutateFavorite } = useSWR(
+ identifier && isAuthenticated ? ['favorite-status', 'agent', identifier] : null,
+ () => socialService.checkFavoriteStatus('agent', identifier!),
+ { revalidateOnFocus: false },
+ );
+
+ const isFavorited = favoriteStatus?.isFavorited ?? false;
+
+ const handleFavoriteClick = async () => {
+ if (!isAuthenticated) {
+ await signIn();
+ return;
+ }
+
+ if (!identifier) return;
+
+ setFavoriteLoading(true);
+ try {
+ if (isFavorited) {
+ await socialService.removeFavorite('agent', identifier);
+ message.success(t('assistant.unfavoriteSuccess'));
+ } else {
+ await socialService.addFavorite('agent', identifier);
+ message.success(t('assistant.favoriteSuccess'));
+ }
+ await mutateFavorite();
+ } catch (error) {
+ console.error('Favorite action failed:', error);
+ message.error(t('assistant.favoriteFailed'));
+ } finally {
+ setFavoriteLoading(false);
+ }
+ };
+
const categories = useCategory();
const cate = categories.find((c) => c.key === category);
@@ -104,6 +152,16 @@ const Header = memo<{ mobile?: boolean }>(({ mobile: isMobile }) => {
{title}
</Text>
</Flexbox>
+ <Tooltip title={isFavorited ? t('assistant.unfavorite') : t('assistant.favorite')}>
+ <ActionIcon
+ icon={(props: LucideProps) => (
+ <Heart {...props} fill={isFavorited ? 'currentColor' : 'none'} />
+ )}
+ loading={favoriteLoading}
+ onClick={handleFavoriteClick}
+ style={isFavorited ? { color: 'var(--lobe-color-error)' } : undefined}
+ />
+ </Tooltip>
</Flexbox>
<Flexbox align={'center'} gap={4} horizontal>
{author && userName ? (
diff --git a/src/app/[variants]/(main)/community/(detail)/mcp/features/Sidebar/ActionButton/index.tsx b/src/app/[variants]/(main)/community/(detail)/mcp/features/Sidebar/ActionButton/index.tsx
index d777a5baf10..259785a31e7 100644
--- a/src/app/[variants]/(main)/community/(detail)/mcp/features/Sidebar/ActionButton/index.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/mcp/features/Sidebar/ActionButton/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { Flexbox, Icon , Button } from '@lobehub/ui';
+import { Button, Flexbox, Icon } from '@lobehub/ui';
import { createStyles } from 'antd-style';
import { Trash2Icon } from 'lucide-react';
import { memo, useState } from 'react';
@@ -60,8 +60,6 @@ const ActionButton = memo(() => {
const buttonLoading = isLoading || isAuthLoading;
- console.log('installed', isLoading, isAuthLoading, installed);
-
return installed ? (
<Flexbox gap={8} horizontal>
<Button
diff --git a/src/app/[variants]/(main)/community/(detail)/user/features/FollowButton.tsx b/src/app/[variants]/(main)/community/(detail)/user/features/FollowButton.tsx
new file mode 100644
index 00000000000..80f9618154d
--- /dev/null
+++ b/src/app/[variants]/(main)/community/(detail)/user/features/FollowButton.tsx
@@ -0,0 +1,67 @@
+'use client';
+
+import { Button } from '@lobehub/ui';
+import { UserMinus, UserPlus } from 'lucide-react';
+import { memo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
+import { socialService } from '@/services/social';
+import { useDiscoverStore } from '@/store/discover';
+
+interface FollowButtonProps {
+ userId: number;
+}
+
+const FollowButton = memo<FollowButtonProps>(({ userId }) => {
+ const { t } = useTranslation('discover');
+ const { isAuthenticated, signIn, session } = useMarketAuth();
+ const [loading, setLoading] = useState(false);
+
+ const useFollowStatus = useDiscoverStore((s) => s.useFollowStatus);
+ const follow = useDiscoverStore((s) => s.follow);
+ const unfollow = useDiscoverStore((s) => s.unfollow);
+
+ // Set access token for social service
+ if (session?.accessToken) {
+ socialService.setAccessToken(session.accessToken);
+ }
+
+ const { data: followStatus, mutate } = useFollowStatus(userId);
+ const isFollowing = followStatus?.isFollowing ?? false;
+
+ const handleClick = async () => {
+ if (!isAuthenticated) {
+ await signIn();
+ return;
+ }
+
+ setLoading(true);
+ try {
+ if (isFollowing) {
+ await unfollow(userId);
+ } else {
+ await follow(userId);
+ }
+ await mutate();
+ } catch (error) {
+ console.error('Follow action failed:', error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ return (
+ <Button
+ icon={isFollowing ? UserMinus : UserPlus}
+ loading={loading}
+ onClick={handleClick}
+ shape={'round'}
+ type={isFollowing ? 'default' : 'primary'}
+ >
+ {isFollowing ? t('user.unfollow') : t('user.follow')}
+ </Button>
+ );
+});
+
+export default FollowButton;
diff --git a/src/app/[variants]/(main)/community/(detail)/user/features/FollowStats.tsx b/src/app/[variants]/(main)/community/(detail)/user/features/FollowStats.tsx
new file mode 100644
index 00000000000..47a37413a37
--- /dev/null
+++ b/src/app/[variants]/(main)/community/(detail)/user/features/FollowStats.tsx
@@ -0,0 +1,32 @@
+'use client';
+
+import { Flexbox, Text } from '@lobehub/ui';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useUserDetailContext } from './DetailProvider';
+
+const FollowStats = memo(() => {
+ const { t } = useTranslation('discover');
+ const { user } = useUserDetailContext();
+
+ console.log(user);
+
+ const followingCount = user.followingCount ?? 0;
+ const followersCount = user.followersCount ?? 0;
+
+ return (
+ <Flexbox align={'center'} gap={16} horizontal>
+ <Flexbox align={'center'} gap={4} horizontal>
+ <Text style={{ fontWeight: 600 }}>{followingCount}</Text>
+ <Text type={'secondary'}>{t('user.following')}</Text>
+ </Flexbox>
+ <Flexbox align={'center'} gap={4} horizontal>
+ <Text style={{ fontWeight: 600 }}>{followersCount}</Text>
+ <Text type={'secondary'}>{t('user.followers')}</Text>
+ </Flexbox>
+ </Flexbox>
+ );
+});
+
+export default FollowStats;
diff --git a/src/app/[variants]/(main)/community/(detail)/user/features/Header/index.tsx b/src/app/[variants]/(main)/community/(detail)/user/features/Header/index.tsx
index 644ed0c8241..9100994730a 100644
--- a/src/app/[variants]/(main)/community/(detail)/user/features/Header/index.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/user/features/Header/index.tsx
@@ -8,6 +8,8 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useUserDetailContext } from '../DetailProvider';
+import FollowButton from '../FollowButton';
+import FollowStats from '../FollowStats';
import Banner from './Banner';
const UserHeader = memo(() => {
@@ -42,13 +44,19 @@ const UserHeader = memo(() => {
@{username}
</Text>
</Flexbox>
- {isOwner && onEditProfile && (
- <Button onClick={() => onEditProfile()} shape={'round'}>
- {t('user.editProfile')}
- </Button>
+ {isOwner ? (
+ onEditProfile && (
+ <Button onClick={() => onEditProfile()} shape={'round'}>
+ {t('user.editProfile')}
+ </Button>
+ )
+ ) : (
+ <FollowButton userId={user.id} />
)}
</Flexbox>
+ <FollowStats />
+
{user.description && <Text as={'p'}>{user.description}</Text>}
<TooltipGroup>
diff --git a/src/app/[variants]/(main)/community/(detail)/user/features/UserAgentList.tsx b/src/app/[variants]/(main)/community/(detail)/user/features/UserAgentList.tsx
index 6fbf19881ec..9db6e81485a 100644
--- a/src/app/[variants]/(main)/community/(detail)/user/features/UserAgentList.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/user/features/UserAgentList.tsx
@@ -1,7 +1,8 @@
'use client';
import { Flexbox, Grid, Tag, Text } from '@lobehub/ui';
-import { memo } from 'react';
+import { Pagination } from 'antd';
+import { memo, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import AssistantEmpty from '../../../features/AssistantEmpty';
@@ -9,15 +10,24 @@ import { useUserDetailContext } from './DetailProvider';
import UserAgentCard from './UserAgentCard';
interface UserAgentListProps {
+ pageSize?: number;
rows?: number;
}
-const UserAgentList = memo<UserAgentListProps>(({ rows = 4 }) => {
+const UserAgentList = memo<UserAgentListProps>(({ rows = 4, pageSize = 10 }) => {
const { t } = useTranslation('discover');
const { agents, agentCount } = useUserDetailContext();
+ const [currentPage, setCurrentPage] = useState(1);
+
+ const paginatedAgents = useMemo(() => {
+ const startIndex = (currentPage - 1) * pageSize;
+ return agents.slice(startIndex, startIndex + pageSize);
+ }, [agents, currentPage, pageSize]);
if (agents.length === 0) return <AssistantEmpty />;
+ const showPagination = agents.length > pageSize;
+
return (
<Flexbox gap={16}>
<Flexbox align={'center'} gap={8} horizontal>
@@ -27,10 +37,21 @@ const UserAgentList = memo<UserAgentListProps>(({ rows = 4 }) => {
{agentCount > 0 && <Tag>{agentCount}</Tag>}
</Flexbox>
<Grid rows={rows} width={'100%'}>
- {agents.map((item, index) => (
- <UserAgentCard key={index} {...item} />
+ {paginatedAgents.map((item, index) => (
+ <UserAgentCard key={item.identifier || index} {...item} />
))}
</Grid>
+ {showPagination && (
+ <Flexbox align={'center'} justify={'center'}>
+ <Pagination
+ current={currentPage}
+ onChange={(page) => setCurrentPage(page)}
+ pageSize={pageSize}
+ showSizeChanger={false}
+ total={agents.length}
+ />
+ </Flexbox>
+ )}
</Flexbox>
);
});
diff --git a/src/app/[variants]/(main)/community/(detail)/user/features/UserContent.tsx b/src/app/[variants]/(main)/community/(detail)/user/features/UserContent.tsx
new file mode 100644
index 00000000000..97cb1a8024c
--- /dev/null
+++ b/src/app/[variants]/(main)/community/(detail)/user/features/UserContent.tsx
@@ -0,0 +1,20 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { memo } from 'react';
+
+import UserAgentList from './UserAgentList';
+import UserFavoriteAgents from './UserFavoriteAgents';
+import UserFavoritePlugins from './UserFavoritePlugins';
+
+const UserContent = memo(() => {
+ return (
+ <Flexbox gap={32}>
+ <UserAgentList />
+ <UserFavoriteAgents />
+ <UserFavoritePlugins />
+ </Flexbox>
+ );
+});
+
+export default UserContent;
diff --git a/src/app/[variants]/(main)/community/(detail)/user/features/UserFavoriteAgents.tsx b/src/app/[variants]/(main)/community/(detail)/user/features/UserFavoriteAgents.tsx
new file mode 100644
index 00000000000..1ba187c185b
--- /dev/null
+++ b/src/app/[variants]/(main)/community/(detail)/user/features/UserFavoriteAgents.tsx
@@ -0,0 +1,302 @@
+'use client';
+
+import { Avatar, Block, Flexbox, Grid, Icon, Tag, Text, Tooltip } from '@lobehub/ui';
+import { App } from 'antd';
+import { createStyles } from 'antd-style';
+import { ClockIcon, DownloadIcon, Heart } from 'lucide-react';
+import qs from 'query-string';
+import { memo, useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
+import { Link, useNavigate } from 'react-router-dom';
+import urlJoin from 'url-join';
+
+import PublishedTime from '@/components/PublishedTime';
+import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
+import { FavoriteAgentItem, socialService } from '@/services/social';
+import { useDiscoverStore } from '@/store/discover';
+import { formatIntergerNumber } from '@/utils/format';
+
+import { useUserDetailContext } from './DetailProvider';
+
+const useStyles = createStyles(({ css, token }) => {
+ return {
+ desc: css`
+ flex: 1;
+ margin: 0 !important;
+ color: ${token.colorTextSecondary};
+ `,
+ favoriteButton: css`
+ cursor: pointer;
+
+ position: absolute;
+ inset-block-start: 12px;
+ inset-inline-end: 12px;
+
+ color: ${token.colorError};
+
+ opacity: 0;
+
+ transition: opacity 0.2s;
+ `,
+ footer: css`
+ margin-block-start: 16px;
+ border-block-start: 1px dashed ${token.colorBorder};
+ background: ${token.colorBgContainerSecondary};
+ `,
+ secondaryDesc: css`
+ font-size: 12px;
+ color: ${token.colorTextDescription};
+ `,
+ statTag: css`
+ border-radius: 4px;
+
+ font-family: ${token.fontFamilyCode};
+ font-size: 11px;
+ color: ${token.colorTextSecondary};
+
+ background: ${token.colorFillTertiary};
+ `,
+ title: css`
+ margin: 0 !important;
+ font-size: 16px !important;
+ font-weight: 500 !important;
+
+ &:hover {
+ color: ${token.colorLink};
+ }
+ `,
+ wrapper: css`
+ &:hover .favorite-button {
+ opacity: 1;
+ }
+ `,
+ };
+});
+
+interface FavoriteAgentCardProps extends FavoriteAgentItem {
+ onUnfavorite: (identifier: string) => void;
+ showUnfavorite: boolean;
+}
+
+const FavoriteAgentCard = memo<FavoriteAgentCardProps>(
+ ({
+ avatar,
+ name,
+ description,
+ createdAt,
+ category,
+ identifier,
+ installCount,
+ onUnfavorite,
+ showUnfavorite,
+ }) => {
+ const { styles } = useStyles();
+ const { t } = useTranslation('discover');
+ const navigate = useNavigate();
+
+ const link = qs.stringifyUrl(
+ {
+ query: { source: 'new' },
+ url: urlJoin('/community/assistant', identifier),
+ },
+ { skipNull: true },
+ );
+
+ return (
+ <Block
+ className={styles.wrapper}
+ clickable
+ height={'100%'}
+ onClick={() => navigate(link)}
+ style={{
+ cursor: 'pointer',
+ overflow: 'hidden',
+ position: 'relative',
+ }}
+ variant={'outlined'}
+ width={'100%'}
+ >
+ {showUnfavorite && (
+ <Tooltip title={t('user.unfavorite')}>
+ <div
+ className={`favorite-button ${styles.favoriteButton}`}
+ onClick={(e) => {
+ e.stopPropagation();
+ onUnfavorite(identifier);
+ }}
+ >
+ <Icon fill="currentColor" icon={Heart} size={16} />
+ </div>
+ </Tooltip>
+ )}
+ <Flexbox
+ align={'flex-start'}
+ gap={16}
+ horizontal
+ justify={'space-between'}
+ padding={16}
+ width={'100%'}
+ >
+ <Flexbox
+ gap={12}
+ horizontal
+ style={{
+ overflow: 'hidden',
+ }}
+ >
+ <Avatar avatar={avatar} shape={'square'} size={40} style={{ flex: 'none' }} />
+ <Flexbox
+ flex={1}
+ gap={2}
+ style={{
+ overflow: 'hidden',
+ }}
+ >
+ <Flexbox align={'center'} gap={8} horizontal>
+ <Link
+ onClick={(e) => e.stopPropagation()}
+ style={{ color: 'inherit', flex: 1, overflow: 'hidden' }}
+ to={link}
+ >
+ <Text as={'h3'} className={styles.title} ellipsis style={{ flex: 1 }}>
+ {name}
+ </Text>
+ </Link>
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+ <Flexbox flex={1} gap={12} paddingInline={16}>
+ <Text
+ as={'p'}
+ className={styles.desc}
+ ellipsis={{
+ rows: 3,
+ }}
+ >
+ {description}
+ </Text>
+ <Flexbox align={'center'} gap={4} horizontal>
+ {installCount !== undefined && (
+ <Tooltip
+ placement={'top'}
+ styles={{ root: { pointerEvents: 'none' } }}
+ title={t('assistants.downloads')}
+ >
+ <Tag className={styles.statTag} icon={<Icon icon={DownloadIcon} />}>
+ {formatIntergerNumber(installCount)}
+ </Tag>
+ </Tooltip>
+ )}
+ </Flexbox>
+ </Flexbox>
+ <Flexbox
+ align={'center'}
+ className={styles.footer}
+ horizontal
+ justify={'space-between'}
+ padding={16}
+ >
+ <Flexbox
+ align={'center'}
+ className={styles.secondaryDesc}
+ horizontal
+ justify={'space-between'}
+ >
+ <Flexbox align={'center'} gap={4} horizontal>
+ <Icon icon={ClockIcon} size={14} />
+ <PublishedTime
+ className={styles.secondaryDesc}
+ date={createdAt}
+ template={'MMM DD, YYYY'}
+ />
+ </Flexbox>
+ {category && t(`category.assistant.${category}` as any)}
+ </Flexbox>
+ </Flexbox>
+ </Block>
+ );
+ },
+);
+
+interface UserFavoriteAgentsProps {
+ rows?: number;
+}
+
+const UserFavoriteAgents = memo<UserFavoriteAgentsProps>(({ rows = 4 }) => {
+ const { t } = useTranslation('discover');
+ const { message } = App.useApp();
+ const { user, isOwner } = useUserDetailContext();
+ const { session } = useMarketAuth();
+
+ const useFavoriteAgents = useDiscoverStore((s) => s.useFavoriteAgents);
+ const removeFavorite = useDiscoverStore((s) => s.removeFavorite);
+
+ const { data, mutate } = useFavoriteAgents(user.id);
+
+ // Set access token for social service
+ if (session?.accessToken) {
+ socialService.setAccessToken(session.accessToken);
+ }
+
+ const handleUnfavorite = useCallback(
+ async (identifier: string) => {
+ try {
+ const agent = data?.items.find((a) => a.identifier === identifier);
+ if (agent) {
+ await removeFavorite('agent', (agent as any).id);
+ await mutate();
+ message.success(t('user.unfavoriteSuccess'));
+ }
+ } catch (error) {
+ console.error('Unfavorite failed:', error);
+ message.error(t('user.unfavoriteFailed'));
+ }
+ },
+ [data, removeFavorite, mutate, message, t],
+ );
+
+ // SDK returns { data: [{ agent: {...}, favoritedAt: string }] } or flat array
+ const rawData = data?.items ?? (data as any)?.data ?? [];
+ const agents: FavoriteAgentItem[] = rawData.map((item: any) => {
+ const agent = item.agent || item;
+ return {
+ avatar: agent.icon || agent.avatar || '',
+ category: agent.category || '',
+ createdAt: item.favoritedAt || agent.favoritedAt || agent.createdAt,
+ description: agent.description || '',
+ identifier: agent.identifier,
+ installCount: agent.installCount,
+ name: agent.name,
+ tags: agent.tags || [],
+ };
+ });
+
+ // Don't render if no favorite agents
+ if (agents.length === 0) {
+ return null;
+ }
+
+ return (
+ <Flexbox gap={16}>
+ <Flexbox align={'center'} gap={8} horizontal>
+ <Text fontSize={16} weight={500}>
+ {t('user.favoriteAgents')}
+ </Text>
+ <Tag>{agents.length}</Tag>
+ </Flexbox>
+ <Grid rows={rows} width={'100%'}>
+ {agents.map((item) => (
+ <FavoriteAgentCard
+ key={item.identifier}
+ {...item}
+ onUnfavorite={handleUnfavorite}
+ showUnfavorite={isOwner}
+ />
+ ))}
+ </Grid>
+ </Flexbox>
+ );
+});
+
+export default UserFavoriteAgents;
diff --git a/src/app/[variants]/(main)/community/(detail)/user/features/UserFavoritePlugins.tsx b/src/app/[variants]/(main)/community/(detail)/user/features/UserFavoritePlugins.tsx
new file mode 100644
index 00000000000..3c7f5f332c1
--- /dev/null
+++ b/src/app/[variants]/(main)/community/(detail)/user/features/UserFavoritePlugins.tsx
@@ -0,0 +1,276 @@
+'use client';
+
+import { Avatar, Block, Flexbox, Grid, Icon, Tag, Text, Tooltip } from '@lobehub/ui';
+import { App } from 'antd';
+import { createStyles } from 'antd-style';
+import { ClockIcon, Heart } from 'lucide-react';
+import qs from 'query-string';
+import { memo, useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
+import { Link, useNavigate } from 'react-router-dom';
+import urlJoin from 'url-join';
+
+import PublishedTime from '@/components/PublishedTime';
+import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
+import { FavoritePluginItem, socialService } from '@/services/social';
+import { useDiscoverStore } from '@/store/discover';
+
+import { useUserDetailContext } from './DetailProvider';
+
+const useStyles = createStyles(({ css, token }) => {
+ return {
+ desc: css`
+ flex: 1;
+ margin: 0 !important;
+ color: ${token.colorTextSecondary};
+ `,
+ favoriteButton: css`
+ cursor: pointer;
+
+ position: absolute;
+ inset-block-start: 12px;
+ inset-inline-end: 12px;
+
+ color: ${token.colorError};
+
+ opacity: 0;
+
+ transition: opacity 0.2s;
+ `,
+ footer: css`
+ margin-block-start: 16px;
+ border-block-start: 1px dashed ${token.colorBorder};
+ background: ${token.colorBgContainerSecondary};
+ `,
+ secondaryDesc: css`
+ font-size: 12px;
+ color: ${token.colorTextDescription};
+ `,
+ title: css`
+ margin: 0 !important;
+ font-size: 16px !important;
+ font-weight: 500 !important;
+
+ &:hover {
+ color: ${token.colorLink};
+ }
+ `,
+ wrapper: css`
+ &:hover .favorite-button {
+ opacity: 1;
+ }
+ `,
+ };
+});
+
+interface FavoritePluginCardProps extends FavoritePluginItem {
+ onUnfavorite: (identifier: string) => void;
+ showUnfavorite: boolean;
+}
+
+const FavoritePluginCard = memo<FavoritePluginCardProps>(
+ ({
+ avatar,
+ name,
+ description,
+ createdAt,
+ category,
+ identifier,
+ onUnfavorite,
+ showUnfavorite,
+ }) => {
+ const { styles } = useStyles();
+ const { t } = useTranslation('discover');
+ const navigate = useNavigate();
+
+ const link = qs.stringifyUrl(
+ {
+ url: urlJoin('/community/plugin', identifier),
+ },
+ { skipNull: true },
+ );
+
+ return (
+ <Block
+ className={styles.wrapper}
+ clickable
+ height={'100%'}
+ onClick={() => navigate(link)}
+ style={{
+ cursor: 'pointer',
+ overflow: 'hidden',
+ position: 'relative',
+ }}
+ variant={'outlined'}
+ width={'100%'}
+ >
+ {showUnfavorite && (
+ <Tooltip title={t('user.unfavorite')}>
+ <div
+ className={`favorite-button ${styles.favoriteButton}`}
+ onClick={(e) => {
+ e.stopPropagation();
+ onUnfavorite(identifier);
+ }}
+ >
+ <Icon fill="currentColor" icon={Heart} size={16} />
+ </div>
+ </Tooltip>
+ )}
+ <Flexbox
+ align={'flex-start'}
+ gap={16}
+ horizontal
+ justify={'space-between'}
+ padding={16}
+ width={'100%'}
+ >
+ <Flexbox
+ gap={12}
+ horizontal
+ style={{
+ overflow: 'hidden',
+ }}
+ >
+ <Avatar avatar={avatar} shape={'square'} size={40} style={{ flex: 'none' }} />
+ <Flexbox
+ flex={1}
+ gap={2}
+ style={{
+ overflow: 'hidden',
+ }}
+ >
+ <Flexbox align={'center'} gap={8} horizontal>
+ <Link
+ onClick={(e) => e.stopPropagation()}
+ style={{ color: 'inherit', flex: 1, overflow: 'hidden' }}
+ to={link}
+ >
+ <Text as={'h3'} className={styles.title} ellipsis style={{ flex: 1 }}>
+ {name}
+ </Text>
+ </Link>
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+ <Flexbox flex={1} gap={12} paddingInline={16}>
+ <Text
+ as={'p'}
+ className={styles.desc}
+ ellipsis={{
+ rows: 3,
+ }}
+ >
+ {description}
+ </Text>
+ </Flexbox>
+ <Flexbox
+ align={'center'}
+ className={styles.footer}
+ horizontal
+ justify={'space-between'}
+ padding={16}
+ >
+ <Flexbox
+ align={'center'}
+ className={styles.secondaryDesc}
+ horizontal
+ justify={'space-between'}
+ >
+ <Flexbox align={'center'} gap={4} horizontal>
+ <Icon icon={ClockIcon} size={14} />
+ <PublishedTime
+ className={styles.secondaryDesc}
+ date={createdAt}
+ template={'MMM DD, YYYY'}
+ />
+ </Flexbox>
+ {category && t(`category.plugin.${category}` as any)}
+ </Flexbox>
+ </Flexbox>
+ </Block>
+ );
+ },
+);
+
+interface UserFavoritePluginsProps {
+ rows?: number;
+}
+
+const UserFavoritePlugins = memo<UserFavoritePluginsProps>(({ rows = 4 }) => {
+ const { t } = useTranslation('discover');
+ const { message } = App.useApp();
+ const { user, isOwner } = useUserDetailContext();
+ const { session } = useMarketAuth();
+
+ const useFavoritePlugins = useDiscoverStore((s) => s.useFavoritePlugins);
+ const removeFavorite = useDiscoverStore((s) => s.removeFavorite);
+
+ const { data, mutate } = useFavoritePlugins(user.id);
+
+ // Set access token for social service
+ if (session?.accessToken) {
+ socialService.setAccessToken(session.accessToken);
+ }
+
+ const handleUnfavorite = useCallback(
+ async (identifier: string) => {
+ try {
+ const plugin = data?.items.find((p) => p.identifier === identifier);
+ if (plugin) {
+ await removeFavorite('plugin', (plugin as any).id);
+ await mutate();
+ message.success(t('user.unfavoriteSuccess'));
+ }
+ } catch (error) {
+ console.error('Unfavorite failed:', error);
+ message.error(t('user.unfavoriteFailed'));
+ }
+ },
+ [data, removeFavorite, mutate, message, t],
+ );
+
+ // SDK returns { data: [{ plugin: {...}, favoritedAt: string }] } or flat array
+ const rawData = data?.items ?? (data as any)?.data ?? [];
+ const plugins: FavoritePluginItem[] = rawData.map((item: any) => {
+ const plugin = item.plugin || item;
+ return {
+ avatar: plugin.icon || plugin.avatar || '',
+ category: plugin.category || '',
+ createdAt: item.favoritedAt || plugin.favoritedAt || plugin.createdAt,
+ description: plugin.description || '',
+ identifier: plugin.identifier,
+ name: plugin.name,
+ tags: plugin.tags || [],
+ };
+ });
+
+ // Don't render if no favorite plugins
+ if (plugins.length === 0) {
+ return null;
+ }
+
+ return (
+ <Flexbox gap={16}>
+ <Flexbox align={'center'} gap={8} horizontal>
+ <Text fontSize={16} weight={500}>
+ {t('user.favoritePlugins')}
+ </Text>
+ <Tag>{plugins.length}</Tag>
+ </Flexbox>
+ <Grid rows={rows} width={'100%'}>
+ {plugins.map((item) => (
+ <FavoritePluginCard
+ key={item.identifier}
+ {...item}
+ onUnfavorite={handleUnfavorite}
+ showUnfavorite={isOwner}
+ />
+ ))}
+ </Grid>
+ </Flexbox>
+ );
+});
+
+export default UserFavoritePlugins;
diff --git a/src/app/[variants]/(main)/community/(detail)/user/index.tsx b/src/app/[variants]/(main)/community/(detail)/user/index.tsx
index 4218c4100a3..3d6eee3877a 100644
--- a/src/app/[variants]/(main)/community/(detail)/user/index.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/user/index.tsx
@@ -10,7 +10,7 @@ import { useDiscoverStore } from '@/store/discover';
import NotFound from '../components/NotFound';
import { UserDetailProvider } from './features/DetailProvider';
import UserHeader from './features/Header';
-import UserAgentList from './features/UserAgentList';
+import UserContent from './features/UserContent';
import { useUserDetail } from './features/useUserDetail';
import Loading from './loading';
@@ -78,7 +78,7 @@ const UserDetailPage = memo<UserDetailPageProps>(({ mobile }) => {
return (
<UserDetailProvider config={contextConfig}>
<UserHeader />
- <UserAgentList />
+ <UserContent />
</UserDetailProvider>
);
});
diff --git a/src/features/MCPPluginDetail/Header.tsx b/src/features/MCPPluginDetail/Header.tsx
index d99704bb330..d46e36e2e8b 100644
--- a/src/features/MCPPluginDetail/Header.tsx
+++ b/src/features/MCPPluginDetail/Header.tsx
@@ -2,17 +2,29 @@
import { Github } from '@lobehub/icons';
import { ActionIcon, Avatar, Button, Flexbox, Icon, Tag, Text, Tooltip } from '@lobehub/ui';
+import { App } from 'antd';
import { createStyles, useResponsive } from 'antd-style';
-import { CircleIcon, DotIcon, DownloadIcon, ScaleIcon, StarIcon } from 'lucide-react';
+import {
+ CircleIcon,
+ DotIcon,
+ DownloadIcon,
+ Heart,
+ type LucideProps,
+ ScaleIcon,
+ StarIcon,
+} from 'lucide-react';
import qs from 'query-string';
-import { memo } from 'react';
+import { useState , memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
+import useSWR from 'swr';
import OfficialIcon from '@/components/OfficialIcon';
import Scores from '@/features/MCP/Scores';
import { getLanguageColor, getRecommendedDeployment } from '@/features/MCP/utils';
import { useCategory } from '@/hooks/useMCPCategory';
+import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
+import { socialService } from '@/services/social';
import InstallationIcon from '../../components/MCPDepsIcon';
import PublishedTime from '../../components/PublishedTime';
@@ -36,6 +48,7 @@ const useStyles = createStyles(({ css, token }) => {
const Header = memo<{ inModal?: boolean; mobile?: boolean }>(({ mobile: isMobile, inModal }) => {
const { t } = useTranslation('discover');
+ const { message } = App.useApp();
const {
name,
author,
@@ -58,6 +71,48 @@ const Header = memo<{ inModal?: boolean; mobile?: boolean }>(({ mobile: isMobile
} = useDetailContext();
const { styles, theme } = useStyles();
const { mobile = isMobile } = useResponsive();
+ const { isAuthenticated, signIn, session } = useMarketAuth();
+ const [favoriteLoading, setFavoriteLoading] = useState(false);
+
+ // Set access token for social service
+ if (session?.accessToken) {
+ socialService.setAccessToken(session.accessToken);
+ }
+
+ // Fetch favorite status
+ const { data: favoriteStatus, mutate: mutateFavorite } = useSWR(
+ identifier && isAuthenticated ? ['favorite-status', 'plugin', identifier] : null,
+ () => socialService.checkFavoriteStatus('plugin', identifier!),
+ { revalidateOnFocus: false },
+ );
+
+ const isFavorited = favoriteStatus?.isFavorited ?? false;
+
+ const handleFavoriteClick = async () => {
+ if (!isAuthenticated) {
+ await signIn();
+ return;
+ }
+
+ if (!identifier) return;
+
+ setFavoriteLoading(true);
+ try {
+ if (isFavorited) {
+ await socialService.removeFavorite('plugin', identifier);
+ message.success(t('assistant.unfavoriteSuccess'));
+ } else {
+ await socialService.addFavorite('plugin', identifier);
+ message.success(t('assistant.favoriteSuccess'));
+ }
+ await mutateFavorite();
+ } catch (error) {
+ console.error('Favorite action failed:', error);
+ message.error(t('assistant.favoriteFailed'));
+ } finally {
+ setFavoriteLoading(false);
+ }
+ };
const recommendedDeployment = getRecommendedDeployment(deploymentOptions);
const categories = useCategory();
@@ -137,6 +192,16 @@ const Header = memo<{ inModal?: boolean; mobile?: boolean }>(({ mobile: isMobile
{!mobile && scores}
</Flexbox>
<Flexbox align={'center'} gap={6} horizontal>
+ <Tooltip title={isFavorited ? t('assistant.unfavorite') : t('assistant.favorite')}>
+ <ActionIcon
+ icon={(props: LucideProps) => (
+ <Heart {...props} fill={isFavorited ? 'currentColor' : 'none'} />
+ )}
+ loading={favoriteLoading}
+ onClick={handleFavoriteClick}
+ style={isFavorited ? { color: 'var(--lobe-color-error)' } : undefined}
+ />
+ </Tooltip>
{recommendedDeployment?.installationMethod && (
<InstallationIcon type={recommendedDeployment.installationMethod} />
)}
diff --git a/src/locales/default/discover.ts b/src/locales/default/discover.ts
index 1450f2b8a0f..e734553e76c 100644
--- a/src/locales/default/discover.ts
+++ b/src/locales/default/discover.ts
@@ -1,4 +1,12 @@
export default {
+ assistant: {
+ favorite: '收藏',
+ favoriteFailed: '收藏失败',
+ favoriteSuccess: '已收藏',
+ unfavorite: '取消收藏',
+ unfavoriteFailed: '取消收藏失败',
+ unfavoriteSuccess: '已取消收藏',
+ },
assistants: {
addAgent: '添加助手',
addAgentAndConverse: '添加助手并会话',
@@ -727,11 +735,26 @@ export default {
agents: '助手',
downloads: '下载',
editProfile: '编辑个人资料',
+ favoriteAgents: '收藏的助手',
+ favoritePlugins: '收藏的插件',
+ follow: '关注',
+ followers: '粉丝',
+ following: '关注',
login: '成为创作者',
logout: '退出登录',
myProfile: '我的主页',
noAgents: '该用户暂未发布助手',
+ noFavoriteAgents: '暂无收藏的助手',
+ noFavoritePlugins: '暂无收藏的插件',
publishedAgents: '创作的助手',
+ tabs: {
+ favorites: '收藏',
+ publishedAgents: '创作',
+ },
+ unfavorite: '取消收藏',
+ unfavoriteFailed: '取消收藏失败',
+ unfavoriteSuccess: '已取消收藏',
+ unfollow: '取消关注',
website: '个人网站',
},
};
diff --git a/src/server/services/discover/index.ts b/src/server/services/discover/index.ts
index 346b0f403d7..254bf0fe653 100644
--- a/src/server/services/discover/index.ts
+++ b/src/server/services/discover/index.ts
@@ -1719,6 +1719,8 @@ export class DiscoverService {
createdAt: user.createdAt,
description: user.meta?.description || null,
displayName: user.displayName || null,
+ followersCount: user.followerCount ?? 0,
+ followingCount: user.followingCount ?? 0,
id: user.id,
namespace: user.namespace,
socialLinks: user.meta?.socialLinks || null,
diff --git a/src/services/_url.ts b/src/services/_url.ts
index f746b1fa3e0..09f9bf96b2c 100644
--- a/src/services/_url.ts
+++ b/src/services/_url.ts
@@ -64,4 +64,40 @@ export const MARKET_ENDPOINTS = {
getUserProfile: (username: string) =>
withElectronProtocolIfElectron(`/market/user/${encodeURIComponent(username)}`),
updateUserProfile: withElectronProtocolIfElectron('/market/user/me'),
+
+ // Social - Follow
+ follow: withElectronProtocolIfElectron('/market/social/follow'),
+ unfollow: withElectronProtocolIfElectron('/market/social/unfollow'),
+ followStatus: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/follow-status/${userId}`),
+ following: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/following/${userId}`),
+ followers: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/followers/${userId}`),
+ followCounts: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/follow-counts/${userId}`),
+
+ // Social - Favorite
+ favorite: withElectronProtocolIfElectron('/market/social/favorite'),
+ unfavorite: withElectronProtocolIfElectron('/market/social/unfavorite'),
+ favoriteStatus: (targetType: 'agent' | 'plugin', targetIdOrIdentifier: number | string) =>
+ withElectronProtocolIfElectron(
+ `/market/social/favorite-status/${targetType}/${encodeURIComponent(targetIdOrIdentifier)}`,
+ ),
+ myFavorites: withElectronProtocolIfElectron('/market/social/favorites'),
+ userFavorites: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/user-favorites/${userId}`),
+ favoriteAgents: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/favorite-agents/${userId}`),
+ favoritePlugins: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/favorite-plugins/${userId}`),
+
+ // Social - Like
+ like: withElectronProtocolIfElectron('/market/social/like'),
+ unlike: withElectronProtocolIfElectron('/market/social/unlike'),
+ toggleLike: withElectronProtocolIfElectron('/market/social/toggle-like'),
+ likedAgents: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/liked-agents/${userId}`),
+ likedPlugins: (userId: number) =>
+ withElectronProtocolIfElectron(`/market/social/liked-plugins/${userId}`),
};
diff --git a/src/services/social.ts b/src/services/social.ts
new file mode 100644
index 00000000000..e93909a72dc
--- /dev/null
+++ b/src/services/social.ts
@@ -0,0 +1,319 @@
+import { MARKET_ENDPOINTS } from '@/services/_url';
+
+export type SocialTargetType = 'agent' | 'plugin';
+
+export interface FollowStatus {
+ isFollowing: boolean;
+ isMutual: boolean;
+}
+
+export interface FollowCounts {
+ followersCount: number;
+ followingCount: number;
+}
+
+export interface FavoriteStatus {
+ isFavorited: boolean;
+}
+
+export interface ToggleLikeResult {
+ liked: boolean;
+}
+
+export interface PaginationParams {
+ page?: number;
+ pageSize?: number;
+}
+
+export interface PaginatedResponse<T> {
+ currentPage: number;
+ items: T[];
+ pageSize: number;
+ totalCount: number;
+ totalPages: number;
+}
+
+export interface FollowUserItem {
+ avatarUrl: string | null;
+ displayName: string | null;
+ id: number;
+ namespace: string;
+ userName: string | null;
+}
+
+export interface FavoriteItem {
+ createdAt: string;
+ id: number;
+ targetId: number;
+ targetType: SocialTargetType;
+}
+
+export interface FavoriteAgentItem {
+ avatar: string;
+ category: string;
+ createdAt: string;
+ description: string;
+ identifier: string;
+ installCount?: number;
+ name: string;
+ tags: string[];
+}
+
+export interface FavoritePluginItem {
+ avatar: string;
+ category: string;
+ createdAt: string;
+ description: string;
+ identifier: string;
+ name: string;
+ tags: string[];
+}
+
+class SocialService {
+ private accessToken?: string;
+
+ // eslint-disable-next-line no-undef
+ private async request<T>(endpoint: string, init?: RequestInit): Promise<T> {
+ const headers = new Headers(init?.headers);
+
+ if (init?.body && !headers.has('content-type')) {
+ headers.set('content-type', 'application/json');
+ }
+
+ if (this.accessToken && !headers.has('authorization')) {
+ headers.set('authorization', `Bearer ${this.accessToken}`);
+ }
+
+ const response = await fetch(endpoint, {
+ ...init,
+ credentials: init?.credentials ?? 'same-origin',
+ headers,
+ });
+
+ if (!response.ok) {
+ let message = 'Unknown error';
+
+ try {
+ const errorBody = await response.json();
+ message = errorBody?.message ?? message;
+ } catch {
+ message = await response.text();
+ }
+
+ throw new Error(message || 'Social request failed');
+ }
+
+ if (response.status === 204) {
+ return undefined as T;
+ }
+
+ return (await response.json()) as T;
+ }
+
+ setAccessToken(token: string | undefined) {
+ this.accessToken = token;
+ }
+
+ // ==================== Follow ====================
+
+ async follow(followingId: number): Promise<void> {
+ await this.request(MARKET_ENDPOINTS.follow, {
+ body: JSON.stringify({ followingId }),
+ method: 'POST',
+ });
+ }
+
+ async unfollow(followingId: number): Promise<void> {
+ await this.request(MARKET_ENDPOINTS.unfollow, {
+ body: JSON.stringify({ followingId }),
+ method: 'POST',
+ });
+ }
+
+ async checkFollowStatus(userId: number): Promise<FollowStatus> {
+ return this.request(MARKET_ENDPOINTS.followStatus(userId), {
+ method: 'GET',
+ });
+ }
+
+ async getFollowCounts(userId: number): Promise<FollowCounts> {
+ return this.request(MARKET_ENDPOINTS.followCounts(userId), {
+ method: 'GET',
+ });
+ }
+
+ async getFollowing(
+ userId: number,
+ params?: PaginationParams,
+ ): Promise<PaginatedResponse<FollowUserItem>> {
+ const searchParams = new URLSearchParams();
+ if (params?.page) searchParams.set('page', String(params.page));
+ if (params?.pageSize) searchParams.set('pageSize', String(params.pageSize));
+
+ const queryString = searchParams.toString();
+ const url = queryString
+ ? `${MARKET_ENDPOINTS.following(userId)}?${queryString}`
+ : MARKET_ENDPOINTS.following(userId);
+
+ return this.request(url, { method: 'GET' });
+ }
+
+ async getFollowers(
+ userId: number,
+ params?: PaginationParams,
+ ): Promise<PaginatedResponse<FollowUserItem>> {
+ const searchParams = new URLSearchParams();
+ if (params?.page) searchParams.set('page', String(params.page));
+ if (params?.pageSize) searchParams.set('pageSize', String(params.pageSize));
+
+ const queryString = searchParams.toString();
+ const url = queryString
+ ? `${MARKET_ENDPOINTS.followers(userId)}?${queryString}`
+ : MARKET_ENDPOINTS.followers(userId);
+
+ return this.request(url, { method: 'GET' });
+ }
+
+ // ==================== Favorite ====================
+
+ async addFavorite(
+ targetType: SocialTargetType,
+ targetIdOrIdentifier: number | string,
+ ): Promise<void> {
+ const body =
+ typeof targetIdOrIdentifier === 'string'
+ ? { identifier: targetIdOrIdentifier, targetType }
+ : { targetId: targetIdOrIdentifier, targetType };
+
+ await this.request(MARKET_ENDPOINTS.favorite, {
+ body: JSON.stringify(body),
+ method: 'POST',
+ });
+ }
+
+ async removeFavorite(
+ targetType: SocialTargetType,
+ targetIdOrIdentifier: number | string,
+ ): Promise<void> {
+ const body =
+ typeof targetIdOrIdentifier === 'string'
+ ? { identifier: targetIdOrIdentifier, targetType }
+ : { targetId: targetIdOrIdentifier, targetType };
+
+ await this.request(MARKET_ENDPOINTS.unfavorite, {
+ body: JSON.stringify(body),
+ method: 'POST',
+ });
+ }
+
+ async checkFavoriteStatus(
+ targetType: SocialTargetType,
+ targetIdOrIdentifier: number | string,
+ ): Promise<FavoriteStatus> {
+ return this.request(MARKET_ENDPOINTS.favoriteStatus(targetType, targetIdOrIdentifier), {
+ method: 'GET',
+ });
+ }
+
+ async getMyFavorites(params?: PaginationParams): Promise<PaginatedResponse<FavoriteItem>> {
+ const searchParams = new URLSearchParams();
+ if (params?.page) searchParams.set('page', String(params.page));
+ if (params?.pageSize) searchParams.set('pageSize', String(params.pageSize));
+
+ const queryString = searchParams.toString();
+ const url = queryString
+ ? `${MARKET_ENDPOINTS.myFavorites}?${queryString}`
+ : MARKET_ENDPOINTS.myFavorites;
+
+ return this.request(url, { method: 'GET' });
+ }
+
+ async getUserFavoriteAgents(
+ userId: number,
+ params?: PaginationParams,
+ ): Promise<PaginatedResponse<FavoriteAgentItem>> {
+ const searchParams = new URLSearchParams();
+ if (params?.page) searchParams.set('page', String(params.page));
+ if (params?.pageSize) searchParams.set('pageSize', String(params.pageSize));
+
+ const queryString = searchParams.toString();
+ const url = queryString
+ ? `${MARKET_ENDPOINTS.favoriteAgents(userId)}?${queryString}`
+ : MARKET_ENDPOINTS.favoriteAgents(userId);
+
+ return this.request(url, { method: 'GET' });
+ }
+
+ async getUserFavoritePlugins(
+ userId: number,
+ params?: PaginationParams,
+ ): Promise<PaginatedResponse<FavoritePluginItem>> {
+ const searchParams = new URLSearchParams();
+ if (params?.page) searchParams.set('page', String(params.page));
+ if (params?.pageSize) searchParams.set('pageSize', String(params.pageSize));
+
+ const queryString = searchParams.toString();
+ const url = queryString
+ ? `${MARKET_ENDPOINTS.favoritePlugins(userId)}?${queryString}`
+ : MARKET_ENDPOINTS.favoritePlugins(userId);
+
+ return this.request(url, { method: 'GET' });
+ }
+
+ // ==================== Like ====================
+
+ async like(targetType: SocialTargetType, targetId: number): Promise<void> {
+ await this.request(MARKET_ENDPOINTS.like, {
+ body: JSON.stringify({ targetId, targetType }),
+ method: 'POST',
+ });
+ }
+
+ async unlike(targetType: SocialTargetType, targetId: number): Promise<void> {
+ await this.request(MARKET_ENDPOINTS.unlike, {
+ body: JSON.stringify({ targetId, targetType }),
+ method: 'POST',
+ });
+ }
+
+ async toggleLike(targetType: SocialTargetType, targetId: number): Promise<ToggleLikeResult> {
+ return this.request(MARKET_ENDPOINTS.toggleLike, {
+ body: JSON.stringify({ targetId, targetType }),
+ method: 'POST',
+ });
+ }
+
+ async getUserLikedAgents(
+ userId: number,
+ params?: PaginationParams,
+ ): Promise<PaginatedResponse<FavoriteAgentItem>> {
+ const searchParams = new URLSearchParams();
+ if (params?.page) searchParams.set('page', String(params.page));
+ if (params?.pageSize) searchParams.set('pageSize', String(params.pageSize));
+
+ const queryString = searchParams.toString();
+ const url = queryString
+ ? `${MARKET_ENDPOINTS.likedAgents(userId)}?${queryString}`
+ : MARKET_ENDPOINTS.likedAgents(userId);
+
+ return this.request(url, { method: 'GET' });
+ }
+
+ async getUserLikedPlugins(
+ userId: number,
+ params?: PaginationParams,
+ ): Promise<PaginatedResponse<FavoritePluginItem>> {
+ const searchParams = new URLSearchParams();
+ if (params?.page) searchParams.set('page', String(params.page));
+ if (params?.pageSize) searchParams.set('pageSize', String(params.pageSize));
+
+ const queryString = searchParams.toString();
+ const url = queryString
+ ? `${MARKET_ENDPOINTS.likedPlugins(userId)}?${queryString}`
+ : MARKET_ENDPOINTS.likedPlugins(userId);
+
+ return this.request(url, { method: 'GET' });
+ }
+}
+
+export const socialService = new SocialService();
diff --git a/src/store/discover/slices/social/action.ts b/src/store/discover/slices/social/action.ts
new file mode 100644
index 00000000000..ea7c0d27be2
--- /dev/null
+++ b/src/store/discover/slices/social/action.ts
@@ -0,0 +1,161 @@
+import useSWR, { type SWRResponse, mutate } from 'swr';
+import type { StateCreator } from 'zustand/vanilla';
+
+import {
+ FavoriteAgentItem,
+ FavoritePluginItem,
+ FollowCounts,
+ FollowStatus,
+ FollowUserItem,
+ PaginatedResponse,
+ SocialTargetType,
+ socialService,
+} from '@/services/social';
+import { DiscoverStore } from '@/store/discover';
+
+export interface SocialAction {
+ // Favorite actions
+ addFavorite: (targetType: SocialTargetType, targetId: number) => Promise<void>;
+ // Follow actions
+ follow: (followingId: number) => Promise<void>;
+
+ removeFavorite: (targetType: SocialTargetType, targetId: number) => Promise<void>;
+ // Like actions
+ toggleLike: (targetType: SocialTargetType, targetId: number) => Promise<{ liked: boolean }>;
+
+ unfollow: (followingId: number) => Promise<void>;
+
+ // Favorite queries
+ useFavoriteAgents: (
+ userId: number | undefined,
+ params?: { page?: number; pageSize?: number },
+ ) => SWRResponse<PaginatedResponse<FavoriteAgentItem>>;
+ useFavoritePlugins: (
+ userId: number | undefined,
+ params?: { page?: number; pageSize?: number },
+ ) => SWRResponse<PaginatedResponse<FavoritePluginItem>>;
+ useFollowCounts: (userId: number | undefined) => SWRResponse<FollowCounts>;
+ // Follow queries
+ useFollowStatus: (userId: number | undefined) => SWRResponse<FollowStatus>;
+
+ useFollowers: (
+ userId: number | undefined,
+ params?: { page?: number; pageSize?: number },
+ ) => SWRResponse<PaginatedResponse<FollowUserItem>>;
+ useFollowing: (
+ userId: number | undefined,
+ params?: { page?: number; pageSize?: number },
+ ) => SWRResponse<PaginatedResponse<FollowUserItem>>;
+}
+
+export const createSocialSlice: StateCreator<
+ DiscoverStore,
+ [['zustand/devtools', never]],
+ [],
+ SocialAction
+> = () => ({
+
+ // Favorite actions
+addFavorite: async (targetType, targetId) => {
+ await socialService.addFavorite(targetType, targetId);
+ // Invalidate favorite-related caches
+ await mutate((key) => typeof key === 'string' && key.startsWith('favorite-'), undefined, {
+ revalidate: true,
+ });
+ },
+
+
+// Follow actions
+follow: async (followingId) => {
+ await socialService.follow(followingId);
+ // Invalidate follow-related caches
+ await mutate((key) => typeof key === 'string' && key.startsWith('follow-'), undefined, {
+ revalidate: true,
+ });
+ },
+
+
+ removeFavorite: async (targetType, targetId) => {
+ await socialService.removeFavorite(targetType, targetId);
+ // Invalidate favorite-related caches
+ await mutate((key) => typeof key === 'string' && key.startsWith('favorite-'), undefined, {
+ revalidate: true,
+ });
+ },
+
+ // Like actions
+toggleLike: async (targetType, targetId) => {
+ const result = await socialService.toggleLike(targetType, targetId);
+ // Invalidate like-related caches
+ await mutate((key) => typeof key === 'string' && key.startsWith('liked-'), undefined, {
+ revalidate: true,
+ });
+ return result;
+ },
+
+
+ unfollow: async (followingId) => {
+ await socialService.unfollow(followingId);
+ // Invalidate follow-related caches
+ await mutate((key) => typeof key === 'string' && key.startsWith('follow-'), undefined, {
+ revalidate: true,
+ });
+ },
+
+
+ // Favorite queries
+useFavoriteAgents: (userId, params) => {
+ return useSWR(
+ userId ? ['favorite-agents', userId, params?.page, params?.pageSize].join('-') : null,
+ async () => socialService.getUserFavoriteAgents(userId!, params),
+ { revalidateOnFocus: false },
+ );
+ },
+
+
+
+useFavoritePlugins: (userId, params) => {
+ return useSWR(
+ userId ? ['favorite-plugins', userId, params?.page, params?.pageSize].join('-') : null,
+ async () => socialService.getUserFavoritePlugins(userId!, params),
+ { revalidateOnFocus: false },
+ );
+ },
+
+
+
+useFollowCounts: (userId) => {
+ return useSWR(
+ userId ? ['follow-counts', userId].join('-') : null,
+ async () => socialService.getFollowCounts(userId!),
+ { revalidateOnFocus: false },
+ );
+ },
+
+
+// Follow queries
+useFollowStatus: (userId) => {
+ return useSWR(
+ userId ? ['follow-status', userId].join('-') : null,
+ async () => socialService.checkFollowStatus(userId!),
+ { revalidateOnFocus: false },
+ );
+ },
+
+
+ useFollowers: (userId, params) => {
+ return useSWR(
+ userId ? ['followers', userId, params?.page, params?.pageSize].join('-') : null,
+ async () => socialService.getFollowers(userId!, params),
+ { revalidateOnFocus: false },
+ );
+ },
+
+ useFollowing: (userId, params) => {
+ return useSWR(
+ userId ? ['following', userId, params?.page, params?.pageSize].join('-') : null,
+ async () => socialService.getFollowing(userId!, params),
+ { revalidateOnFocus: false },
+ );
+ },
+});
diff --git a/src/store/discover/slices/social/index.ts b/src/store/discover/slices/social/index.ts
new file mode 100644
index 00000000000..2c0622fbb9c
--- /dev/null
+++ b/src/store/discover/slices/social/index.ts
@@ -0,0 +1 @@
+export * from './action';
diff --git a/src/store/discover/store.ts b/src/store/discover/store.ts
index d8d85f6220b..863490fc30d 100644
--- a/src/store/discover/store.ts
+++ b/src/store/discover/store.ts
@@ -8,6 +8,7 @@ import { MCPAction, createMCPSlice } from './slices/mcp';
import { ModelAction, createModelSlice } from './slices/model/action';
import { PluginAction, createPluginSlice } from './slices/plugin/action';
import { ProviderAction, createProviderSlice } from './slices/provider/action';
+import { SocialAction, createSocialSlice } from './slices/social';
import { UserAction, createUserSlice } from './slices/user';
// =============== Aggregate createStoreFn ============ //
@@ -17,6 +18,7 @@ export type DiscoverStore = MCPAction &
ProviderAction &
ModelAction &
PluginAction &
+ SocialAction &
UserAction;
const createStore: StateCreator<DiscoverStore, [['zustand/devtools', never]]> = (
@@ -27,6 +29,7 @@ const createStore: StateCreator<DiscoverStore, [['zustand/devtools', never]]> =
...createProviderSlice(...parameters),
...createModelSlice(...parameters),
...createPluginSlice(...parameters),
+ ...createSocialSlice(...parameters),
...createUserSlice(...parameters),
});