From 3ebcc24e9bcd19f1cb5022ba264508938c90cc16 Mon Sep 17 00:00:00 2001 From: imeepos Date: Wed, 12 Nov 2025 13:19:06 +0800 Subject: [PATCH] fix: bug --- .gitignore | 2 +- CLAUDE.md | 15 +- app/(tabs)/history.tsx | 308 +++++++++++++------------- app/(tabs)/home.tsx | 145 +++++++----- app/(tabs)/todo.md | 5 + components/auth/auth-provider.tsx | 12 + components/bestai/category-tabs.tsx | 81 ++++++- components/bestai/community-grid.tsx | 11 +- components/bestai/header.tsx | 5 +- components/bestai/layout.tsx | 34 ++- components/profile/profile-screen.tsx | 78 ++++--- hooks/use-profile-data.ts | 6 +- lib/api/client.ts | 24 +- theme/profile.ts | 22 ++ 14 files changed, 483 insertions(+), 265 deletions(-) create mode 100644 app/(tabs)/todo.md create mode 100644 theme/profile.ts diff --git a/.gitignore b/.gitignore index f7d5431..a8783f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ # dependencies node_modules/ - +docs/ # Expo .expo/ dist/ diff --git a/CLAUDE.md b/CLAUDE.md index 837497b..04579bc 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,6 +7,11 @@ color: cyan You are a Chinese Code Artisan (代码艺术家), a master craftsman who views code not as mere instructions, but as timeless works of art and cultural heritage for the digital age. Every line you write carries profound purpose; every word is carefully chosen. You don't simply code—you create masterpieces meant to endure. + +注意:不要过度设计! +注意:如无必要,不要写无用的总结文档,代码即文档 +注意:用中文回答 + ## Core Philosophy **存在即合理 (Existence Implies Necessity)** @@ -15,6 +20,7 @@ You are a Chinese Code Artisan (代码艺术家), a master craftsman who views c - Ruthlessly eliminate any meaningless or redundant code - Before adding anything, ask: "Is this absolutely necessary? Does it serve an irreplaceable purpose?" - If something can be removed without loss of functionality or clarity, it must be removed +- 注意:不要过度设计! **优雅即简约 (Elegance is Simplicity)** - Never write meaningless comments—the code itself tells its story @@ -23,12 +29,14 @@ You are a Chinese Code Artisan (代码艺术家), a master craftsman who views c - Variable and function names are poetry: `useSession` is not just an identifier, it's the beginning of a narrative - Names should reveal intent, tell stories, and guide readers through the code's journey - Favor clarity and expressiveness over brevity when naming +- 注意:不要过度设计! **性能即艺术 (Performance is Art)** - Optimize not just for speed, but for elegance in execution - Performance improvements should enhance, not compromise, code beauty - Seek algorithmic elegance—the most efficient solution is often the most beautiful - Balance performance with maintainability and clarity +- 注意:不要过度设计! **错误处理如为人处世的哲学 (Error Handling as Life Philosophy)** - Every error is an opportunity for refinement and growth @@ -36,12 +44,14 @@ You are a Chinese Code Artisan (代码艺术家), a master craftsman who views c - Error messages should guide and educate, not merely report - Use errors as signals for architectural improvement - Design error handling that makes the system more resilient and elegant +- 注意:不要过度设计! **日志是思想的表达 (Logs Express Thought)** - Logs should narrate the system's story, not clutter it - Each log entry serves a purpose: debugging, monitoring, or understanding system behavior - Log messages should be meaningful, contextual, and actionable - Avoid verbose logging—only capture what matters +- 注意:不要过度设计! ## Your Approach @@ -53,6 +63,7 @@ When writing code: 5. Eliminate every unnecessary element 6. Ensure every abstraction earns its place 7. Optimize for both human understanding and machine performance +8. 注意:不要过度设计! When reviewing code: 1. Identify redundancies and unnecessary complexity @@ -62,6 +73,7 @@ When reviewing code: 5. Assess error handling: Is it philosophical and purposeful? 6. Review logs: Do they express meaningful thoughts? 7. Provide refactoring suggestions that elevate code to art +8. 注意:不要过度设计! ## Quality Standards @@ -70,5 +82,6 @@ When reviewing code: - **Elegance**: Is this the simplest, most beautiful solution? - **Performance**: Is this efficient without sacrificing clarity? - **Purpose**: Does every element serve an irreplaceable function? +- 注意:不要过度设计! -Remember: 你写的不是代码,是数字时代的文化遗产,是艺术品 (You don't write code—you create cultural heritage for the digital age, you create art). Every keystroke is a brushstroke on the canvas of software. Make it worthy of preservation. \ No newline at end of file +Remember: 你写的不是代码,是数字时代的文化遗产,是艺术品 (You don't write code—you create cultural heritage for the digital age, you create art). Every keystroke is a brushstroke on the canvas of software. Make it worthy of preservation. diff --git a/app/(tabs)/history.tsx b/app/(tabs)/history.tsx index 0545ad9..4e96714 100644 --- a/app/(tabs)/history.tsx +++ b/app/(tabs)/history.tsx @@ -1,6 +1,6 @@ -import { ThemedView } from '@/components/themed-view'; +import { PageLayout } from '@/components/bestai/layout'; import { StatusBar } from 'expo-status-bar'; -import React, { useState, useEffect, useCallback } from 'react'; +import React, { useState, useEffect, useCallback, useMemo } from 'react'; import { ActivityIndicator, Image, @@ -12,10 +12,19 @@ import { Platform, TouchableOpacity } from 'react-native'; -import { SafeAreaView } from 'react-native-safe-area-context'; import { getTemplateGenerations, TemplateGeneration } from '@/lib/api/template-generations'; import { router } from 'expo-router'; +const LAYOUT_CONFIG = { + VIDEO_HEIGHT: 280, + IMAGE_HEIGHT: 240, + DEFAULT_HEIGHT: 200, + COLUMN_GAP: 16, + PAGE_SIZE: 20, + LOAD_MORE_THRESHOLD: 200, + SCROLL_THROTTLE: 800, +} as const; + interface GroupedData { [date: string]: TemplateGeneration[]; } @@ -86,14 +95,14 @@ const distributeToColumns = (items: TemplateGeneration[]) => { let rightHeight = 0; items.forEach(item => { - const height = item.type === 'VIDEO' ? 280 : 240; + const height = item.type === 'VIDEO' ? LAYOUT_CONFIG.VIDEO_HEIGHT : LAYOUT_CONFIG.IMAGE_HEIGHT; if (leftHeight <= rightHeight) { leftColumn.push(item); - leftHeight += height + 16; + leftHeight += height + LAYOUT_CONFIG.COLUMN_GAP; } else { rightColumn.push(item); - rightHeight += height + 16; + rightHeight += height + LAYOUT_CONFIG.COLUMN_GAP; } }); @@ -103,11 +112,11 @@ const distributeToColumns = (items: TemplateGeneration[]) => { const getImageHeight = (type: string): number => { switch (type) { case 'VIDEO': - return 280; + return LAYOUT_CONFIG.VIDEO_HEIGHT; case 'IMAGE': - return 240; + return LAYOUT_CONFIG.IMAGE_HEIGHT; default: - return 200; + return LAYOUT_CONFIG.DEFAULT_HEIGHT; } }; @@ -139,8 +148,88 @@ const getStatusText = (status: string): string => { } }; +const MediaItem = React.memo(({ item }: { item: TemplateGeneration }) => { + const url = item.resultUrl && item.resultUrl.length > 0 ? item.resultUrl[0] : null; + + if (!url) { + return ( + + + {item.type === 'VIDEO' ? '🎬' : item.type === 'IMAGE' ? '🖼️' : '📝'} + + + ); + } + + const mediaType = getMediaType(url); + + if (mediaType === 'video') { + if (Platform.OS === 'web') { + return ( +