Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(web): Homepage UI optimization (#429)
yikae4e6b590a7c2
diff --git a/project/web/src/app/[lng]/accounts/accountCore.tsx b/project/web/src/app/[lng]/accounts/accountCore.tsxindex 3a4fff60..9a328cf9 100644--- a/project/web/src/app/[lng]/accounts/accountCore.tsx+++ b/project/web/src/app/[lng]/accounts/accountCore.tsx@@ -716,7 +716,7 @@ export default function AccountPageCore({return (<NoSSR>- <div className="flex flex-col h-screen bg-background">+ <div className="flex flex-col h-full bg-background">{/* Row 1: 顶部导航栏 */}<AccountsTopNavonNewWork={() => {diff --git a/project/web/src/app/[lng]/accounts/components/CalendarTimingItem/index.tsx b/project/web/src/app/[lng]/accounts/components/CalendarTimingItem/index.tsxindex 4161e327..0e82faed 100644--- a/project/web/src/app/[lng]/accounts/components/CalendarTimingItem/index.tsx+++ b/project/web/src/app/[lng]/accounts/components/CalendarTimingItem/index.tsx@@ -86,13 +86,20 @@ const CalendarTimingItem = memo(}}, [isMore, records, reservationsTimesLast, recordMap])- // 进入视图时将“今天”尽量居中显示+ // 进入视图时将"今天"尽量居中显示(仅在日历容器内滚动)useEffect(() => {if (argDate.getTime() === nowDate.getTime()) {// 推迟到布局完成后再滚动setTimeout(() => {- cellRef.current?.scrollIntoView({ block: 'center', inline: 'nearest' })- }, 0)+ const calendarContainer = document.getElementById('calendarTiming-calendar')+ if (calendarContainer && cellRef.current) {+ // 计算目标位置,使"今天"居中显示+ const containerRect = calendarContainer.getBoundingClientRect()+ const cellRect = cellRef.current.getBoundingClientRect()+ const scrollTop = calendarContainer.scrollTop + (cellRect.top - containerRect.top) - (containerRect.height / 2) + (cellRect.height / 2)+ calendarContainer.scrollTo({ top: Math.max(0, scrollTop), behavior: 'smooth' })+ }+ }, 100)}}, [])diff --git a/project/web/src/app/[lng]/layout.tsx b/project/web/src/app/[lng]/layout.tsxindex 15ec57fd..02bbfbd5 100644--- a/project/web/src/app/[lng]/layout.tsx+++ b/project/web/src/app/[lng]/layout.tsx@@ -48,7 +48,7 @@ export default async function RootLayout({{/* 桌面端侧边栏 */}<LayoutSidebar />{/* 主内容区域 */}- <main className="flex-1 overflow-y-auto overflow-x-hidden pt-14 md:pt-0">+ <main className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden pt-14 md:pt-0">{children}</main><script src="/js/xhs_web_sign.js" />diff --git a/project/web/src/app/[lng]/page.tsx b/project/web/src/app/[lng]/page.tsxindex 1980b9f4..27b08344 100644--- a/project/web/src/app/[lng]/page.tsx+++ b/project/web/src/app/[lng]/page.tsx@@ -56,9 +56,9 @@ function BackToTop({ position = 'left' }: { position?: 'left' | 'right' }) {export default function Home() {return (- <div className="min-h-screen bg-background">+ <div className="bg-background">{/* 首屏 Chat 区域 */}- <section className="min-h-[70vh] flex items-center justify-center px-4 pt-32 pb-12">+ <section className="min-h-[60vh] flex items-center justify-center px-4 pt-16 pb-8 md:pt-24 md:pb-12"><HomeChat /></section>diff --git a/project/web/src/app/globals.css b/project/web/src/app/globals.cssindex 75ba95a0..c5dbef59 100644--- a/project/web/src/app/globals.css+++ b/project/web/src/app/globals.css@@ -5,6 +5,11 @@@custom-variant dark (&:is(.dark *));+html, body {+ height: 100%;+ overflow: hidden;+}+body {font-family: "SourceHanSansCN-Regular";}diff --git a/project/web/src/app/i18n/locales/en/chat.json b/project/web/src/app/i18n/locales/en/chat.jsonindex baa27233..06161ee4 100644--- a/project/web/src/app/i18n/locales/en/chat.json+++ b/project/web/src/app/i18n/locales/en/chat.json@@ -68,6 +68,9 @@"connectChannel": "Connect Channel","connectChannelDesc": "You haven't connected your {{platform}} account yet. Please connect your channel account to publish content.","connectNow": "Connect Now",+ "addChannel": "Add Channel",+ "addChannelDesc": "You haven't connected a {{platform}} account yet. Please add a channel to publish content.",+ "addChannelNow": "Add Channel","updateAuth": "Update Authorization","updateAuthDesc": "Your {{platform}} account authorization has expired. Please re-authorize.","reauthorize": "Re-authorize",diff --git a/project/web/src/app/i18n/locales/zh-CN/chat.json b/project/web/src/app/i18n/locales/zh-CN/chat.jsonindex ff64d8bd..8a623126 100644--- a/project/web/src/app/i18n/locales/zh-CN/chat.json+++ b/project/web/src/app/i18n/locales/zh-CN/chat.json@@ -68,6 +68,9 @@"connectChannel": "连接频道","connectChannelDesc": "您还未连接 {{platform}} 账号,请先连接频道账号才能发布内容。","connectNow": "立即连接",+ "addChannel": "添加频道",+ "addChannelDesc": "您还未连接 {{platform}} 账号,请先添加频道才能发布内容。",+ "addChannelNow": "添加频道","updateAuth": "更新授权","updateAuthDesc": "您的 {{platform}} 账号授权已过期,请重新授权。","reauthorize": "重新授权",diff --git a/project/web/src/components/Chat/ActionCard/index.tsx b/project/web/src/components/Chat/ActionCard/index.tsxindex eed90d82..1c4f96d6 100644--- a/project/web/src/components/Chat/ActionCard/index.tsx+++ b/project/web/src/components/Chat/ActionCard/index.tsx@@ -6,11 +6,16 @@'use client'+import { useState } from 'react'import { useRouter, useParams } from 'next/navigation'import { Link2, RefreshCw, Send, ArrowRight, AlertCircle } from 'lucide-react'import { cn } from '@/lib/utils'import { useTransClient } from '@/app/i18n/client'import { Button } from '@/components/ui/button'+import { useUserStore } from '@/store/user'+import { toast } from '@/lib/toast'+import { openLoginModal } from '@/store/loginModal'+import AddAccountModal from '@/app/[lng]/accounts/components/AddAccountModal'import type { IActionCard } from '@/store/agent/agent.types'export interface IActionCardProps {@@ -62,6 +67,10 @@ export function ActionCard({ action, className }: IActionCardProps) {const router = useRouter()const { lng } = useParams()const { t } = useTransClient('chat')+ const token = useUserStore(state => state.token)++ // 添加账号弹窗状态+ const [addAccountVisible, setAddAccountVisible] = useState(false)const platformName = getPlatformDisplayName(action.platform)@@ -71,9 +80,9 @@ export function ActionCard({ action, className }: IActionCardProps) {case 'createChannel':return {icon: <Link2 className="w-5 h-5" />,- title: t('action.connectChannel' as any) || '连接频道',- description: t('action.connectChannelDesc' as any, { platform: platformName }) || `您还未连接 ${platformName} 账号,请先连接频道账号才能发布内容`,- buttonText: t('action.connectNow' as any) || '立即连接',+ title: t('action.addChannel' as any) || 'Add Channel',+ description: t('action.addChannelDesc' as any, { platform: platformName }) || `You haven't connected a ${platformName} account yet. Please add a channel to publish content.`,+ buttonText: t('action.addChannelNow' as any) || 'Add Channel',bgClass: 'bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-blue-950/30 dark:to-indigo-950/30',borderClass: 'border-blue-200 dark:border-blue-800',iconClass: 'text-blue-600 dark:text-blue-400 bg-blue-100 dark:bg-blue-900/50',@@ -129,7 +138,14 @@ export function ActionCard({ action, className }: IActionCardProps) {switch (action.type) {case 'createChannel':- router.push(`/${lng}/accounts?addChannel=${platform}`)+ // 未登录时先登录+ if (!token) {+ toast.warning(t('home.loginRequired' as any) || 'Please login first')+ openLoginModal(() => setAddAccountVisible(true))+ return+ }+ // 直接打开添加账号弹窗+ setAddAccountVisible(true)breakcase 'updateChannel':router.push(`/${lng}/accounts?updateChannel=${platform}`)@@ -191,6 +207,16 @@ export function ActionCard({ action, className }: IActionCardProps) {{config.buttonText}<ArrowRight className="w-4 h-4 ml-2 transition-transform group-hover:translate-x-1" /></Button>++ {/* 添加账号弹窗 - 仅用于 createChannel */}+ {action.type === 'createChannel' && (+ <AddAccountModal+ open={addAccountVisible}+ onClose={() => setAddAccountVisible(false)}+ onAddSuccess={() => setAddAccountVisible(false)}+ showSpaceSelector={true}+ />+ )}</div>)}diff --git a/project/web/src/components/Chat/ChatMessage/index.tsx b/project/web/src/components/Chat/ChatMessage/index.tsxindex c0c62912..9f559d23 100644--- a/project/web/src/components/Chat/ChatMessage/index.tsx+++ b/project/web/src/components/Chat/ChatMessage/index.tsx@@ -6,12 +6,22 @@'use client'-import { useState, useMemo, useEffect } from 'react'+import { useState, useMemo, useEffect, useCallback } from 'react'import Image from 'next/image'-import ReactMarkdown from 'react-markdown'-import { Loader2, AlertCircle, User, ChevronDown, ChevronRight, Wrench, CheckCircle2, FileText } from 'lucide-react'+import ReactMarkdown, { Components } from 'react-markdown'+import { Loader2, AlertCircle, User, ChevronDown, ChevronRight, Wrench, CheckCircle2, FileText, Play } from 'lucide-react'import { cn } from '@/lib/utils'import { getOssUrl } from '@/utils/oss'++/** 判断 URL 是否为视频链接 */+const isVideoUrl = (url: string): boolean => {+ if (!url) return false+ const videoExtensions = ['.mp4', '.webm', '.mov', '.avi', '.mkv', '.m4v', '.ogv']+ const lowerUrl = url.toLowerCase()+ return videoExtensions.some(ext => lowerUrl.includes(ext)) ||+ lowerUrl.includes('video') ||+ (lowerUrl.includes('s3') && lowerUrl.includes('.mp4'))+}import { useTransClient } from '@/app/i18n/client'import type { IUploadedMedia } from '../MediaUpload'import type { IMessageStep, IWorkflowStep, IActionCard } from '@/store/agent'@@ -213,6 +223,75 @@ function MessageStepContent({ step, isLast, isStreaming }: IMessageStepContentPr// 当前步骤是否活跃:是最后一个步骤且消息正在流式输出const isActiveStep = isLast && isStreaming+ // 自定义 Markdown 组件 - 处理视频链接渲染+ const markdownComponents: Components = useMemo(() => ({+ // 自定义链接渲染:视频链接渲染为播放器+ a: ({ href, children }) => {+ if (href && isVideoUrl(href)) {+ const videoUrl = getOssUrl(href)+ return (+ <div className="my-3">+ <video+ src={videoUrl}+ controls+ className="max-w-full max-h-[300px] rounded-lg border border-border"+ preload="metadata"+ >+ Your browser does not support the video tag.+ </video>+ </div>+ )+ }+ // 普通链接+ return (+ <a+ href={href}+ target="_blank"+ rel="noopener noreferrer"+ className="text-primary hover:underline"+ >+ {children}+ </a>+ )+ },+ // 处理纯文本中的视频 URL(不是链接格式)+ p: ({ children }) => {+ // 检查子元素是否包含视频 URL+ const content = String(children)+ const urlRegex = /(https?:\/\/[^\s]+\.mp4[^\s]*)/gi+ const matches = content.match(urlRegex)++ if (matches && matches.length > 0) {+ // 分割内容,将视频 URL 替换为视频播放器+ const parts = content.split(urlRegex)+ return (+ <div>+ {parts.map((part, index) => {+ if (matches.includes(part)) {+ const videoUrl = getOssUrl(part)+ return (+ <div key={index} className="my-3">+ <video+ src={videoUrl}+ controls+ className="max-w-full max-h-[300px] rounded-lg border border-border"+ preload="metadata"+ >+ Your browser does not support the video tag.+ </video>+ </div>+ )+ }+ return part ? <p key={index} className="mb-2 last:mb-0">{part}</p> : null+ })}+ </div>+ )+ }++ return <p className="mb-2 last:mb-0">{children}</p>+ },+ }), [])+return (<div className={cn(styles.messageStep,@@ -225,7 +304,7 @@ function MessageStepContent({ step, isLast, isStreaming }: IMessageStepContentPr'text-sm leading-relaxed text-foreground',styles.markdownContent,)}>- <ReactMarkdown>{step.content}</ReactMarkdown>+ <ReactMarkdown components={markdownComponents}>{step.content}</ReactMarkdown></div>)}