refactor: 优化代码和添加类型检查脚本
- 统一 OWNER_ID 导入,从 lib/auth 导入而非环境变量 - 添加 type-checks 脚本用于 TypeScript 类型检查 - 对接 my 页面后端接口,使用 useTemplateGenerations - 添加 MySkeleton 骨架屏组件 - 添加下拉刷新功能 - 添加空状态提示文案 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
78
components/skeleton/HomeSkeleton.tsx
Normal file
78
components/skeleton/HomeSkeleton.tsx
Normal file
@@ -0,0 +1,78 @@
|
||||
import { Dimensions, View, StyleSheet } from 'react-native'
|
||||
import { Skeleton } from './skeleton'
|
||||
|
||||
const { width: screenWidth } = Dimensions.get('window')
|
||||
|
||||
const horizontalPadding = 8 * 2
|
||||
const cardGap = 5
|
||||
const cardWidth = (screenWidth - horizontalPadding - cardGap) / 2
|
||||
|
||||
export function HomeSkeleton() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
{/* 标签骨架屏 */}
|
||||
<View style={styles.tabsContainer}>
|
||||
{[1, 2, 3, 4].map((_, index) => (
|
||||
<Skeleton
|
||||
key={index}
|
||||
width={60}
|
||||
height={20}
|
||||
borderRadius={4}
|
||||
style={styles.tabSkeleton}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
|
||||
{/* 卡片骨架屏 */}
|
||||
<View style={styles.gridContainer}>
|
||||
{[1, 2, 3, 4, 5, 6].map((_, index) => (
|
||||
<View
|
||||
key={index}
|
||||
style={[
|
||||
styles.cardSkeleton,
|
||||
index % 2 === 0 ? styles.cardLeft : styles.cardRight,
|
||||
{ width: cardWidth },
|
||||
]}
|
||||
>
|
||||
<Skeleton
|
||||
width="100%"
|
||||
height={cardWidth * 1.2}
|
||||
borderRadius={16}
|
||||
/>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
backgroundColor: '#090A0B',
|
||||
},
|
||||
tabsContainer: {
|
||||
flexDirection: 'row',
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 12,
|
||||
gap: 20,
|
||||
marginBottom: 18,
|
||||
},
|
||||
tabSkeleton: {
|
||||
marginBottom: 8,
|
||||
},
|
||||
gridContainer: {
|
||||
flexDirection: 'row',
|
||||
flexWrap: 'wrap',
|
||||
paddingHorizontal: 8,
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
cardSkeleton: {
|
||||
marginBottom: 12,
|
||||
},
|
||||
cardLeft: {
|
||||
marginRight: 0,
|
||||
},
|
||||
cardRight: {
|
||||
marginLeft: 0,
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user