feat: 添加测试框架和优化项目结构
- 添加 Jest 配置和测试设置 - 添加 use-categories hook 的单元测试 - 更新 CLAUDE.md 添加包管理工具说明 - 优化首页、视频页和频道页的组件结构 - 添加 .claude 命令配置文件 - 移除 bun.lock 和 package-lock.json,统一使用 bun - 更新 package.json 依赖 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,12 @@ import { useTemplates, type TemplateDetail } from '@/hooks'
|
||||
const { width: screenWidth, height: screenHeight } = Dimensions.get('window')
|
||||
const TAB_BAR_HEIGHT = 83
|
||||
|
||||
// 检查 URL 是否为视频格式
|
||||
const isVideoUrl = (url: string): boolean => {
|
||||
const videoExtensions = ['.mp4', '.webm', '.mov', '.avi', '.mkv', '.m3u8']
|
||||
return videoExtensions.some(ext => url.toLowerCase().endsWith(ext))
|
||||
}
|
||||
|
||||
// 统一的布局组件
|
||||
const Layout = ({ children }: { children: React.ReactNode }) => (
|
||||
<SafeAreaView style={styles.container} edges={[]}>
|
||||
@@ -165,6 +171,12 @@ export default function VideoScreen() {
|
||||
index,
|
||||
}), [videoHeight])
|
||||
|
||||
// 过滤掉视频类型的 item
|
||||
const filteredTemplates = templates.filter((item: TemplateDetail) => {
|
||||
const displayUrl = item.webpPreviewUrl || item.previewUrl
|
||||
return !(displayUrl && isVideoUrl(displayUrl))
|
||||
})
|
||||
|
||||
if (loading && templates.length === 0) return <LoadingState />
|
||||
if (error && templates.length === 0) return <ErrorState />
|
||||
|
||||
@@ -172,7 +184,7 @@ export default function VideoScreen() {
|
||||
<Layout>
|
||||
<FlatList
|
||||
ref={flatListRef}
|
||||
data={templates}
|
||||
data={filteredTemplates}
|
||||
renderItem={renderItem}
|
||||
keyExtractor={keyExtractor}
|
||||
getItemLayout={getItemLayout}
|
||||
|
||||
Reference in New Issue
Block a user