Skip to content

Let's use AI to Earn!

feat(agent): add public share, forward and frontend rating UI (#464)

yika6f7ee7658cc7
diff --git a/project/web/public/sitemap-0.xml b/project/web/public/sitemap-0.xml
index a3ab45cf..ac08f29f 100644
--- a/project/web/public/sitemap-0.xml
+++ b/project/web/public/sitemap-0.xml
@@ -1,52 +1,52 @@
<?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-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>
-<url><loc>https://aitoearn.ai/en/websit/plugin-guide</loc><lastmod>2025-12-22T02:19:26.233Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<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-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-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>
-<url><loc>https://aitoearn.ai/en/cgmaterial</loc><lastmod>2025-11-18T02:51:00.099Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/en/auth/login</loc><lastmod>2025-12-18T11:52:18.715Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/en/auth/forgot-password</loc><lastmod>2025-12-18T11:52:18.710Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/en/aiRank</loc><lastmod>2025-11-18T02:51:00.092Z</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
-<url><loc>https://aitoearn.ai/en/aiRank/aiRanking</loc><lastmod>2025-11-18T02:51:00.078Z</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
-<url><loc>https://aitoearn.ai/en/accounts</loc><lastmod>2025-12-19T13:34:03.419Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/en/accounts/auth</loc><lastmod>2025-11-18T02:50:59.996Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN</loc><lastmod>2025-12-24T04:08:42.228Z</lastmod><changefreq>monthly</changefreq><priority>0.8</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/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/zh-CN/websit/privacy-policy</loc><lastmod>2025-12-22T02:19:26.234Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/websit/plugin-guide</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/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-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-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>
-<url><loc>https://aitoearn.ai/zh-CN/cgmaterial</loc><lastmod>2025-11-18T02:51:00.099Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/auth/login</loc><lastmod>2025-12-18T11:52:18.715Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/auth/forgot-password</loc><lastmod>2025-12-18T11:52:18.710Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/aiRank</loc><lastmod>2025-11-18T02:51:00.092Z</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/aiRank/aiRanking</loc><lastmod>2025-11-18T02:51:00.078Z</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/accounts</loc><lastmod>2025-12-19T13:34:03.419Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
-<url><loc>https://aitoearn.ai/zh-CN/accounts/auth</loc><lastmod>2025-11-18T02:50:59.996Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/healthz</loc><lastmod>2025-12-25T07:17:38.132Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en</loc><lastmod>2025-12-25T06:58:43.312Z</lastmod><changefreq>monthly</changefreq><priority>0.8</priority></url>
+<url><loc>https://aitoearn.ai/en/websit/terms-of-service</loc><lastmod>2025-12-20T14:27:57.199Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/websit/privacy-policy</loc><lastmod>2025-12-20T14:27:57.198Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/websit/plugin-guide</loc><lastmod>2025-12-20T14:27:57.198Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/websit/extension-privacy-policy</loc><lastmod>2025-12-20T14:27:57.196Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/websit/data-protection-agreement</loc><lastmod>2025-12-20T14:27:57.196Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/websit/data-deletion</loc><lastmod>2025-12-20T14:27:57.196Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/tasks-history</loc><lastmod>2025-12-25T06:58:43.312Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/tasks</loc><lastmod>2025-12-20T14:27:57.195Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/pricing</loc><lastmod>2025-12-20T14:27:57.195Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/pinterest</loc><lastmod>2025-12-23T03:24:46.958Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/material</loc><lastmod>2025-12-20T14:27:57.194Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/interactiveNew</loc><lastmod>2025-12-20T14:27:57.192Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/income</loc><lastmod>2025-12-25T06:58:43.311Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/hotContent</loc><lastmod>2025-12-20T14:27:57.190Z</lastmod><changefreq>daily</changefreq><priority>0.9</priority></url>
+<url><loc>https://aitoearn.ai/en/dataStatistics</loc><lastmod>2025-12-20T14:27:57.187Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/data-monitoring</loc><lastmod>2025-12-23T03:24:46.864Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/cgmaterial</loc><lastmod>2025-12-20T14:27:57.184Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/auth/login</loc><lastmod>2025-12-20T14:27:57.183Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/auth/forgot-password</loc><lastmod>2025-12-20T14:27:57.183Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/aiRank</loc><lastmod>2025-12-20T14:27:57.183Z</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
+<url><loc>https://aitoearn.ai/en/aiRank/aiRanking</loc><lastmod>2025-12-20T14:27:57.182Z</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
+<url><loc>https://aitoearn.ai/en/accounts</loc><lastmod>2025-12-20T14:27:57.182Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/en/accounts/auth</loc><lastmod>2025-12-20T14:27:57.179Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN</loc><lastmod>2025-12-25T06:58:43.312Z</lastmod><changefreq>monthly</changefreq><priority>0.8</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/websit/terms-of-service</loc><lastmod>2025-12-20T14:27:57.199Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/websit/privacy-policy</loc><lastmod>2025-12-20T14:27:57.198Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/websit/plugin-guide</loc><lastmod>2025-12-20T14:27:57.198Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/websit/extension-privacy-policy</loc><lastmod>2025-12-20T14:27:57.196Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/websit/data-protection-agreement</loc><lastmod>2025-12-20T14:27:57.196Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/websit/data-deletion</loc><lastmod>2025-12-20T14:27:57.196Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/tasks-history</loc><lastmod>2025-12-25T06:58:43.312Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/tasks</loc><lastmod>2025-12-20T14:27:57.195Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/pricing</loc><lastmod>2025-12-20T14:27:57.195Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/pinterest</loc><lastmod>2025-12-23T03:24:46.958Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/material</loc><lastmod>2025-12-20T14:27:57.194Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/interactiveNew</loc><lastmod>2025-12-20T14:27:57.192Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/income</loc><lastmod>2025-12-25T06:58:43.311Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/hotContent</loc><lastmod>2025-12-20T14:27:57.190Z</lastmod><changefreq>daily</changefreq><priority>0.9</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/dataStatistics</loc><lastmod>2025-12-20T14:27:57.187Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/data-monitoring</loc><lastmod>2025-12-23T03:24:46.864Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/cgmaterial</loc><lastmod>2025-12-20T14:27:57.184Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/auth/login</loc><lastmod>2025-12-20T14:27:57.183Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/auth/forgot-password</loc><lastmod>2025-12-20T14:27:57.183Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/aiRank</loc><lastmod>2025-12-20T14:27:57.183Z</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/aiRank/aiRanking</loc><lastmod>2025-12-20T14:27:57.182Z</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/accounts</loc><lastmod>2025-12-20T14:27:57.182Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
+<url><loc>https://aitoearn.ai/zh-CN/accounts/auth</loc><lastmod>2025-12-20T14:27:57.179Z</lastmod><changefreq>monthly</changefreq><priority>0.7</priority></url>
</urlset>
\ No newline at end of file
diff --git a/project/web/src/app/layout/LayoutSidebar/components/NavSection.tsx b/project/web/src/app/layout/LayoutSidebar/components/NavSection.tsx
index 8f8bbb0c..51edc5cf 100644
--- a/project/web/src/app/layout/LayoutSidebar/components/NavSection.tsx
+++ b/project/web/src/app/layout/LayoutSidebar/components/NavSection.tsx
@@ -4,6 +4,7 @@
'use client'
+import { useState } from 'react'
import Link from 'next/link'
import { FileText, PlusCircle } from 'lucide-react'
import { useTransClient } from '@/app/i18n/client'
@@ -121,27 +122,95 @@ interface NavSectionWithAddChannelProps extends NavSectionProps {
}
export function NavSection({ items, currentRoute, collapsed, onAddChannel }: NavSectionWithAddChannelProps) {
- // 在 "互动数据" 后面插入 Add Channel 按钮 (index 3,即第4个位置)
- const interactiveIndex = items.findIndex(item => item.translationKey === 'interactive')
- const insertIndex = interactiveIndex !== -1 ? interactiveIndex + 1 : 4
+ // Move Add Channel to be the second item (under Home)
+ const addChannelInsertIndex = 1
+
+ // Keys to group into a collapsed section
+ const groupKeys = [
+ 'tasksHistory',
+ 'dataStatistics',
+ 'header.materialLibrary',
+ 'header.draftBox',
+ ]
+
+ const groupedItems = items.filter(i => groupKeys.includes(i.translationKey as string))
+ const otherItems = items.filter(i => !groupKeys.includes(i.translationKey as string))
+
+ const [groupOpen, setGroupOpen] = useState(false)
return (
<nav className="flex flex-col gap-1">
- {items.map((item, index) => (
- <div key={item.path || item.translationKey}>
- <NavItem
- item={item}
- isActive={item.path === currentRoute}
- collapsed={collapsed}
- />
- {/* 在指定位置插入 Add Channel 按钮 */}
- {index === insertIndex - 1 && onAddChannel && (
- <div className="mt-1">
- <AddChannelButton collapsed={collapsed} onClick={onAddChannel} />
+ {otherItems.map((item, index) => {
+ // Render first item (Home)
+ if (index === 0) {
+ return (
+ <div key={item.path || item.translationKey}>
+ <NavItem
+ item={item}
+ isActive={item.path === currentRoute}
+ collapsed={collapsed}
+ />
+ {/* Insert Add Channel right after first item */}
+ {onAddChannel && (
+ <div className="mt-1">
+ <AddChannelButton collapsed={collapsed} onClick={onAddChannel} />
+ </div>
+ )}
+ </div>
+ )
+ }
+
+ // For other items (excluding the grouped ones), render normally
+ return (
+ <div key={item.path || item.translationKey}>
+ <NavItem
+ item={item}
+ isActive={item.path === currentRoute}
+ collapsed={collapsed}
+ />
+ </div>
+ )
+ })}
+
+ {/* Collapsible group for Task History / Data / Library / Drafts */}
+ {groupedItems.length > 0 && (
+ <div>
+ <div className="mt-1">
+ <button
+ onClick={() => setGroupOpen((s) => !s)}
+ className={cn(
+ 'relative flex items-center rounded-lg text-sm font-medium transition-all w-full',
+ 'text-muted-foreground hover:bg-accent hover:text-foreground',
+ collapsed ? 'justify-center px-2 py-2.5' : 'gap-3 px-3 py-2.5',
+ )}
+ >
+ <span className="flex shrink-0 items-center justify-center">
+ <FileText size={20} />
+ </span>
+ {!collapsed && (
+ <span className="overflow-hidden text-ellipsis whitespace-nowrap">
+ {/* Use a generic label for the grouped section */}
+ {useTransClient('route').t('sidebar.more' as any) || 'More'}
+ </span>
+ )}
+ </button>
+ </div>
+
+ {/* Expand list when open */}
+ {!collapsed && groupOpen && (
+ <div className="mt-1 flex flex-col gap-1 pl-2">
+ {groupedItems.map((gitem) => (
+ <NavItem
+ key={gitem.path || gitem.translationKey}
+ item={gitem}
+ isActive={gitem.path === currentRoute}
+ collapsed={collapsed}
+ />
+ ))}
</div>
)}
</div>
- ))}
+ )}
</nav>
)
}
diff --git a/project/web/src/components/Chat/TaskCard/index.tsx b/project/web/src/components/Chat/TaskCard/index.tsx
index 5e1fe65a..749a9323 100644
--- a/project/web/src/components/Chat/TaskCard/index.tsx
+++ b/project/web/src/components/Chat/TaskCard/index.tsx
@@ -8,18 +8,13 @@
import type React from 'react'
import { useState } from 'react'
import { useRouter } from 'next/navigation'
-import { Loader2, MessageSquare, MoreHorizontal, Trash2, AlertCircle, CheckCircle2 } from 'lucide-react'
+import { Loader2, MessageSquare, Trash2, AlertCircle, CheckCircle2, Link2 } from 'lucide-react'
import { agentApi } from '@/api/agent'
import { toast } from '@/lib/toast'
import { cn, formatRelativeTime } from '@/lib/utils'
import { useGetClientLng } from '@/hooks/useSystem'
import { useTransClient } from '@/app/i18n/client'
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from '@/components/ui/dropdown-menu'
+import { Modal } from '@/components/ui/modal'
export interface ITaskCardProps {
/** 任务ID */
@@ -38,6 +33,8 @@ export interface ITaskCardProps {
onRateClick?: (taskId: string) => void
/** 选择回调(如果提供,点击卡片将触发选择而不是跳转) */
onSelect?: (id: string) => void
+ /** 在主页展示内联评分控件 */
+ showInlineRating?: boolean
/** 自定义类名 */
className?: string
}
@@ -94,12 +91,17 @@ export function TaskCard({
className,
onSelect,
onRateClick,
+ showInlineRating = false,
}: ITaskCardProps) {
const router = useRouter()
const lng = useGetClientLng()
const { t } = useTransClient('chat')
const [isDeleting, setIsDeleting] = useState(false)
const [isProcessing, setIsProcessing] = useState(false)
+ const [ratingModalOpen, setRatingModalOpen] = useState(false)
+ const [inlineRating, setInlineRating] = useState<number>(0)
+ const [ratingComment, setRatingComment] = useState<string>('')
+ const [isRatingSubmitting, setIsRatingSubmitting] = useState(false)
const statusConfig = getStatusConfig(status, t as (key: string) => string)
@@ -127,37 +129,54 @@ export function TaskCard({
}
/** 处理转发(复制会话为新任务并跳转) */
- const handleForward = async (e: React.MouseEvent) => {
+ const handleShare = async (e: React.MouseEvent) => {
e.stopPropagation()
if (isProcessing) return
try {
setIsProcessing(true)
- // 创建一个新的任务,传入 taskId 以复用会话(后端会在可用时复用 session)
+ // 创建一个新的任务(复用会话),获取新 id
const res = await agentApi.createTask({ prompt: [], taskId: id })
if (res && (res as any).code === 0 && (res as any).data) {
const newTaskId = (res as any).data.id
+ const url = `${window.location.origin}/${lng}/chat/${newTaskId}`
+ try {
+ await navigator.clipboard.writeText(url)
+ toast.success(t('task.copyLinkSuccess' as any) || 'Link copied')
+ } catch {
+ // ignore clipboard error, still navigate
+ }
router.push(`/${lng}/chat/${newTaskId}`)
} else {
- toast.error((res as any)?.msg || t('task.forwardFailed' as any) || 'Forward failed')
+ toast.error((res as any)?.msg || t('task.forwardFailed' as any) || 'Share failed')
}
} catch (error) {
- console.error('Forward failed', error)
- toast.error(t('task.forwardFailed' as any) || 'Forward failed')
+ console.error('Share failed', error)
+ toast.error(t('task.forwardFailed' as any) || 'Share failed')
} finally {
setIsProcessing(false)
}
}
- /** 复制任务链接到剪贴板 */
- const handleCopyLink = async (e: React.MouseEvent) => {
- e.stopPropagation()
+ /** 提交评分(内联) */
+ const submitInlineRating = async () => {
+ if (inlineRating < 1 || inlineRating > 5) {
+ toast.error(t('task.ratingInvalid' as any) || 'Invalid rating')
+ return
+ }
try {
- const url = `${window.location.origin}/${lng}/chat/${id}`
- await navigator.clipboard.writeText(url)
- toast.success(t('task.copyLinkSuccess' as any) || 'Link copied')
+ setIsRatingSubmitting(true)
+ const res = await agentApi.createRating(id, inlineRating, ratingComment)
+ if (res && (res as any).code === 0) {
+ toast.success(t('task.ratingSuccess' as any) || 'Rating submitted')
+ setRatingModalOpen(false)
+ } else {
+ toast.error((res as any)?.msg || (t('task.ratingFailed' as any) || 'Submit failed'))
+ }
} catch (error) {
- console.error('Copy link failed', error)
- toast.error(t('task.copyLinkFailed' as any) || 'Copy failed')
+ console.error('Submit rating failed', error)
+ toast.error(t('task.ratingFailed' as any) || 'Submit failed')
+ } finally {
+ setIsRatingSubmitting(false)
}
}
@@ -209,48 +228,74 @@ export function TaskCard({
)}
</div>
- {/* 更多操作按钮 */}
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <button
- onClick={(e) => e.stopPropagation()}
- disabled={isDeleting}
- className={cn(
- 'absolute top-2 right-2 w-7 h-7 rounded-md flex items-center justify-center',
- 'opacity-0 group-hover:opacity-100 transition-opacity',
- 'hover:bg-muted text-muted-foreground hover:text-foreground',
- isDeleting && 'opacity-100 cursor-wait',
- )}
- >
- {isDeleting ? (
- <Loader2 className="w-4 h-4 animate-spin" />
- ) : (
- <MoreHorizontal className="w-4 h-4" />
- )}
- </button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onClick={handleRateClick} className="focus:bg-muted/5">
- <CheckCircle2 className="w-4 h-4 mr-2" />
- Rate
- </DropdownMenuItem>
- <DropdownMenuItem onClick={handleForward} className="focus:bg-muted/5">
- {isProcessing ? <Loader2 className="w-4 h-4 mr-2 animate-spin" /> : <MessageSquare className="w-4 h-4 mr-2" />}
- Forward
- </DropdownMenuItem>
- <DropdownMenuItem onClick={handleCopyLink} className="focus:bg-muted/5">
- <MoreHorizontal className="w-4 h-4 mr-2" />
- Copy link
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={handleDelete}
- className="text-destructive focus:text-destructive focus:bg-destructive/10"
+ {/* Action buttons: Share (forward+copy) and Delete */}
+ <div className="absolute top-2 right-2 flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
+ <button
+ onClick={handleShare}
+ disabled={isDeleting || isProcessing}
+ className="w-8 h-8 rounded-md flex items-center justify-center hover:bg-muted text-muted-foreground hover:text-foreground"
+ aria-label="share"
+ >
+ {isProcessing ? <Loader2 className="w-4 h-4 animate-spin" /> : <Link2 className="w-4 h-4" />}
+ </button>
+ <button
+ onClick={handleDelete}
+ disabled={isDeleting}
+ className="w-8 h-8 rounded-md flex items-center justify-center hover:bg-muted text-destructive hover:text-destructive/90"
+ aria-label="delete"
+ >
+ {isDeleting ? <Loader2 className="w-4 h-4 animate-spin" /> : <Trash2 className="w-4 h-4" />}
+ </button>
+ </div>
+
+ {/* Inline rating UI for homepage usage */}
+ {showInlineRating && (
+ <>
+ <div className="mt-3">
+ <div className="flex items-center gap-2">
+ {Array.from({ length: 5 }).map((_, idx) => {
+ const v = idx + 1
+ return (
+ <button
+ key={v}
+ onClick={(e) => {
+ e.stopPropagation()
+ setInlineRating(v)
+ setRatingModalOpen(true)
+ }}
+ className={cn(
+ 'w-7 h-7 rounded-md border flex items-center justify-center',
+ inlineRating >= v ? 'bg-amber-100 border-amber-300 text-amber-700' : 'bg-transparent'
+ )}
+ aria-label={`rate-${v}`}
+ >
+ {v}
+ </button>
+ )
+ })}
+ </div>
+ </div>
+
+ <Modal
+ open={ratingModalOpen}
+ title={t('task.externalRating' as any) || 'Rate selected task'}
+ onCancel={() => setRatingModalOpen(false)}
+ onOk={submitInlineRating}
+ okText={isRatingSubmitting ? t('task.submitting' as any) || 'Submitting' : t('task.submit' as any) || 'Submit'}
+ confirmLoading={isRatingSubmitting}
>
- <Trash2 className="w-4 h-4 mr-2" />
- Delete
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ <div className="flex flex-col gap-2">
+ <div className="text-sm text-muted-foreground">Task: {id}</div>
+ <textarea
+ value={ratingComment}
+ onChange={(e) => setRatingComment(e.target.value)}
+ placeholder={t('task.ratingCommentPlaceholder' as any) || 'Optional comment'}
+ className="w-full p-2 border rounded-md resize-none h-24"
+ />
+ </div>
+ </Modal>
+ </>
+ )}
</div>
)
}
diff --git a/project/web/src/components/Home/TaskPreview/index.tsx b/project/web/src/components/Home/TaskPreview/index.tsx
index cb74e9b2..88547a28 100644
--- a/project/web/src/components/Home/TaskPreview/index.tsx
+++ b/project/web/src/components/Home/TaskPreview/index.tsx
@@ -151,7 +151,9 @@ export function TaskPreview({ limit = 4, className }: ITaskPreviewProps) {
createdAt={task.createdAt}
updatedAt={task.updatedAt}
onDelete={handleDelete}
- onSelect={(id: string) => {
+ // Do NOT pass onSelect so clicking the card navigates to the chat detail.
+ // Keep onRateClick so users can still select a task for external rating.
+ onRateClick={(id: string) => {
setSelectedTaskId(id)
}}
/>