Skip to content

Let's use AI to Earn!

feat: My channel has been developed (#460)

Gao6bde0bbb5814
diff --git a/project/web/public/sitemap-0.xml b/project/web/public/sitemap-0.xml
index 40bf8e31..a3ab45cf 100644
--- a/project/web/public/sitemap-0.xml
+++ b/project/web/public/sitemap-0.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
-<url><loc>https://aitoearn.ai/healthz</loc><lastmod>2025-12-24T16:37:48.595Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/healthz</loc><lastmod>2025-12-25T03:38:20.533Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en</loc><lastmod>2025-12-24T04:08:42.228Z</lastmod><changefreq>monthly</changefreq><priority>0.8</priority></url>
<url><loc>https://aitoearn.ai/en/websit/terms-of-service</loc><lastmod>2025-12-22T02:19:26.235Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/websit/privacy-policy</loc><lastmod>2025-12-22T02:19:26.234Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
@@ -8,13 +8,13 @@
<url><loc>https://aitoearn.ai/en/websit/extension-privacy-policy</loc><lastmod>2025-12-22T02:19:26.233Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/websit/data-protection-agreement</loc><lastmod>2025-12-12T06:46:42.348Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/websit/data-deletion</loc><lastmod>2025-12-22T02:19:26.232Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/en/tasks-history</loc><lastmod>2025-12-24T13:58:01.410Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/tasks-history</loc><lastmod>2025-12-25T02:23:02.206Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/tasks</loc><lastmod>2025-11-18T02:51:00.256Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/pricing</loc><lastmod>2025-12-18T11:52:18.737Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/pinterest</loc><lastmod>2025-12-22T02:19:26.229Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/material</loc><lastmod>2025-11-18T02:51:00.224Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/interactiveNew</loc><lastmod>2025-12-18T11:52:18.730Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/en/income</loc><lastmod>2025-12-23T05:50:28.851Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/income</loc><lastmod>2025-12-25T02:23:02.205Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/hotContent</loc><lastmod>2025-11-18T02:51:00.185Z</lastmod><changefreq>daily</changefreq><priority>0.9</priority></url>
<url><loc>https://aitoearn.ai/en/dataStatistics</loc><lastmod>2025-11-18T02:51:00.115Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/en/data-monitoring</loc><lastmod>2025-12-22T02:19:26.225Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
@@ -32,13 +32,13 @@
<url><loc>https://aitoearn.ai/zh-CN/websit/extension-privacy-policy</loc><lastmod>2025-12-22T02:19:26.233Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/websit/data-protection-agreement</loc><lastmod>2025-12-12T06:46:42.348Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/websit/data-deletion</loc><lastmod>2025-12-22T02:19:26.232Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/tasks-history</loc><lastmod>2025-12-24T13:58:01.410Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/tasks-history</loc><lastmod>2025-12-25T02:23:02.206Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/tasks</loc><lastmod>2025-11-18T02:51:00.256Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/pricing</loc><lastmod>2025-12-18T11:52:18.737Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/pinterest</loc><lastmod>2025-12-22T02:19:26.229Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/material</loc><lastmod>2025-11-18T02:51:00.224Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/interactiveNew</loc><lastmod>2025-12-18T11:52:18.730Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/income</loc><lastmod>2025-12-23T05:50:28.851Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/income</loc><lastmod>2025-12-25T02:23:02.205Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/hotContent</loc><lastmod>2025-11-18T02:51:00.185Z</lastmod><changefreq>daily</changefreq><priority>0.9</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/dataStatistics</loc><lastmod>2025-11-18T02:51:00.115Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
<url><loc>https://aitoearn.ai/zh-CN/data-monitoring</loc><lastmod>2025-12-22T02:19:26.225Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
diff --git a/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/AccountItem.tsx b/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/AccountItem.tsx
index 4ea53474..ece338c7 100644
--- a/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/AccountItem.tsx
+++ b/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/AccountItem.tsx
@@ -1,16 +1,9 @@
import type { SocialAccount } from '@/api/types/account.type'
-import { DeleteOutlined, EllipsisOutlined, LoadingOutlined } from '@ant-design/icons'
import Image from 'next/image'
-import { memo, useState } from 'react'
+import { memo } from 'react'
import { AccountPlatInfoMap } from '@/app/config/platConfig'
import { useTransClient } from '@/app/i18n/client'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from '@/components/ui/dropdown-menu'
import { cn } from '@/lib/utils'
import { getOssUrl } from '@/utils/oss'
import AccountStatusView from './AccountStatusView'
@@ -19,31 +12,21 @@ interface AccountItemProps {
account: SocialAccount
isActive: boolean
onSelect: (account: SocialAccount) => void
- onDelete: (account: SocialAccount) => void
- deleteLoading?: string | null
indent?: boolean
}
-const AccountItem = memo(({ account, isActive, onSelect, onDelete, deleteLoading, indent = false }: AccountItemProps) => {
+const AccountItem = memo(({ account, isActive, onSelect, indent = false }: AccountItemProps) => {
const { t } = useTransClient('account')
const platInfo = AccountPlatInfoMap.get(account.type)
- const [operationMenuOpen, setOperationMenuOpen] = useState(false)
- const isDeleting = deleteLoading === account.id
-
- const handleDelete = (e: React.MouseEvent) => {
- e.stopPropagation()
- setOperationMenuOpen(false)
- onDelete(account)
- }
return (
<div
- onClick={() => !isDeleting && onSelect(account)}
+ onClick={() => onSelect(account)}
className={cn(
'flex items-center gap-3 px-3 py-2 mx-2 rounded-sm transition-colors group relative',
indent && 'ml-8',
isActive && 'bg-accent text-accent-foreground',
- isDeleting ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer hover:bg-muted/50',
+ 'cursor-pointer hover:bg-muted/50',
)}
>
<Avatar className="h-8 w-8 shrink-0">
@@ -79,31 +62,6 @@ const AccountItem = memo(({ account, isActive, onSelect, onDelete, deleteLoading
</div>
</div>
- {isDeleting ? (
- <div className="p-1">
- <LoadingOutlined className="h-4 w-4 text-muted-foreground animate-spin" />
- </div>
- ) : (
- <DropdownMenu open={operationMenuOpen} onOpenChange={setOperationMenuOpen}>
- <DropdownMenuTrigger asChild>
- <button
- onClick={(e) => {
- e.stopPropagation()
- setOperationMenuOpen(true)
- }}
- className="opacity-0 group-hover:opacity-100 transition-opacity p-1 hover:bg-muted rounded cursor-pointer"
- >
- <EllipsisOutlined className="h-4 w-4 text-muted-foreground" />
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onClick={handleDelete} className="text-destructive">
- <DeleteOutlined className="mr-2" />
- {t('deleteAccount')}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
</div>
)
})
diff --git a/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/AccountSelector.tsx b/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/AccountSelector.tsx
index c413e279..12ec22e5 100644
--- a/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/AccountSelector.tsx
+++ b/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/AccountSelector.tsx
@@ -29,7 +29,6 @@ interface AccountSelectorProps {
sortLoading?: string | null
deleteLoading?: string | null
onAccountSelect: (account: SocialAccount | undefined) => void
- onAccountDelete: (account: SocialAccount) => void
onToggleSpaceCollapse: (spaceId: string) => void
onGroupSort: (groupId: string, direction: 'up' | 'down') => void
searchText: string
@@ -47,7 +46,6 @@ const AccountSelector = memo(({
sortLoading,
deleteLoading,
onAccountSelect,
- onAccountDelete,
onToggleSpaceCollapse,
onGroupSort,
searchText,
@@ -134,7 +132,6 @@ const AccountSelector = memo(({
deleteLoading={deleteLoading}
onToggleCollapse={onToggleSpaceCollapse}
onSelectAccount={onAccountSelect}
- onDeleteAccount={onAccountDelete}
onGroupSort={onGroupSort}
/>
)
@@ -158,8 +155,6 @@ const AccountSelector = memo(({
account={account}
isActive={isActive}
onSelect={onAccountSelect}
- onDelete={onAccountDelete}
- deleteLoading={deleteLoading}
/>
)
})
diff --git a/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/SpaceGroupItem.tsx b/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/SpaceGroupItem.tsx
index 4865d6e4..0fffd9de 100644
--- a/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/SpaceGroupItem.tsx
+++ b/project/web/src/app/[lng]/accounts/components/AccountsTopNav/components/SpaceGroupItem.tsx
@@ -17,7 +17,6 @@ interface SpaceGroupItemProps {
deleteLoading?: string | null
onToggleCollapse: (groupId: string) => void
onSelectAccount: (account: SocialAccount) => void
- onDeleteAccount: (account: SocialAccount) => void
onGroupSort: (groupId: string, direction: 'up' | 'down') => void
}
@@ -33,7 +32,6 @@ const SpaceGroupItem = memo(({
deleteLoading,
onToggleCollapse,
onSelectAccount,
- onDeleteAccount,
onGroupSort,
}: SpaceGroupItemProps) => {
const { t } = useTransClient('account')
@@ -66,8 +64,6 @@ const SpaceGroupItem = memo(({
account={account}
isActive={isActive}
onSelect={onSelectAccount}
- onDelete={onDeleteAccount}
- deleteLoading={deleteLoading}
indent
/>
)
diff --git a/project/web/src/app/[lng]/accounts/components/AccountsTopNav/index.tsx b/project/web/src/app/[lng]/accounts/components/AccountsTopNav/index.tsx
index 66e55d6e..5d055214 100644
--- a/project/web/src/app/[lng]/accounts/components/AccountsTopNav/index.tsx
+++ b/project/web/src/app/[lng]/accounts/components/AccountsTopNav/index.tsx
@@ -73,26 +73,6 @@ const AccountsTopNav = memo<IAccountsTopNavProps>(
[setAccountActive],
)
- // 处理账户删除
- const handleAccountDelete = useCallback(async (account: SocialAccount) => {
- setDeleteLoading(account.id)
- try {
- await deleteAccountsApi([account.id])
- await getAccountList()
- toast.success(t('messages.deleteSuccess'))
- // 如果删除的是当前选中的账号,清空选中状态
- if (accountActive?.id === account.id) {
- setAccountActive(undefined)
- }
- }
- catch (error) {
- toast.error(t('messages.sortFailed'))
- }
- finally {
- setDeleteLoading(null)
- }
- }, [accountActive, getAccountList, setAccountActive, t])
-
// 处理空间排序
const handleGroupSort = useCallback(async (groupId: string, direction: 'up' | 'down') => {
setSortLoading(groupId)
@@ -193,7 +173,6 @@ const AccountsTopNav = memo<IAccountsTopNavProps>(
sortLoading={sortLoading}
deleteLoading={deleteLoading}
onAccountSelect={handleAccountSelect}
- onAccountDelete={handleAccountDelete}
onToggleSpaceCollapse={toggleSpaceCollapse}
onGroupSort={handleGroupSort}
searchText={accountSearchText}
diff --git a/project/web/src/app/[lng]/chat/[taskId]/components/ChatMessageList/index.tsx b/project/web/src/app/[lng]/chat/[taskId]/components/ChatMessageList/index.tsx
index 94af8ac5..32db27a8 100644
--- a/project/web/src/app/[lng]/chat/[taskId]/components/ChatMessageList/index.tsx
+++ b/project/web/src/app/[lng]/chat/[taskId]/components/ChatMessageList/index.tsx
@@ -72,6 +72,7 @@ export function ChatMessageList({
steps={message.steps}
workflowSteps={isLastAssistant && isGenerating ? workflowSteps : undefined}
actions={message.actions}
+ isGenerating={isLastAssistant && isGenerating}
/>
)
})}
@@ -83,6 +84,7 @@ export function ChatMessageList({
content=""
status="streaming"
workflowSteps={workflowSteps}
+ isGenerating={true}
/>
)}
diff --git a/project/web/src/app/layout/LayoutSidebar/index.tsx b/project/web/src/app/layout/LayoutSidebar/index.tsx
index 93418866..c43c8456 100644
--- a/project/web/src/app/layout/LayoutSidebar/index.tsx
+++ b/project/web/src/app/layout/LayoutSidebar/index.tsx
@@ -204,9 +204,9 @@ function LayoutSidebar() {
{/* 底部固定区域 - 不随滚动 */}
<div className="flex-shrink-0">
{/* 我的频道入口 */}
- {/* <div className="pb-1 flex flex-1">
+ <div className="pb-1 flex flex-1">
<MyChannelsEntry collapsed={collapsed} />
- </div> */}
+ </div>
{/* 推广赚钱入口 - 在底部功能区横线上方 */}
<div className="pb-1">
diff --git a/project/web/src/components/ChannelManager/components/ChannelItem.tsx b/project/web/src/components/ChannelManager/components/ChannelItem.tsx
new file mode 100644
index 00000000..98ff4fe1
--- /dev/null
+++ b/project/web/src/components/ChannelManager/components/ChannelItem.tsx
@@ -0,0 +1,93 @@
+/**
+ * ChannelItem - 频道项组件
+ *
+ * 功能:
+ * - 显示频道信息(头像、名称、平台、粉丝数等)
+ * - 处理频道删除操作
+ */
+
+'use client'
+
+import Image from 'next/image'
+import { DeleteOutlined, LoadingOutlined } from '@ant-design/icons'
+import { Trash2 } from 'lucide-react'
+import { AccountPlatInfoMap } from '@/app/config/platConfig'
+import { getOssUrl } from '@/utils/oss'
+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
+import { Button } from '@/components/ui/button'
+
+interface Channel {
+ id: string
+ name: string
+ platform: string
+ accountId: string
+ avatar?: string
+ fansCount?: number
+}
+
+interface ChannelItemProps {
+ channel: Channel
+ onDelete: (channel: Channel) => void
+ deleteLoading?: string | null
+}
+
+export function ChannelItem({ channel, onDelete, deleteLoading }: ChannelItemProps) {
+ const platInfo = AccountPlatInfoMap.get(channel.platform as any)
+ const isDeleting = deleteLoading === channel.id
+
+ return (
+ <div
+ className={`flex items-center gap-3 p-4 hover:bg-accent/30 transition-colors group relative ${
+ isDeleting ? 'opacity-50 cursor-not-allowed' : ''
+ }`}
+ >
+ <Avatar className="h-10 w-10 shrink-0">
+ <AvatarImage src={getOssUrl(channel.avatar)} alt={channel.name} />
+ <AvatarFallback>{channel.name[0]}</AvatarFallback>
+ </Avatar>
+
+ <div className="flex-1 min-w-0">
+ <div className="font-medium text-sm truncate">{channel.name}</div>
+ <div className="flex items-center gap-2 mt-1 flex-wrap">
+ {platInfo?.icon && (
+ <Image
+ src={platInfo.icon}
+ alt={platInfo.name}
+ width={14}
+ height={14}
+ className="rounded-sm shrink-0"
+ />
+ )}
+ <span className="text-xs text-muted-foreground shrink-0">
+ {platInfo?.name}
+ </span>
+ {/* 状态显示 */}
+ <span className="flex items-center gap-1 text-xs text-green-600 shrink-0">
+ <div className="w-2 h-2 bg-green-600 rounded-full"></div>
+ 在线
+ </span>
+ {channel.fansCount !== undefined && (
+ <span className="text-xs text-muted-foreground shrink-0">
+ 粉丝: {channel.fansCount}
+ </span>
+ )}
+ </div>
+ </div>
+
+ {isDeleting ? (
+ <div className="p-1">
+ <LoadingOutlined className="h-4 w-4 text-muted-foreground animate-spin" />
+ </div>
+ ) : (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => onDelete(channel)}
+ className="opacity-0 group-hover:opacity-100 h-8 w-8 p-0 text-destructive hover:text-destructive shrink-0"
+ >
+ <Trash2 className="h-4 w-4" />
+ </Button>
+ )}
+ </div>
+ )
+}
diff --git a/project/web/src/components/ChannelManager/components/CreateSpaceSection.tsx b/project/web/src/components/ChannelManager/components/CreateSpaceSection.tsx
new file mode 100644
index 00000000..db942c77
--- /dev/null
+++ b/project/web/src/components/ChannelManager/components/CreateSpaceSection.tsx
@@ -0,0 +1,102 @@
+/**
+ * CreateSpaceSection - 新建空间部分组件
+ *
+ * 功能:
+ * - 显示新建空间的输入框和按钮
+ * - 处理新建空间的逻辑
+ */
+
+'use client'
+
+import { useCallback, useState } from 'react'
+import { Loader2, Plus } from 'lucide-react'
+import { createAccountGroupApi } from '@/api/account'
+import { useTransClient } from '@/app/i18n/client'
+import { Button } from '@/components/ui/button'
+import { Input } from '@/components/ui/input'
+import { toast } from '@/lib/toast'
+
+interface CreateSpaceSectionProps {
+ onSpaceCreated: () => void
+}
+
+export function CreateSpaceSection({ onSpaceCreated }: CreateSpaceSectionProps) {
+ const { t } = useTransClient('account')
+ const [showCreateSpace, setShowCreateSpace] = useState(false)
+ const [creatingSpace, setCreatingSpace] = useState(false)
+ const [newSpaceName, setNewSpaceName] = useState('')
+
+ // 添加新空间
+ const addNewSpace = useCallback(async () => {
+ if (!newSpaceName.trim())
+ return
+
+ setCreatingSpace(true)
+ try {
+ await createAccountGroupApi({ name: newSpaceName.trim() })
+ await onSpaceCreated()
+ toast.success(t('channelManager.createSpaceSuccess', '创建空间成功'))
+ setNewSpaceName('')
+ setCreatingSpace(false)
+ setShowCreateSpace(false)
+ }
+ catch (error) {
+ toast.error(t('channelManager.createSpaceFailed', '创建空间失败'))
+ setCreatingSpace(false)
+ // 注意:这里不重置showCreateSpace,让用户可以重试
+ }
+ }, [newSpaceName, onSpaceCreated, t])
+
+ return (
+ <div className="flex gap-2">
+ {showCreateSpace ? (
+ <>
+ <Input
+ placeholder={t('channelManager.createSpaceNamePlaceholder', '输入空间名称')}
+ value={newSpaceName}
+ onChange={e => setNewSpaceName(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter')
+ addNewSpace()
+ if (e.key === 'Escape') {
+ setNewSpaceName('')
+ setShowCreateSpace(false)
+ }
+ }}
+ disabled={creatingSpace}
+ autoFocus
+ className="flex-1"
+ />
+ <Button onClick={addNewSpace} size="sm" disabled={!newSpaceName.trim() || creatingSpace}>
+ {creatingSpace ? (
+ <Loader2 className="h-4 w-4 animate-spin mr-1" />
+ ) : (
+ <Plus className="h-4 w-4 mr-1" />
+ )}
+ {t('common.confirm', '确认')}
+ </Button>
+ <Button
+ variant="outline"
+ onClick={() => {
+ setNewSpaceName('')
+ setShowCreateSpace(false)
+ }}
+ size="sm"
+ >
+ {t('common.cancel', '取消')}
+ </Button>
+ </>
+ ) : (
+ <Button
+ variant="outline"
+ onClick={() => setShowCreateSpace(true)}
+ className="w-full justify-start"
+ disabled={showCreateSpace}
+ >
+ <Plus className="h-4 w-4 mr-2" />
+ {t('channelManager.createSpace', '新建空间')}
+ </Button>
+ )}
+ </div>
+ )
+}
diff --git a/project/web/src/components/ChannelManager/components/DeleteConfirmDialog.tsx b/project/web/src/components/ChannelManager/components/DeleteConfirmDialog.tsx
new file mode 100644
index 00000000..80947863
--- /dev/null
+++ b/project/web/src/components/ChannelManager/components/DeleteConfirmDialog.tsx
@@ -0,0 +1,81 @@
+/**
+ * DeleteConfirmDialog - 删除确认对话框组件
+ *
+ * 功能:
+ * - 确认删除空间或频道
+ * - 显示删除提示信息
+ */
+
+'use client'
+
+import { LoadingOutlined } from '@ant-design/icons'
+import { useTransClient } from '@/app/i18n/client'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@/components/ui/alert-dialog'
+
+interface DeleteConfirmDialogProps {
+ open: boolean
+ type: 'space' | 'channel'
+ name: string
+ loading?: boolean
+ onOpenChange: (open: boolean) => void
+ onConfirm: () => void
+}
+
+export function DeleteConfirmDialog({
+ open,
+ type,
+ name,
+ loading = false,
+ onOpenChange,
+ onConfirm,
+}: DeleteConfirmDialogProps) {
+ const { t } = useTransClient('account')
+
+ return (
+ <AlertDialog open={open} onOpenChange={onOpenChange}>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>
+ {t('channelManager.deleteConfirm', '确认删除')}
+ </AlertDialogTitle>
+ <AlertDialogDescription>
+ 确定要删除
+ {type === 'space' ? '空间' : '频道'}
+ {' '}
+ "
+ {name}
+ " 吗?此操作无法撤销。
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>
+ {t('common.cancel', '取消')}
+ </AlertDialogCancel>
+ <AlertDialogAction
+ onClick={onConfirm}
+ disabled={loading}
+ className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
+ >
+ {loading ? (
+ <>
+ <LoadingOutlined className="h-4 w-4 mr-2 animate-spin" />
+ 删除中...
+ </>
+ ) : (
+ t('common.confirm', '确认')
+ )}
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ )
+}
diff --git a/project/web/src/components/ChannelManager/components/SpaceItem.tsx b/project/web/src/components/ChannelManager/components/SpaceItem.tsx
new file mode 100644
index 00000000..2de5413d
--- /dev/null
+++ b/project/web/src/components/ChannelManager/components/SpaceItem.tsx
@@ -0,0 +1,244 @@
+/**
+ * SpaceItem - 空间项组件
+ *
+ * 功能:
+ * - 显示空间信息和操作按钮
+ * - 支持编辑空间名称
+ * - 显示频道列表
+ * - 处理空间折叠展开
+ */
+
+'use client'
+
+import { useCallback, useState } from 'react'
+import { LoadingOutlined } from '@ant-design/icons'
+import {
+ ChevronDown,
+ ChevronRight,
+ ChevronUp,
+ Edit,
+ MoreVertical,
+ Trash2,
+ Box,
+ Loader2,
+} from 'lucide-react'
+import { updateAccountGroupApi } from '@/api/account'
+import { useTransClient } from '@/app/i18n/client'
+import { Button } from '@/components/ui/button'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu'
+import { Input } from '@/components/ui/input'
+import { toast } from '@/lib/toast'
+import { ChannelItem } from './ChannelItem'
+
+interface Channel {
+ id: string
+ name: string
+ platform: string
+ accountId: string
+ avatar?: string
+ fansCount?: number
+}
+
+interface AccountGroup {
+ id: string
+ name: string
+ isDefault: boolean
+}
+
+interface SpaceItemProps {
+ space: AccountGroup
+ channels: Channel[]
+ index: number
+ totalSpaces: number
+ isCollapsed: boolean
+ isEditing: boolean
+ editSpaceName: string
+ editingSpaceLoading: boolean
+ deleteLoading?: string | null
+ sortingLoading?: string | null
+ onToggleCollapse: () => void
+ onStartEdit: () => void
+ onEditNameChange: (name: string) => void
+ onSaveEdit: () => void
+ onCancelEdit: () => void
+ onMoveUp?: () => void
+ onMoveDown?: () => void
+ onDelete: () => void
+ onChannelDelete: (channel: Channel) => void
+ onRefresh: () => void
+}
+
+export function SpaceItem({
+ space,
+ channels,
+ index,
+ totalSpaces,
+ isCollapsed,
+ isEditing,
+ editSpaceName,
+ editingSpaceLoading,
+ deleteLoading,
+ sortingLoading,
+ onToggleCollapse,
+ onStartEdit,
+ onEditNameChange,
+ onSaveEdit,
+ onCancelEdit,
+ onMoveUp,
+ onMoveDown,
+ onDelete,
+ onChannelDelete,
+ onRefresh,
+}: SpaceItemProps) {
+ const { t } = useTransClient('account')
+
+ const canMoveUp = index > 0
+ const canMoveDown = index < totalSpaces - 1
+ const isSorting = sortingLoading === space.id
+
+ return (
+ <div className={`border rounded-lg overflow-hidden ${isSorting ? 'opacity-60 pointer-events-none' : ''}`}>
+ {/* 空间标题栏 */}
+ <div className="flex items-center gap-2.5 py-2 px-4 bg-muted/30 border-b">
+ {isCollapsed ? (
+ <ChevronRight
+ className="h-4 w-4 text-muted-foreground shrink-0 cursor-pointer hover:text-foreground transition-colors"
+ onClick={() => !isEditing && onToggleCollapse()}
+ />
+ ) : (
+ <ChevronDown
+ className="h-4 w-4 text-muted-foreground shrink-0 cursor-pointer hover:text-foreground transition-colors"
+ onClick={() => !isEditing && onToggleCollapse()}
+ />
+ )}
+
+ <Box className="h-4 w-4 text-primary shrink-0" />
+
+ {isEditing ? (
+ <div className="flex-1 flex gap-2">
+ <Input
+ value={editSpaceName}
+ onChange={e => onEditNameChange(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') onSaveEdit()
+ if (e.key === 'Escape') onCancelEdit()
+ }}
+ autoFocus
+ className="h-7 text-sm"
+ />
+ <Button onClick={onSaveEdit} size="sm" disabled={editingSpaceLoading}>
+ {editingSpaceLoading ? (
+ <Loader2 className="h-4 w-4 animate-spin mr-1" />
+ ) : null}
+ {t('common.save', '保存')}
+ </Button>
+ <Button variant="outline" onClick={onCancelEdit} size="sm" disabled={editingSpaceLoading}>
+ {t('common.cancel', '取消')}
+ </Button>
+ </div>
+ ) : (
+ <>
+ <div className="flex-1 min-w-0">
+ <div className="font-medium text-sm">{space.name}</div>
+ {space.isDefault && (
+ <div className="text-xs text-muted-foreground">
+ {t('account.defaultSpace', '默认空间')}
+ </div>
+ )}
+ </div>
+
+ <div className="text-xs text-muted-foreground shrink-0">
+ {channels.length} 个频道
+ </div>
+
+ {isSorting && (
+ <div className="flex items-center gap-1 text-xs text-muted-foreground shrink-0">
+ <LoadingOutlined className="h-3 w-3 animate-spin" />
+ 排序中...
+ </div>
+ )}
+
+ {!space.isDefault && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-8 w-8 p-0 shrink-0"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <MoreVertical className="h-4 w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={onStartEdit}>
+ <Edit className="h-4 w-4 mr-2" />
+ {t('common.edit', '编辑')}
+ </DropdownMenuItem>
+ {canMoveUp && (
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation()
+ if (!isSorting) onMoveUp?.()
+ }}
+ disabled={isSorting}
+ >
+ <ChevronUp className="h-4 w-4 mr-2" />
+ {t('channelManager.moveUp', '上移')}
+ </DropdownMenuItem>
+ )}
+ {canMoveDown && (
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation()
+ if (!isSorting) onMoveDown?.()
+ }}
+ disabled={isSorting}
+ >
+ <ChevronDown className="h-4 w-4 mr-2" />
+ {t('channelManager.moveDown', '下移')}
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ onClick={onDelete}
+ className="text-destructive"
+ >
+ <Trash2 className="h-4 w-4 mr-2" />
+ {t('common.delete', '删除')}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </>
+ )}
+ </div>
+
+ {/* 频道列表 */}
+ {!isCollapsed && (
+ <div className="divide-y">
+ {channels.length === 0 ? (
+ <div className="text-sm text-muted-foreground py-8 text-center">
+ {t('channelManager.noChannels', '暂无频道')}
+ </div>
+ ) : (
+ channels.map((channel) => (
+ <ChannelItem
+ key={channel.id}
+ channel={channel}
+ onDelete={onChannelDelete}
+ deleteLoading={deleteLoading}
+ />
+ ))
+ )}
+ </div>
+ )}
+ </div>
+ )
+}
diff --git a/project/web/src/components/ChannelManager/components/SpaceListSkeleton.tsx b/project/web/src/components/ChannelManager/components/SpaceListSkeleton.tsx
new file mode 100644
index 00000000..74f0ccbd
--- /dev/null
+++ b/project/web/src/components/ChannelManager/components/SpaceListSkeleton.tsx
@@ -0,0 +1,56 @@
+/**
+ * SpaceListSkeleton - 空间列表骨架屏组件
+ *
+ * 功能:
+ * - 显示加载状态的骨架屏
+ */
+
+'use client'
+
+import { Loader2 } from 'lucide-react'
+import { useTransClient } from '@/app/i18n/client'
+import { Skeleton } from '@/components/ui/skeleton'
+
+export function SpaceListSkeleton() {
+ const { t } = useTransClient('account')
+
+ return (
+ <div className="space-y-4">
+ {/* 骨架屏 */}
+ <div className="flex items-center gap-3 p-4 bg-muted/30 border-b">
+ <Skeleton className="h-5 w-5 rounded" />
+ <Skeleton className="h-5 w-5 rounded" />
+ <div className="flex-1">
+ <Skeleton className="h-4 w-24 mb-1" />
+ <Skeleton className="h-3 w-16" />
+ </div>
+ <Skeleton className="h-8 w-8 rounded" />
+ </div>
+
+ {/* 频道骨架屏 */}
+ {Array.from({ length: 3 }).map((_, index) => (
+ <div key={index} className="flex items-center gap-3 p-4 border-b last:border-b-0">
+ <Skeleton className="h-10 w-10 rounded-full" />
+ <div className="flex-1">
+ <Skeleton className="h-4 w-32 mb-2" />
+ <div className="flex items-center gap-2">
+ <Skeleton className="h-3 w-3 rounded-full" />
+ <Skeleton className="h-3 w-16" />
+ <Skeleton className="h-3 w-12" />
+ <Skeleton className="h-3 w-20" />
+ </div>
+ </div>
+ <Skeleton className="h-8 w-8 rounded" />
+ </div>
+ ))}
+
+ {/* 加载动画 */}
+ <div className="flex items-center justify-center py-4">
+ <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
+ <span className="ml-2 text-sm text-muted-foreground">
+ {t('common.loading', '加载中...')}
+ </span>
+ </div>
+ </div>
+ )
+}
diff --git a/project/web/src/components/ChannelManager/components/UnifiedChannelSpaceList.tsx b/project/web/src/components/ChannelManager/components/UnifiedChannelSpaceList.tsx
index 12d9f968..e8705860 100644
--- a/project/web/src/components/ChannelManager/components/UnifiedChannelSpaceList.tsx
+++ b/project/web/src/components/ChannelManager/components/UnifiedChannelSpaceList.tsx
@@ -9,50 +9,20 @@
'use client'
-import {
- ChevronDown,
- ChevronRight,
- ChevronUp,
- Edit,
- Folder,
- MoreVertical,
- Plus,
- Trash2,
-} from 'lucide-react'
-import { useCallback, useRef, useState } from 'react'
+import { useCallback, useState } from 'react'
import { useShallow } from 'zustand/react/shallow'
-import { Loader2 } from 'lucide-react'
-import Image from 'next/image'
-import { createAccountGroupApi, deleteAccountGroupApi, updateAccountGroupApi } from '@/api/account'
-import { AccountPlatInfoMap } from '@/app/config/platConfig'
+import { deleteAccountApi, deleteAccountGroupApi, updateAccountGroupApi } from '@/api/account'
+import { apiUpdateAccountGroupSortRank } from '@/api/accountSort'
import { useTransClient } from '@/app/i18n/client'
-import { getOssUrl } from '@/utils/oss'
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
-} from '@/components/ui/alert-dialog'
-import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
-import { Skeleton } from '@/components/ui/skeleton'
-import { Button } from '@/components/ui/button'
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
-} from '@/components/ui/dropdown-menu'
-import { Input } from '@/components/ui/input'
import { ScrollArea } from '@/components/ui/scroll-area'
import { toast } from '@/lib/toast'
import { useAccountStore } from '@/store/account'
+import { CreateSpaceSection } from './CreateSpaceSection'
+import { SpaceItem } from './SpaceItem'
+import { DeleteConfirmDialog } from './DeleteConfirmDialog'
+import { SpaceListSkeleton } from './SpaceListSkeleton'
-// 模拟频道数据类型(后续需要从API获取)
+// 频道数据类型
interface Channel {
id: string
name: string
@@ -69,22 +39,24 @@ export function UnifiedChannelSpaceList() {
accountList,
accountLoading,
getAccountGroup,
+ getAccountList,
} = useAccountStore(
useShallow(state => ({
accountGroupList: state.accountGroupList,
accountList: state.accountList,
accountLoading: state.accountLoading,
getAccountGroup: state.getAccountGroup,
+ getAccountList: state.getAccountList,
})),
)
// UI状态
const [editingSpace, setEditingSpace] = useState<string | null>(null)
const [editSpaceName, setEditSpaceName] = useState('')
- const [showCreateSpace, setShowCreateSpace] = useState(false)
- const [creatingSpace, setCreatingSpace] = useState(false)
const [editingSpaceLoading, setEditingSpaceLoading] = useState(false)
- const [newSpaceName, setNewSpaceName] = useState('')
+ const [collapsedSpaces, setCollapsedSpaces] = useState<Set<string>>(new Set())
+ const [deleteLoading, setDeleteLoading] = useState<string | null>(null)
+ const [sortingSpaceLoading, setSortingSpaceLoading] = useState<string | null>(null)
// 删除确认对话框
const [deleteDialog, setDeleteDialog] = useState<{
@@ -99,7 +71,6 @@ export function UnifiedChannelSpaceList() {
name: '',
})
-
// 开始编辑空间
const startEditingSpace = useCallback((spaceId: string, currentName: string) => {
setEditingSpace(spaceId)
@@ -136,47 +107,79 @@ export function UnifiedChannelSpaceList() {
setEditSpaceName('')
}, [])
- // 添加新空间
- const addNewSpace = useCallback(async () => {
- if (!newSpaceName.trim())
- return
-
- setCreatingSpace(true)
- try {
- await createAccountGroupApi({ name: newSpaceName.trim() })
- await getAccountGroup()
- toast.success(t('channelManager.createSpaceSuccess', '创建空间成功'))
- setNewSpaceName('')
- setCreatingSpace(false)
- setShowCreateSpace(false)
- }
- catch (error) {
- toast.error(t('channelManager.createSpaceFailed', '创建空间失败'))
- setCreatingSpace(false)
- // 注意:这里不重置showCreateSpace,让用户可以重试
- }
- }, [newSpaceName, getAccountGroup, t])
-
// 删除空间或频道
const confirmDelete = useCallback(async () => {
try {
+ setDeleteLoading(deleteDialog.id)
if (deleteDialog.type === 'space') {
await deleteAccountGroupApi([deleteDialog.id])
toast.success(t('channelManager.deleteSpaceSuccess', '删除空间成功'))
+ await getAccountGroup()
}
else {
- // TODO: 实现删除频道API
+ await deleteAccountApi(deleteDialog.id)
toast.success(t('channelManager.deleteChannelSuccess', '删除频道成功'))
+ // 删除频道后同时刷新账户列表和分组数据
+ await Promise.all([getAccountList(), getAccountGroup()])
}
- await getAccountGroup()
}
catch (error) {
const errorType = deleteDialog.type === 'space' ? '空间' : '频道'
toast.error(`删除${errorType}失败`)
+ return
+ }
+ finally {
+ setDeleteLoading(null)
+ setDeleteDialog({ open: false, type: 'space', id: '', name: '' })
}
+ }, [deleteDialog, getAccountGroup, getAccountList, t])
+
+ // 切换空间折叠状态
+ const toggleSpaceCollapse = useCallback((spaceId: string) => {
+ setCollapsedSpaces(prev => {
+ const newSet = new Set(prev)
+ if (newSet.has(spaceId)) {
+ newSet.delete(spaceId)
+ } else {
+ newSet.add(spaceId)
+ }
+ return newSet
+ })
+ }, [])
+
+ // 空间排序函数
+ const handleSpaceSort = useCallback(async (spaceId: string, direction: 'up' | 'down') => {
+ if (sortingSpaceLoading) return // 防止重复操作
+
+ setSortingSpaceLoading(spaceId)
+
+ try {
+ const sortedGroups = [...accountGroupList].sort((a, b) => (a.rank || 0) - (b.rank || 0))
+ const currentIndex = sortedGroups.findIndex(g => g.id === spaceId)
+
+ if (currentIndex === -1) return
+
+ const newIndex = direction === 'up' ? currentIndex - 1 : currentIndex + 1
+ if (newIndex < 0 || newIndex >= sortedGroups.length) return
+
+ // 交换位置
+ [sortedGroups[currentIndex], sortedGroups[newIndex]] = [sortedGroups[newIndex], sortedGroups[currentIndex]]
+
+ // 更新rank
+ const updateList = sortedGroups.map((group, index) => ({
+ id: group.id,
+ rank: index,
+ }))
- setDeleteDialog({ open: false, type: 'space', id: '', name: '' })
- }, [deleteDialog, getAccountGroup, t])
+ await apiUpdateAccountGroupSortRank({ list: updateList })
+ await getAccountGroup()
+ toast.success(t('channelManager.sortSuccess', '排序成功'))
+ } catch (error) {
+ toast.error(t('channelManager.sortFailed', '排序失败'))
+ } finally {
+ setSortingSpaceLoading(null)
+ }
+ }, [accountGroupList, getAccountGroup, t, sortingSpaceLoading])
// 获取空间下的频道
const getChannelsInSpace = useCallback((spaceId: string): Channel[] => {
@@ -195,303 +198,70 @@ export function UnifiedChannelSpaceList() {
}, [accountList])
if (accountLoading) {
- return (
- <div className="space-y-4">
- {/* 骨架屏 */}
- <div className="flex items-center gap-3 p-4 bg-muted/30 border-b">
- <Skeleton className="h-5 w-5 rounded" />
- <Skeleton className="h-5 w-5 rounded" />
- <div className="flex-1">
- <Skeleton className="h-4 w-24 mb-1" />
- <Skeleton className="h-3 w-16" />
- </div>
- <Skeleton className="h-8 w-8 rounded" />
- </div>
-
- {/* 频道骨架屏 */}
- {Array.from({ length: 3 }).map((_, index) => (
- <div key={index} className="flex items-center gap-3 p-4 border-b last:border-b-0">
- <Skeleton className="h-10 w-10 rounded-full" />
- <div className="flex-1">
- <Skeleton className="h-4 w-32 mb-2" />
- <div className="flex items-center gap-2">
- <Skeleton className="h-3 w-3 rounded-full" />
- <Skeleton className="h-3 w-16" />
- <Skeleton className="h-3 w-12" />
- <Skeleton className="h-3 w-20" />
- </div>
- </div>
- <Skeleton className="h-8 w-8 rounded" />
- </div>
- ))}
-
- {/* 加载动画 */}
- <div className="flex items-center justify-center py-4">
- <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
- <span className="ml-2 text-sm text-muted-foreground">
- {t('common.loading', '加载中...')}
- </span>
- </div>
- </div>
- )
+ return <SpaceListSkeleton />
}
return (
- <div className="flex flex-col gap-4">
+ <div className="flex flex-col gap-4 h-full overflow-hidden">
{/* 添加新空间 */}
- <div className="flex gap-2">
- {showCreateSpace ? (
- <>
- <Input
- placeholder={t('channelManager.createSpaceNamePlaceholder', '输入空间名称')}
- value={newSpaceName}
- onChange={e => setNewSpaceName(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === 'Enter')
- addNewSpace()
- if (e.key === 'Escape') {
- setNewSpaceName('')
- setShowCreateSpace(false)
- }
- }}
- disabled={creatingSpace}
- autoFocus
- className="flex-1"
- />
- <Button onClick={addNewSpace} size="sm" disabled={!newSpaceName.trim() || creatingSpace}>
- {creatingSpace ? (
- <Loader2 className="h-4 w-4 animate-spin mr-1" />
- ) : (
- <Plus className="h-4 w-4 mr-1" />
- )}
- {t('common.confirm', '确认')}
- </Button>
- <Button
- variant="outline"
- onClick={() => {
- setNewSpaceName('')
- setShowCreateSpace(false)
- }}
- size="sm"
- >
- {t('common.cancel', '取消')}
- </Button>
- </>
- ) : (
- <Button
- variant="outline"
- onClick={() => setShowCreateSpace(true)}
- className="w-full justify-start"
- disabled={showCreateSpace}
- >
- <Plus className="h-4 w-4 mr-2" />
- {t('channelManager.createSpace', '新建空间')}
- </Button>
- )}
- </div>
+ <CreateSpaceSection onSpaceCreated={getAccountGroup} />
{/* 空间和频道列表 */}
- <ScrollArea className="flex-1">
+ <ScrollArea className="flex-1 h-full">
<div className="space-y-2">
{accountGroupList.map((space, index) => {
const channels = getChannelsInSpace(space.id)
- const canMoveUp = index > 0
- const canMoveDown = index < accountGroupList.length - 1
const isEditing = editingSpace === space.id
+ const isCollapsed = collapsedSpaces.has(space.id)
return (
- <div key={space.id} className="border rounded-lg overflow-hidden">
- {/* 空间标题栏 */}
- <div className="flex items-center gap-3 p-4 bg-muted/30 border-b">
- <ChevronRight className="h-4 w-4 text-muted-foreground shrink-0" />
-
- <Folder className="h-5 w-5 text-primary shrink-0" />
-
- {isEditing ? (
- <div className="flex-1 flex gap-2">
- <Input
- value={editSpaceName}
- onChange={e => setEditSpaceName(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === 'Enter') saveSpaceEdit()
- if (e.key === 'Escape') cancelSpaceEdit()
- }}
- autoFocus
- className="h-8 text-sm"
- />
- <Button onClick={saveSpaceEdit} size="sm" disabled={editingSpaceLoading}>
- {editingSpaceLoading ? (
- <Loader2 className="h-4 w-4 animate-spin mr-1" />
- ) : null}
- {t('common.save', '保存')}
- </Button>
- <Button variant="outline" onClick={cancelSpaceEdit} size="sm" disabled={editingSpaceLoading}>
- {t('common.cancel', '取消')}
- </Button>
- </div>
- ) : (
- <>
- <div className="flex-1 min-w-0">
- <div className="font-medium text-sm">{space.name}</div>
- {space.isDefault && (
- <div className="text-xs text-muted-foreground">
- {t('account.defaultSpace', '默认空间')}
- </div>
- )}
- </div>
-
- <div className="text-xs text-muted-foreground shrink-0">
- {channels.length} 个频道
- </div>
-
- {!space.isDefault && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="sm" className="h-8 w-8 p-0 shrink-0">
- <MoreVertical className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onClick={() => startEditingSpace(space.id, space.name)}>
- <Edit className="h-4 w-4 mr-2" />
- {t('common.edit', '编辑')}
- </DropdownMenuItem>
- {canMoveUp && (
- <DropdownMenuItem>
- <ChevronUp className="h-4 w-4 mr-2" />
- {t('channelManager.moveUp', '上移')}
- </DropdownMenuItem>
- )}
- {canMoveDown && (
- <DropdownMenuItem>
- <ChevronDown className="h-4 w-4 mr-2" />
- {t('channelManager.moveDown', '下移')}
- </DropdownMenuItem>
- )}
- <DropdownMenuSeparator />
- <DropdownMenuItem
- onClick={() => setDeleteDialog({
- open: true,
- type: 'space',
- id: space.id,
- name: space.name,
- })}
- className="text-destructive"
- >
- <Trash2 className="h-4 w-4 mr-2" />
- {t('common.delete', '删除')}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
- </>
- )}
- </div>
-
- {/* 频道列表 */}
- <div className="divide-y">
- {channels.length === 0 ? (
- <div className="text-sm text-muted-foreground py-8 text-center">
- {t('channelManager.noChannels', '暂无频道')}
- </div>
- ) : (
- channels.map((channel) => {
- const platInfo = AccountPlatInfoMap.get(channel.platform as any)
- return (
- <div
- key={channel.id}
- className="flex items-center gap-3 p-4 hover:bg-accent/30 transition-colors group"
- >
- <Avatar className="h-10 w-10 shrink-0">
- <AvatarImage src={getOssUrl(channel.avatar)} alt={channel.name} />
- <AvatarFallback>{channel.name[0]}</AvatarFallback>
- </Avatar>
-
- <div className="flex-1 min-w-0">
- <div className="font-medium text-sm truncate">{channel.name}</div>
- <div className="flex items-center gap-2 mt-1 flex-wrap">
- {platInfo?.icon && (
- <Image
- src={platInfo.icon}
- alt={platInfo.name}
- width={14}
- height={14}
- className="rounded-sm shrink-0"
- />
- )}
- <span className="text-xs text-muted-foreground shrink-0">
- {platInfo?.name}
- </span>
- {/* 状态显示 */}
- <span className="flex items-center gap-1 text-xs text-green-600 shrink-0">
- <div className="w-2 h-2 bg-green-600 rounded-full"></div>
- 在线
- </span>
- {channel.fansCount !== undefined && (
- <span className="text-xs text-muted-foreground shrink-0">
- 粉丝: {channel.fansCount}
- </span>
- )}
- </div>
- </div>
-
- <Button
- variant="ghost"
- size="sm"
- onClick={() => setDeleteDialog({
- open: true,
- type: 'channel',
- id: channel.id,
- name: channel.name,
- })}
- className="opacity-0 group-hover:opacity-100 h-8 w-8 p-0 text-destructive hover:text-destructive shrink-0"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- </div>
- )
- })
- )}
- </div>
- </div>
+ <SpaceItem
+ key={space.id}
+ space={space}
+ channels={channels}
+ index={index}
+ totalSpaces={accountGroupList.length}
+ isCollapsed={isCollapsed}
+ isEditing={isEditing}
+ editSpaceName={editSpaceName}
+ editingSpaceLoading={editingSpaceLoading}
+ deleteLoading={deleteLoading}
+ sortingLoading={sortingSpaceLoading}
+ onToggleCollapse={() => toggleSpaceCollapse(space.id)}
+ onStartEdit={() => startEditingSpace(space.id, space.name)}
+ onEditNameChange={setEditSpaceName}
+ onSaveEdit={saveSpaceEdit}
+ onCancelEdit={cancelSpaceEdit}
+ onMoveUp={() => handleSpaceSort(space.id, 'up')}
+ onMoveDown={() => handleSpaceSort(space.id, 'down')}
+ onDelete={() => setDeleteDialog({
+ open: true,
+ type: 'space',
+ id: space.id,
+ name: space.name,
+ })}
+ onChannelDelete={(channel: Channel) => setDeleteDialog({
+ open: true,
+ type: 'channel',
+ id: channel.id,
+ name: channel.name,
+ })}
+ onRefresh={getAccountGroup}
+ />
)
})}
</div>
</ScrollArea>
{/* 删除确认对话框 */}
- <AlertDialog
+ <DeleteConfirmDialog
open={deleteDialog.open}
- onOpenChange={open =>
- setDeleteDialog(prev => ({ ...prev, open }))}
- >
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>
- {t('channelManager.deleteConfirm', '确认删除')}
- </AlertDialogTitle>
- <AlertDialogDescription>
- 确定要删除
- {deleteDialog.type === 'space' ? '空间' : '频道'}
- {' '}
- "
- {deleteDialog.name}
- " 吗?此操作无法撤销。
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancel>
- {t('common.cancel', '取消')}
- </AlertDialogCancel>
- <AlertDialogAction
- onClick={confirmDelete}
- className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
- >
- {t('common.confirm', '确认')}
- </AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
+ type={deleteDialog.type}
+ name={deleteDialog.name}
+ loading={!!deleteLoading}
+ onOpenChange={open => setDeleteDialog(prev => ({ ...prev, open }))}
+ onConfirm={confirmDelete}
+ />
</div>
)
}
diff --git a/project/web/src/components/ChannelManager/index.tsx b/project/web/src/components/ChannelManager/index.tsx
index 38d5b8d2..f265ad37 100644
--- a/project/web/src/components/ChannelManager/index.tsx
+++ b/project/web/src/components/ChannelManager/index.tsx
@@ -15,6 +15,7 @@ import { useTransClient } from '@/app/i18n/client'
import {
Dialog,
DialogContent,
+ DialogDescription,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
@@ -44,15 +45,20 @@ export function ChannelManager({
return (
<Dialog open={isOpen} onOpenChange={handleClose}>
- <DialogContent className="max-w-2xl h-[600px] overflow-hidden flex flex-col">
+ <DialogContent className="max-w-4xl h-[700px] overflow-hidden flex flex-col">
<DialogHeader>
<DialogTitle className="text-lg font-semibold">
{t('channelManager.title', '我的频道')}
</DialogTitle>
+ <DialogDescription>
+ {t('channelManager.description', '管理您的频道和空间分组')}
+ </DialogDescription>
</DialogHeader>
{/* 统一的空间和频道管理列表 */}
- <UnifiedChannelSpaceList />
+ <div className="flex-1 min-h-0">
+ <UnifiedChannelSpaceList />
+ </div>
</DialogContent>
</Dialog>
)
diff --git a/project/web/src/components/Chat/ChatMessage/index.tsx b/project/web/src/components/Chat/ChatMessage/index.tsx
index f1baeb64..23cf88fe 100644
--- a/project/web/src/components/Chat/ChatMessage/index.tsx
+++ b/project/web/src/components/Chat/ChatMessage/index.tsx
@@ -53,6 +53,8 @@ export interface IChatMessageProps {
workflowSteps?: IWorkflowStep[]
/** Action 卡片列表(用于显示可交互的 action) */
actions?: IActionCard[]
+ /** 是否正在生成(用于最后一条AI消息显示思考状态) */
+ isGenerating?: boolean
/** 自定义类名 */
className?: string
}
@@ -208,6 +210,7 @@ export function ChatMessage({
steps = [],
workflowSteps = [],
actions = [],
+ isGenerating = false,
className,
}: IChatMessageProps) {
const { t } = useTransClient('chat')
@@ -330,6 +333,71 @@ export function ChatMessage({
onOpenPreview={openPreviewWithUrl}
/>
))}
+
+ {/* 思考中状态 - 在最后一条AI消息底部显示 */}
+ {isGenerating && (
+ <div className="mt-4 pt-4 border-t border-border/50">
+ <div className="flex items-center gap-3 px-1">
+ {/* 优雅的波点动画 */}
+ <div className="flex items-center gap-1 flex-shrink-0">
+ <div
+ className="w-1.5 h-1.5 rounded-full bg-blue-500"
+ style={{
+ animation: 'bounceDots 1.4s ease-in-out infinite both',
+ animationDelay: '0s',
+ }}
+ ></div>
+ <div
+ className="w-1.5 h-1.5 rounded-full bg-purple-500"
+ style={{
+ animation: 'bounceDots 1.4s ease-in-out infinite both',
+ animationDelay: '0.2s',
+ }}
+ ></div>
+ <div
+ className="w-1.5 h-1.5 rounded-full bg-pink-500"
+ style={{
+ animation: 'bounceDots 1.4s ease-in-out infinite both',
+ animationDelay: '0.4s',
+ }}
+ ></div>
+ </div>
+
+ {/* 思考文字 */}
+ <span
+ className="text-sm font-medium bg-linear-to-r from-blue-500 via-purple-500 to-pink-500 bg-clip-text text-transparent"
+ style={{
+ animation: 'thinkingGlow 1.8s ease-in-out infinite',
+ display: 'inline-block',
+ }}
+ >
+ {t('message.thinking')}
+ </span>
+ </div>
+ <style>{`
+ @keyframes thinkingGlow {
+ 0%, 100% {
+ opacity: 0.7;
+ filter: hue-rotate(0deg) brightness(1);
+ }
+ 50% {
+ opacity: 1;
+ filter: hue-rotate(180deg) brightness(1.2);
+ }
+ }
+ @keyframes bounceDots {
+ 0%, 80%, 100% {
+ transform: scale(0.8);
+ opacity: 0.5;
+ }
+ 40% {
+ transform: scale(1.2);
+ opacity: 1;
+ }
+ }
+ `}</style>
+ </div>
+ )}
</div>
)}