Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
refactor(web): AI Tools history show models&Eng annotations (#186)
布莱恩·奥夫托·杰森张45e190f8f687
diff --git a/project/web/src/app/[lng]/material/ai-generate/page.tsx b/project/web/src/app/[lng]/material/ai-generate/page.tsxindex 25eef965..9bdc8c7c 100644--- a/project/web/src/app/[lng]/material/ai-generate/page.tsx+++ b/project/web/src/app/[lng]/material/ai-generate/page.tsx@@ -18,7 +18,7 @@ import VipContentModal from "@/components/modals/VipContentModal";const { TextArea } = Input;const { Option } = Select;-// 示例图片 URL 常量+// Sample image URL constantsconst SAMPLE_IMAGE_URLS = {shili21: 'https://aitoearn.s3.ap-southeast-1.amazonaws.com/common/web/shili/image-ai-sample-2-1.webp',shili22: 'https://aitoearn.s3.ap-southeast-1.amazonaws.com/common/web/shili/image-ai-sample-2-2.jpeg',@@ -30,9 +30,9 @@ const SAMPLE_IMAGE_URLS = {/**- * AI 工具页(左右布局)- * - 左侧:图标切换 图片/视频 两个模块- * - 右侧:根据模块展示对应功能(复用原有功能逻辑,不改动接口与状态流转)+ * AI tool page (left-right layout)+ * - Left: Icon switching between image/video modules+ * - Right: Display corresponding functions based on module (reuse existing logic, no changes to interfaces and state flow)*/export default function AIGeneratePage() {const params = useParams();@@ -42,22 +42,22 @@ export default function AIGeneratePage() {const lng = (params as any).lng as string;const isEnglishLang = typeof lng === "string" ? lng.toLowerCase().startsWith("en") : false;- // 根据 URL 初始化模块与子标签+ // Initialize module and sub-tabs based on URLconst queryTab = (searchParams.get("tab") || "").toString();const initIsVideo = ["videoGeneration", "text2video", "image2video"].includes(queryTab);const initImageTab = ["textToImage", "imageToImage", "textToFireflyCard", "md2card", "chat"].includes(queryTab) ? (queryTab as any) : "textToImage";const initVideoTab = ["image2video"].includes(queryTab) ? (queryTab as any) : "text2video";- // 左侧模块切换+ // Left module switchingconst [activeModule, setActiveModule] = useState<"image" | "video">(initIsVideo ? "video" : "image");- // 图片子模块切换+ // Image sub-module switchingconst [activeImageTab, setActiveImageTab] = useState<"textToImage" | "imageToImage" | "textToFireflyCard" | "md2card" | "chat">(initImageTab);- // 视频子模块切换+ // Video sub-module switchingconst [activeVideoTab, setActiveVideoTab] = useState<"text2video" | "image2video">(initVideoTab);- // VIP弹窗状态+ // VIP modal stateconst [vipModalOpen, setVipModalOpen] = useState(false);- // 文生图+ // Text to imageconst [prompt, setPrompt] = useState("");const [size, setSize] = useState("1024x1024");const [n, setN] = useState(1);@@ -71,7 +71,7 @@ export default function AIGeneratePage() {const [imageProgress, setImageProgress] = useState(0);const [checkingImageStatus, setCheckingImageStatus] = useState(false);- // Firefly 卡片+ // Firefly cardconst [content, setContent] = useState("");const [title, setTitle] = useState("");const [temp, setTemp] = useState("tempA");@@ -90,7 +90,7 @@ export default function AIGeneratePage() {{ key: "tempD", name: t("aiGenerate.templateD") },];- // 视频生成+ // Video generationconst [videoPrompt, setVideoPrompt] = useState("");const [videoModel, setVideoModel] = useState("");const [videoSize, setVideoSize] = useState("720p");@@ -106,12 +106,12 @@ export default function AIGeneratePage() {const [checkingStatus, setCheckingStatus] = useState(false);const [videoProgress, setVideoProgress] = useState(0);- // 视频历史记录+ // Video historyconst [videoHistory, setVideoHistory] = useState<any[]>([]);const [loadingHistory, setLoadingHistory] = useState(false);const [showHistory, setShowHistory] = useState(false);- // 首/尾帧上传+ // First/tail frame uploadconst firstFrameInputRef = useRef<HTMLInputElement | null>(null);const tailFrameInputRef = useRef<HTMLInputElement | null>(null);const [uploadingFirstFrame, setUploadingFirstFrame] = useState(false);@@ -151,7 +151,7 @@ export default function AIGeneratePage() {finally { setUploadingTailFrame(false); if (e.target) e.target.value = ""; }};- // 多图上传处理+ // Multi-image upload handlingconst handleMultiImageChange = async (e: React.ChangeEvent<HTMLInputElement>) => {const files = e.target.files;if (!files || files.length === 0) return;@@ -184,12 +184,12 @@ export default function AIGeneratePage() {}};- // 删除图片+ // Remove imageconst handleRemoveImage = (index: number) => {setVideoImages(prev => prev.filter((_, i) => i !== index));};- // 清空所有图片+ // Clear all imagesconst handleClearAllImages = () => {setVideoImages([]);};@@ -218,7 +218,7 @@ export default function AIGeneratePage() {const [videoModels, setVideoModels] = useState<any[]>([]);const [imageEditModels, setImageEditModels] = useState<any[]>([]);- // 图生图相关状态+ // Image-to-image related stateconst [imageEditPrompt, setImageEditPrompt] = useState("");const [imageEditModel, setImageEditModel] = useState("");const [imageEditSize, setImageEditSize] = useState("1024x1024");@@ -232,17 +232,17 @@ export default function AIGeneratePage() {const [sourceImages, setSourceImages] = useState<string[]>([]);const [uploadingSourceImage, setUploadingSourceImage] = useState(false);- // 自定义模型下拉+ // Custom model dropdownconst [showModelDropdown, setShowModelDropdown] = useState(false);const [showVideoModelDropdown, setShowVideoModelDropdown] = useState(false);- // 示例轮播+ // Sample carouselconst sampleImages = [SAMPLE_IMAGE_URLS.shili21, SAMPLE_IMAGE_URLS.shili22, SAMPLE_IMAGE_URLS.shili23, SAMPLE_IMAGE_URLS.shili24];const [sampleIdx, setSampleIdx] = useState(0);const handlePrevSample = () => setSampleIdx((p) => (p - 1 + sampleImages.length) % sampleImages.length);const handleNextSample = () => setSampleIdx((p) => (p + 1) % sampleImages.length);- // 保存结果到本地+ // Save results to localconst handleSaveResults = async () => {try {if (!result || !result.length) { message.warning(t('aiGenerate.imageGenerationFailed')); return; }@@ -271,16 +271,16 @@ export default function AIGeneratePage() {document.body.removeChild(a);};- // 图片编辑相关函数+ // Image editing related functionsconst handleSourceImageChange = async (e: React.ChangeEvent<HTMLInputElement>) => {const files = e.target.files;if (!files || files.length === 0) return;- // 检查当前模型的最大图片数量限制+ // Check current model's maximum image count limitconst selectedModel = imageEditModels.find((m: any) => m.name === imageEditModel);const maxImages = selectedModel?.maxInputImages || 1;- // 计算可以上传的图片数量+ // Calculate number of images that can be uploadedconst remainingSlots = maxImages - sourceImages.length;if (remainingSlots <= 0) {message.warning(t('aiGenerate.maxUploadLimitReached' as any, { count: maxImages }));@@ -383,7 +383,7 @@ export default function AIGeneratePage() {setImageEditProgress(100);message.success(t('aiGenerate.imageEditCompleted' as any));- // 自动上传第一张图片到默认素材库组+ // Auto upload first image to default media groupif (imageUrls.length > 0) {await autoUploadToDefaultGroup(imageUrls[0], "img", imageEditModel, imageEditPrompt);}@@ -408,13 +408,13 @@ export default function AIGeneratePage() {const m = videoModels.find((v) => v.name === modelName);if (!m) return 0;- // 如果是 kling 模型,使用 mode 字段匹配+ // If kling model, use mode field for matchingif (m?.channel === 'kling' && m?.pricing) {const item = m.pricing.find((p: any) => p.duration === duration && p.mode === size);return item ? item.price : 0;}- // 其他模型使用 resolution 字段匹配+ // Other models use resolution field for matchingconst item = m?.pricing?.find((p: any) => p.duration === duration && p.resolution === size);return item ? item.price : 0;};@@ -423,7 +423,7 @@ export default function AIGeneratePage() {if (!Array.isArray(videoModels)) return [] as any[];if (videoMode === "text2video") return (videoModels as any[]).filter((m: any) => (m?.modes || []).includes("text2video"));if (videoMode === "image2video") {- // 合并所有支持图片的视频模式+ // Merge all video modes that support imagesreturn (videoModels as any[]).filter((m: any) => {const modes = m?.modes || [];return modes.includes("image2video") || modes.includes("flf2video") || modes.includes("lf2video") || modes.includes("multi-image2video");@@ -472,14 +472,14 @@ export default function AIGeneratePage() {}};- // 格式化时间戳+ // Format timestampconst formatTime = (timestamp: number) => {if (!timestamp) return '-';const date = new Date(timestamp * 1000);return date.toLocaleString();};- // 获取状态显示文本+ // Get status display textconst getStatusText = (status: string) => {switch (status?.toUpperCase()) {case 'SUCCESS':@@ -497,14 +497,14 @@ export default function AIGeneratePage() {}};- // 处理历史记录项点击+ // Handle history item clickconst handleHistoryItemClick = async (item: any) => {if (item.status === 'SUCCESS' && item.data?.video_url) {setVideoResult(item.data.video_url);setVideoStatus('completed');setVideoProgress(100);- // 自动上传到默认素材库组+ // Auto upload to default media groupawait autoUploadToDefaultGroup(item.data.video_url, "video", item.model || "Unknown Model", item.prompt || "");} else if (item.status === 'PROCESSING') {setVideoTaskId(item.task_id);@@ -514,14 +514,14 @@ export default function AIGeneratePage() {};useEffect(() => { fetchImageModels(); fetchVideoModels(); fetchImageEditModels(); }, []);- // 当切换到视频模块时自动加载历史记录+ // Auto load history when switching to video moduleuseEffect(() => {if (activeModule === "video" && videoHistory.length === 0) {fetchVideoHistory();}}, [activeModule]);- // 当模型切换时,自动设置合适的 quality 值和尺寸值+ // Auto set appropriate quality and size values when model changesuseEffect(() => {if (!model || !imageModels.length) return;@@ -530,21 +530,21 @@ export default function AIGeneratePage() {const sizes = selectedModel?.sizes || [];if (qualities.length > 0) {- // 如果当前 quality 不在模型的 qualities 列表中,则设置为第一个可用的 quality+ // If current quality is not in model's qualities list, set to first available qualityif (!qualities.includes(quality)) {setQuality(qualities[0]);}}if (sizes.length > 0) {- // 如果当前尺寸不在模型的 sizes 列表中,则设置为第一个可用的尺寸+ // If current size is not in model's sizes list, set to first available sizeif (!sizes.includes(size)) {setSize(sizes[0]);}}}, [model, imageModels, quality, size]);- // 当图片编辑模型切换时,自动设置合适的尺寸值并处理图片数量限制+ // Auto set appropriate size value and handle image count limit when image edit model changesuseEffect(() => {if (!imageEditModel || !imageEditModels.length) return;@@ -553,13 +553,13 @@ export default function AIGeneratePage() {const maxImages = selectedModel?.maxInputImages || 1;if (sizes.length > 0) {- // 如果当前尺寸不在模型的 sizes 列表中,则设置为第一个可用的尺寸+ // If current size is not in model's sizes list, set to first available sizeif (!sizes.includes(imageEditSize)) {setImageEditSize(sizes[0]);}}- // 如果当前图片数量超过新模型的最大限制,则移除多余的图片+ // If current image count exceeds new model's maximum limit, remove excess imagesif (sourceImages.length > maxImages) {const removedCount = sourceImages.length - maxImages;setSourceImages(prev => prev.slice(0, maxImages));@@ -567,13 +567,13 @@ export default function AIGeneratePage() {}}, [imageEditModel, imageEditModels, imageEditSize, sourceImages.length]);- // 根据 URL ?tab=... 初始化/响应切换模块与子标签+ // Initialize/respond to module and sub-tab switching based on URL ?tab=...useEffect(() => {const tab = searchParams.get('tab') || '';if (!tab) return;if (tab === 'videoGeneration' || tab === 'text2video' || tab === 'image2video' || tab === 'flf2video' || tab === 'lf2video' || tab === 'multi-image2video') {setActiveModule('video');- // 将所有图片相关的视频模式都映射到 image2video+ // Map all image-related video modes to image2videoif (tab === 'flf2video' || tab === 'lf2video' || tab === 'multi-image2video') {setActiveVideoTab('image2video');} else {@@ -602,12 +602,12 @@ export default function AIGeneratePage() {let durations: any[] = [];let resolutions: any[] = [];- // 如果是 kling 模型,从 pricing 获取选项+ // If kling model, get options from pricingif (current?.channel === 'kling' && current?.pricing) {durations = [...new Set(current.pricing.map((p: any) => p.duration))];resolutions = [...new Set(current.pricing.map((p: any) => p.mode))];} else {- // 其他模型从原有字段获取+ // Other models get from original fieldsdurations = current?.durations || [];resolutions = current?.resolutions || [];}@@ -627,7 +627,7 @@ export default function AIGeneratePage() {if (res.data) {const groups = res.data.list || [];setMediaGroups(groups);- // 找到默认组+ // Find default groupconst defaultGroup = groups.find((group: any) => group.isDefault === true);if (defaultGroup) {setDefaultMediaGroup(defaultGroup._id);@@ -670,7 +670,7 @@ export default function AIGeneratePage() {if (res.data?.image) {setFireflyResult(res.data.image);- // 自动上传到默认素材库组+ // Auto upload to default media groupawait autoUploadToDefaultGroup(res.data.image, "img", "Firefly Card", `${title}: ${content}`);} else {message.error(t("aiGenerate.fireflyCardGenerationFailed"));@@ -691,19 +691,19 @@ export default function AIGeneratePage() {const supported: string[] = current?.supportedParameters || [];const modes: string[] = current?.modes || [];- // 检查多图合成视频+ // Check multi-image videoif (modes.includes('multi-image2video') && supported.includes("image") && videoImages.length === 0) {message.error(t('aiGenerate.pleaseUploadAtLeastOneImage' as any));return;}- // 检查单图视频+ // Check single image videoif (modes.includes('image2video') && !modes.includes('multi-image2video') && supported.includes("image") && !videoImage) {message.error(t("aiGenerate.pleaseUploadFirstFrame"));return;}- // 检查首尾帧视频+ // Check first and tail frame videoif (modes.includes('flf2video') && supported.includes("image") && !videoImage) {message.error(t("aiGenerate.pleaseUploadFirstFrame"));return;@@ -713,7 +713,7 @@ export default function AIGeneratePage() {return;}- // 检查仅尾帧视频+ // Check tail frame only videoif (modes.includes('lf2video') && supported.includes("image_tail") && !videoImageTail) {message.error(t("aiGenerate.pleaseUploadTailFrame"));return;@@ -724,7 +724,7 @@ export default function AIGeneratePage() {const current: any = (filteredVideoModels as any[]).find((m: any) => m.name === videoModel) || {};const data: any = { model: videoModel, prompt: videoPrompt, duration: videoDuration };- // 如果是 kling 模型,传递 mode 参数而不是 size 参数+ // If kling model, pass mode parameter instead of size parameterif (current?.channel === 'kling') {data.mode = videoSize;} else {@@ -735,21 +735,21 @@ export default function AIGeneratePage() {const modes: string[] = current?.modes || [];if (videoMode === "image2video") {- // 多图合成视频+ // Multi-image videoif (modes.includes('multi-image2video') && supported.includes("image") && videoImages.length > 0) {data.image = videoImages.map((image: string) => replaceOssUrl(image));}- // 单图视频+ // Single image videoelse if (modes.includes('image2video') && !modes.includes('multi-image2video') && supported.includes("image") && videoImage) {data.image = replaceOssUrl(videoImage);}- // 首尾帧视频+ // First and tail frame videoelse if (modes.includes('flf2video')) {if (supported.includes("image") && videoImage) data.image = replaceOssUrl(videoImage);if (supported.includes("image_tail") && videoImageTail) data.image_tail = replaceOssUrl(videoImageTail);}- // 仅尾帧视频+ // Tail frame only videoelse if (modes.includes('lf2video') && supported.includes("image_tail") && videoImageTail) {data.image_tail = replaceOssUrl(videoImageTail);}@@ -779,7 +779,7 @@ export default function AIGeneratePage() {setVideoProgress(100);message.success(t("aiGenerate.videoGenerationSuccess"));- // 自动上传到默认素材库组+ // Auto upload to default media groupif (videoUrl) {await autoUploadToDefaultGroup(videoUrl, "video", videoModel, videoPrompt);}@@ -806,7 +806,7 @@ export default function AIGeneratePage() {const normalized = up === "SUCCESS" ? "completed" : up === "FAILED" ? "failed" : up === "PROCESSING" || up === "GENERATING" ? "processing" : up === "NOT_START" || up === "NOT_STARTED" || up === "QUEUED" || up === "PENDING" ? "submitted" : (status || "").toString().toLowerCase();setImageStatus(normalized);- // 计算进度 - 如果没有明确的progress字段,根据状态估算+ // Calculate progress - if no explicit progress field, estimate based on statuslet percent = 0;if (normalized === "submitted") percent = 10;else if (normalized === "processing") percent = 50;@@ -814,13 +814,13 @@ export default function AIGeneratePage() {else if (normalized === "failed") percent = 0;if (normalized === "completed") {- // 优先使用 images 字段,如果没有则使用 response.list+ // Prefer images field, otherwise use response.listconst imageUrls = (images || response?.list || []).map((i: any) => i.url) || [];setResult(imageUrls);setImageProgress(100);message.success(t('aiGenerate.imageGenerationCompleted' as any));- // 自动上传第一张图片到默认素材库组+ // Auto upload first image to default media groupif (imageUrls.length > 0) {await autoUploadToDefaultGroup(imageUrls[0], "img", model, prompt);}@@ -850,7 +850,7 @@ export default function AIGeneratePage() {const cardUrl = res.data.image[0].url;setMd2CardResult(cardUrl);- // 自动上传到默认素材库组+ // Auto upload to default media groupawait autoUploadToDefaultGroup(cardUrl, "img", "Markdown Card", markdownContent.substring(0, 100));} else {setVipModalOpen(true);@@ -861,16 +861,16 @@ export default function AIGeneratePage() {const [currentUploadUrl, setCurrentUploadUrl] = useState<string | null>(null);- // 自动上传到默认素材库组+ // Auto upload to default media groupconst autoUploadToDefaultGroup = async (mediaUrl: string, mediaType: "video" | "img", modelName: string, description: string) => {try {- // 检查是否已经上传过+ // Check if already uploadedif (uploadedContent.has(mediaUrl)) {console.log('Content already uploaded:', mediaUrl);return;}- // 获取素材库列表并找到默认组+ // Get media group list and find default groupconst res: any = await getMediaGroupList(1, 100, mediaType);let defaultGroupId = null;@@ -907,7 +907,7 @@ export default function AIGeneratePage() {});if (uploadRes.data) {- // 标记为已上传+ // Mark as uploadedsetUploadedContent(prev => new Set([...prev, mediaUrl]));message.success(mediaType === "video" ? t("aiGenerate.videoUploadSuccess") : t("aiGenerate.uploadSuccess"));console.log('上传成功');@@ -1545,7 +1545,7 @@ export default function AIGeneratePage() {<Select value={videoSize} onChange={setVideoSize} style={{ width: "100%" }}>{(()=>{const selected:any=(filteredVideoModels as any[]).find((m:any)=>m.name===videoModel)||{};- // 如果是 kling 模型,从 pricing 的 mode 字段获取分辨率选项+ // If kling model, get resolution options from pricing mode fieldif (selected?.channel === 'kling' && selected?.pricing) {const modes = [...new Set(selected.pricing.map((p: any) => p.mode))] as string[];return modes.map((mode: string) => (@@ -1553,7 +1553,7 @@ export default function AIGeneratePage() {));}- // 其他模型从 resolutions 字段获取+ // Other models get from resolutions fieldconst sizes:string[]=selected?.resolutions||[];return sizes.map((s)=> (<Option key={s} value={s}>{s}</Option>));})()}</Select>@@ -1561,7 +1561,7 @@ export default function AIGeneratePage() {<Select value={videoDuration} onChange={setVideoDuration} style={{ width: "100%" }}>{(()=>{const selected:any=(filteredVideoModels as any[]).find((m:any)=>m.name===videoModel)||{};- // 如果是 kling 模型,从 pricing 的 duration 字段获取时长选项+ // If kling model, get duration options from pricing duration fieldif (selected?.channel === 'kling' && selected?.pricing) {const durations = [...new Set(selected.pricing.map((p: any) => p.duration))] as number[];return durations.map((d: number) => (@@ -1569,7 +1569,7 @@ export default function AIGeneratePage() {));}- // 其他模型从 durations 字段获取+ // Other models get from durations fieldconst durs:number[]=selected?.durations||[];return durs.map((d)=> (<Option key={d} value={d}>{d}{t('aiGenerate.seconds')}</Option>));})()}</Select>@@ -1580,7 +1580,7 @@ export default function AIGeneratePage() {const supported:string[]=selected?.supportedParameters||[];const modes:string[]=selected?.modes||[];- // 根据 modes 判断视频生成类型+ // Determine video generation type based on modesconst isImage2Video = modes.includes('image2video');const isFlf2Video = modes.includes('flf2video');const isLf2Video = modes.includes('lf2video');@@ -1589,7 +1589,7 @@ export default function AIGeneratePage() {return (<>{videoMode==='image2video' && (<div className={styles.uploadPanel}>- {/* 单张图生视频 - 只需要首帧 */}+ {/* Single image to video - only needs first frame */}{isImage2Video && supported.includes('image') && !supported.includes('image_tail') && (<div className={styles.uploadCard} onClick={handlePickFirstFrame}>{videoImage ? (@@ -1604,7 +1604,7 @@ export default function AIGeneratePage() {</div>)}- {/* 多图合成视频 - 需要多张图片 */}+ {/* Multi-image video - needs multiple images */}{isMultiImage2Video && supported.includes('image') && (<div className={styles.multiImageUpload}><div className={styles.uploadCard} onClick={() => firstFrameInputRef.current?.click()}>@@ -1651,7 +1651,7 @@ export default function AIGeneratePage() {</div>)}- {/* 首尾帧生成视频 - 需要首帧和尾帧 */}+ {/* First and tail frame video - needs first and tail frames */}{isFlf2Video && supported.includes('image') && supported.includes('image_tail') && (<><div className={styles.uploadCard} onClick={handlePickFirstFrame}>@@ -1680,7 +1680,7 @@ export default function AIGeneratePage() {</>)}- {/* 仅尾帧生成视频 - 只需要尾帧 */}+ {/* Tail frame only video - only needs tail frame */}{isLf2Video && supported.includes('image_tail') && !supported.includes('image') && (<div className={styles.uploadCard} onClick={handlePickTailFrame}>{videoImageTail ? (@@ -1737,7 +1737,7 @@ export default function AIGeneratePage() {</div>)}- {/* 视频历史记录区域 */}+ {/* Video history section */}{activeModule === "video" && (<div className={styles.historySection}><div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>@@ -1799,6 +1799,12 @@ export default function AIGeneratePage() {{getStatusText(item.status)}</span></div>++ {item.data?.model && (+ <div style={{ fontSize: '13px', color: '#666', marginLeft: 'auto', marginBottom: 8 }}>+ <strong>Model:</strong> {item.data.model}+ </div>+ )}<div style={{ fontSize: '13px', color: '#666', marginBottom: 8 }}><div style={{ marginBottom: 4 }}>@@ -1819,6 +1825,8 @@ export default function AIGeneratePage() {<strong>{t('aiGenerate.progress' as any)}:</strong> {item.progress}</div>)}++{item.fail_reason && item.status === 'FAILED' && (<div style={{ fontSize: '13px', color: '#ff4d4f', marginBottom: 8 }}>@@ -1840,6 +1848,8 @@ export default function AIGeneratePage() {/></div>)}++</div>))}</div>@@ -1849,7 +1859,7 @@ export default function AIGeneratePage() {</div></div>- {/* VIP弹窗 */}+ {/* VIP modal */}<VipContentModalopen={vipModalOpen}onClose={() => setVipModalOpen(false)}diff --git a/project/web/src/app/[lng]/page.tsx b/project/web/src/app/[lng]/page.tsxindex 6ae0e49f..9e59877a 100644--- a/project/web/src/app/[lng]/page.tsx+++ b/project/web/src/app/[lng]/page.tsx@@ -2,12 +2,10 @@import { useEffect, useRef, useState } from "react";import styles from "./styles/difyHome.module.scss";-import { directTrans, useTransClient } from "../i18n/client";-import { MAIN_APP_DOWNLOAD_URL, getMainAppDownloadUrlSync } from "../config/appDownloadConfig";+import { useTransClient } from "../i18n/client";+import { getMainAppDownloadUrlSync } from "../config/appDownloadConfig";-import logo from '@/assets/images/logo.png';--// 导入SVG图标+// Import SVG iconsimport gongzhonghao from '@/assets/images/gongzhonghao.jpg';import bilibiliIcon from '@/assets/svgs/plat/bilibili.svg';import douyinIcon from '@/assets/svgs/plat/douyin.svg';@@ -23,12 +21,10 @@ import InstagramIcon from '@/assets/svgs/plat/instagram.png';import LinkedInIcon from '@/assets/svgs/plat/linkedin.png';import PinterestIcon from '@/assets/svgs/plat/pinterest.png';import ThreadsIcon from '@/assets/svgs/plat/threads.png';--// 资料图片import publish1 from '@/assets/images/publish1.png';-// 外部图片 URL 常量+// External image URL constantsconst IMAGE_URLS = {calendar: 'https://aitoearn.s3.ap-southeast-1.amazonaws.com/common/web/app-screenshot/1.%20content%20publish/calendar.jpeg',supportChannels: 'https://aitoearn.s3.ap-southeast-1.amazonaws.com/common/web/app-screenshot/1.%20content%20publish/support_channels.jpeg',@@ -45,16 +41,12 @@ const IMAGE_URLS = {};-import Link from "next/link";import Image from "next/image";import { useRouter } from "next/navigation";-import { Button } from "antd";-import { GlobalOutlined } from "@ant-design/icons";-import { useUserStore } from "@/store/user";import { useParams } from "next/navigation";import { AndroidOutlined } from '@ant-design/icons';-// 版本发布横幅+// Release bannerfunction ReleaseBanner() {const { t } = useTransClient('home');@@ -74,7 +66,7 @@ function ReleaseBanner() {}-// Hero 主标题区+// Hero main title sectionfunction Hero() {const { t } = useTransClient('home');const [displayedText, setDisplayedText] = useState('');@@ -84,14 +76,14 @@ function Hero() {const [startTyping, setStartTyping] = useState(false);const router = useRouter();- // 要显示的完整文本+ // Full text to displayconst fullText = t('hero.title');- const typingSpeed = 120; // 打字速度(毫秒)- const initialDelay = 800; // 初始延迟(毫秒)- const cursorHideDelay = 2000; // 打字完成后光标消失的延迟+ const typingSpeed = 120; // Typing speed (milliseconds)+ const initialDelay = 800; // Initial delay (milliseconds)+ const cursorHideDelay = 2000; // Delay before hiding cursor after typing completesuseEffect(() => {- // 初始延迟后开始打字+ // Start typing after initial delayconst startTimer = setTimeout(() => {setStartTyping(true);}, initialDelay);@@ -103,16 +95,16 @@ function Hero() {if (startTyping && currentIndex < fullText.length) {const currentChar = fullText[currentIndex];- // 根据字符类型调整打字速度+ // Adjust typing speed based on character typelet currentSpeed = typingSpeed;if (currentChar === '\n') {- currentSpeed = typingSpeed * 2; // 换行时稍作停顿+ currentSpeed = typingSpeed * 2; // Pause slightly on line break} else if (currentChar === ' ') {- currentSpeed = typingSpeed * 0.5; // 空格快一点+ currentSpeed = typingSpeed * 0.5; // Space is faster} else if (/[,。!?;:]/.test(currentChar)) {- currentSpeed = typingSpeed * 1.5; // 标点符号稍作停顿+ currentSpeed = typingSpeed * 1.5; // Pause slightly on punctuation} else {- // 添加一些随机性,使打字更自然+ // Add some randomness to make typing more naturalcurrentSpeed = typingSpeed + Math.random() * 50 - 25;}@@ -124,14 +116,14 @@ function Hero() {return () => clearTimeout(timer);} else if (currentIndex >= fullText.length && !isTypingComplete) {setIsTypingComplete(true);- // 打字完成后延迟隐藏光标+ // Delay hiding cursor after typing completessetTimeout(() => {setHideCursor(true);}, cursorHideDelay);}}, [startTyping, currentIndex, fullText, typingSpeed, isTypingComplete, cursorHideDelay]);- // 将文本转换为JSX,处理换行+ // Convert text to JSX, handle line breaksconst renderText = () => {return displayedText.split('\n').map((line, index, array) => (<span key={index}>@@ -158,7 +150,7 @@ function Hero() {<span className={`${styles.cursor} ${hideCursor ? styles.cursorHidden : styles.cursorVisible}`}>|</span></h1>- {/* 移动端按钮 */}+ {/* Mobile button */}<button onClick={() => {router.push("/accounts");}} className={`${styles.heroBtn} ${styles.heroBtnMobile}`}>@@ -172,7 +164,7 @@ function Hero() {{t('hero.subtitle')}</p>- {/* PC端按钮 */}+ {/* Desktop button */}<button onClick={() => {router.push("/accounts");}} className={`${styles.heroBtn} ${styles.heroBtnDesktop}`}>@@ -199,12 +191,12 @@ function Hero() {);}-// 品牌合作伙伴 Logo 区 - 社交媒体平台(无限滚动)+// Brand partner logo section - social media platforms (infinite scroll)function BrandBar() {const { t } = useTransClient('home');const { lng } = useParams();- // 平台数据配置+ // Platform data configurationconst platforms = [{ name: 'YouTube', key: 'YouTube', hasIcon: true, iconPath: youtubeIcon.src },{ name: 'TikTok', key: 'TikTok', hasIcon: true, iconPath: tiktokIcon },@@ -222,10 +214,10 @@ function BrandBar() {{ name: 'X (Twitter)', key: 'X (Twitter)', hasIcon: true, iconPath: TwitterIcon.src },];- // 为了实现无缝滚动,复制一份数据+ // Duplicate data to achieve seamless scrollingconst duplicatedPlatforms = [...platforms, ...platforms];- // 获取平台显示名称+ // Get platform display nameconst getPlatformDisplayName = (platform: any) => {if (lng === 'en') {return platform.key;@@ -262,7 +254,7 @@ function BrandBar() {);}-// 1. Content Publishing — 一键发布 · 多平台触达+// 1. Content Publishing — One-click publishing · Multi-platform reachfunction ContentPublishingSection() {const { t } = useTransClient('home');const [currentImageIndex, setCurrentImageIndex] = useState(0);@@ -271,7 +263,7 @@ function ContentPublishingSection() {const autoRotateRef = useRef<NodeJS.Timeout | null>(null);const carouselRef = useRef<HTMLDivElement>(null);- // 自动轮播+ // Auto rotationuseEffect(() => {if (autoRotate) {autoRotateRef.current = setInterval(() => {@@ -291,7 +283,7 @@ function ContentPublishingSection() {};}, [autoRotate, images.length]);- // 滚轮控制+ // Wheel controluseEffect(() => {const handleWheel = (e: WheelEvent) => {if (carouselRef.current && carouselRef.current.contains(e.target as Node)) {@@ -391,7 +383,7 @@ function ContentPublishingSection() {</div><div className={styles.carouselHint}>- <span>使用滚轮切换图片</span>+ <span>Use scroll wheel to switch images</span></div></div></div>@@ -401,7 +393,7 @@ function ContentPublishingSection() {);}-// 2. Content Hotspot — 爆款灵感引擎+// 2. Content Hotspot — Viral inspiration enginefunction ContentHotspotSection() {const { t } = useTransClient('home');const [currentImageIndex, setCurrentImageIndex] = useState(0);@@ -410,7 +402,7 @@ function ContentHotspotSection() {const autoRotateRef = useRef<NodeJS.Timeout | null>(null);const carouselRef = useRef<HTMLDivElement>(null);- // 自动轮播+ // Auto rotationuseEffect(() => {if (autoRotate) {autoRotateRef.current = setInterval(() => {@@ -430,7 +422,7 @@ function ContentHotspotSection() {};}, [autoRotate, images.length]);- // 滚轮控制+ // Wheel controluseEffect(() => {const handleWheel = (e: WheelEvent) => {if (carouselRef.current && carouselRef.current.contains(e.target as Node)) {@@ -530,7 +522,7 @@ function ContentHotspotSection() {</div><div className={styles.carouselHint}>- <span>使用滚轮切换图片</span>+ <span>Use scroll wheel to switch images</span></div></div></div>@@ -540,7 +532,7 @@ function ContentHotspotSection() {);}-// 3. Content Search — 品牌与市场洞察+// 3. Content Search — Brand and market insightsfunction ContentSearchSection() {const { t } = useTransClient('home');const [currentImageIndex, setCurrentImageIndex] = useState(0);@@ -549,7 +541,7 @@ function ContentSearchSection() {const autoRotateRef = useRef<NodeJS.Timeout | null>(null);const carouselRef = useRef<HTMLDivElement>(null);- // 自动轮播+ // Auto rotationuseEffect(() => {if (autoRotate) {autoRotateRef.current = setInterval(() => {@@ -569,7 +561,7 @@ function ContentSearchSection() {};}, [autoRotate, images.length]);- // 滚轮控制+ // Wheel controluseEffect(() => {const handleWheel = (e: WheelEvent) => {if (carouselRef.current && carouselRef.current.contains(e.target as Node)) {@@ -669,7 +661,7 @@ function ContentSearchSection() {</div><div className={styles.carouselHint}>- <span>使用滚轮切换图片</span>+ <span>Use scroll wheel to switch images</span></div></div></div>@@ -679,7 +671,7 @@ function ContentSearchSection() {);}-// 4. Comments Search — 精准用户挖掘+// 4. Comments Search — Precise user miningfunction CommentsSearchSection() {const { t } = useTransClient('home');const [currentImageIndex, setCurrentImageIndex] = useState(0);@@ -688,7 +680,7 @@ function CommentsSearchSection() {const autoRotateRef = useRef<NodeJS.Timeout | null>(null);const carouselRef = useRef<HTMLDivElement>(null);- // 自动轮播+ // Auto rotationuseEffect(() => {if (autoRotate) {autoRotateRef.current = setInterval(() => {@@ -708,7 +700,7 @@ function CommentsSearchSection() {};}, [autoRotate, images.length]);- // 滚轮控制+ // Wheel controluseEffect(() => {const handleWheel = (e: WheelEvent) => {if (carouselRef.current && carouselRef.current.contains(e.target as Node)) {@@ -808,7 +800,7 @@ function CommentsSearchSection() {</div><div className={styles.carouselHint}>- <span>使用滚轮切换图片</span>+ <span>Use scroll wheel to switch images</span></div></div></div>@@ -818,7 +810,7 @@ function CommentsSearchSection() {);}-// 5. Content Engagement — 互动与增长引擎+// 5. Content Engagement — Interaction and growth enginefunction ContentEngagementSection() {const { t } = useTransClient('home');const [currentImageIndex, setCurrentImageIndex] = useState(0);@@ -827,7 +819,7 @@ function ContentEngagementSection() {const autoRotateRef = useRef<NodeJS.Timeout | null>(null);const carouselRef = useRef<HTMLDivElement>(null);- // 自动轮播+ // Auto rotationuseEffect(() => {if (autoRotate) {autoRotateRef.current = setInterval(() => {@@ -847,7 +839,7 @@ function ContentEngagementSection() {};}, [autoRotate, images.length]);- // 滚轮控制+ // Wheel controluseEffect(() => {const handleWheel = (e: WheelEvent) => {if (carouselRef.current && carouselRef.current.contains(e.target as Node)) {@@ -947,7 +939,7 @@ function ContentEngagementSection() {</div><div className={styles.carouselHint}>- <span>使用滚轮切换图片</span>+ <span>Use scroll wheel to switch images</span></div></div></div>@@ -957,7 +949,7 @@ function ContentEngagementSection() {);}-// 6-8. 即将上线功能整合模块+// 6-8. Upcoming features integration modulefunction UpcomingFeaturesSection() {const { t } = useTransClient('home');@@ -1019,7 +1011,7 @@ function UpcomingFeaturesSection() {);}-// 移动应用下载区+// Mobile app download sectionimport { QRCode } from 'react-qrcode-logo';function DownloadSection() {const { t } = useTransClient('home');@@ -1120,7 +1112,7 @@ function DownloadSection() {-// Enterprise 区块+// Enterprise sectionfunction EnterpriseSection() {const { t } = useTransClient('home');@@ -1145,7 +1137,7 @@ function EnterpriseSection() {);}-// 数据统计区+// Statistics sectionfunction StatsSection() {const { t } = useTransClient('home');@@ -1195,7 +1187,7 @@ function StatsSection() {);}-// 社区区块+// Community sectionfunction CommunitySection() {const { t } = useTransClient('home');const [hoveredButton, setHoveredButton] = useState<string | null>(null);@@ -1273,7 +1265,7 @@ function CommunitySection() {</div><div className={styles.tweets}>- {/* 用户分享卡片区域 */}+ {/* User sharing card area */}</div></div></section>@@ -1287,7 +1279,7 @@ function Footer() {const [currentImageIndex, setCurrentImageIndex] = useState(0);const intervalRef = useRef<NodeJS.Timeout | null>(null);const router = useRouter();- // 背景图片数组+ // Background image arrayconst backgroundImages = [IMAGE_URLS.hotspot,IMAGE_URLS.hotspot2,@@ -1318,7 +1310,7 @@ function Footer() {return (<footer className={styles.footer}><div className={styles.footerContainer}>- {/* 上半部分:Resources 和 Company */}+ {/* Top section: Resources and Company */}<div className={styles.footerTop}><div className={styles.footerColumns}>{/* <div className={styles.footerColumn}>@@ -1360,7 +1352,7 @@ function Footer() {</div></div>- {/* 下半部分:imagine if */}+ {/* Bottom section: imagine if */}<div className={styles.footerBottom}><divclassName={styles.bigText}