feat: 首页更新
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
Dimensions,
|
||||
} from 'react-native';
|
||||
import { createThemeStyles, useColorScheme, useThemeInfo } from '@/theme';
|
||||
import { useSelectedCategory } from '@/hooks/useGameMenus';
|
||||
import { useGameMenuTabs } from '@/hooks/useGameMenus';
|
||||
import { getMockGamesByCategory } from '@/services/mockHomeService';
|
||||
import type { Game } from '@/types/home';
|
||||
|
||||
@@ -108,15 +108,11 @@ interface LobbyProps {
|
||||
/**
|
||||
* 游戏大厅组件
|
||||
*/
|
||||
export default function Lobby({
|
||||
games: propGames,
|
||||
onGamePress,
|
||||
topHeight = 0,
|
||||
}: LobbyProps) {
|
||||
export default function Lobby({ games: propGames, onGamePress, topHeight = 0 }: LobbyProps) {
|
||||
const colorScheme = useColorScheme();
|
||||
const s = styles[colorScheme];
|
||||
const { colors } = useThemeInfo();
|
||||
const { selectedCategory } = useSelectedCategory();
|
||||
const { activeMainMenuTab, activeSubMenuTab } = useGameMenuTabs();
|
||||
const [games, setGames] = useState<Game[]>(propGames || []);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
@@ -131,24 +127,20 @@ export default function Lobby({
|
||||
const loadGames = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// const response = await getGames(selectedCategory);
|
||||
// setGames(response.games.length > 0 ? response.games : getMockGamesByCategory(selectedCategory));
|
||||
// const response = await getGames(activeMainMenuTab);
|
||||
// setGames(response.games.length > 0 ? response.games : getMockGamesByCategory(activeMainMenuTab));
|
||||
} catch (error) {
|
||||
console.error('加载游戏失败:', error);
|
||||
setGames(getMockGamesByCategory(selectedCategory));
|
||||
setGames(getMockGamesByCategory(activeMainMenuTab));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
loadGames();
|
||||
}, [propGames, selectedCategory]);
|
||||
}, [propGames, activeMainMenuTab]);
|
||||
|
||||
const renderGameCard = ({ item }: { item: Game }) => (
|
||||
<TouchableOpacity
|
||||
style={s.gameCard}
|
||||
activeOpacity={0.7}
|
||||
onPress={() => onGamePress?.(item)}
|
||||
>
|
||||
<TouchableOpacity style={s.gameCard} activeOpacity={0.7} onPress={() => onGamePress?.(item)}>
|
||||
<View style={s.gameImage}>
|
||||
{item.icon ? (
|
||||
<Image
|
||||
@@ -165,10 +157,7 @@ export default function Lobby({
|
||||
{item.play_up_name}
|
||||
{item.play_cname ? ` - ${item.play_cname}` : ''}
|
||||
</Text>
|
||||
<TouchableOpacity
|
||||
style={s.gameButton}
|
||||
onPress={() => onGamePress?.(item)}
|
||||
>
|
||||
<TouchableOpacity style={s.gameButton} onPress={() => onGamePress?.(item)}>
|
||||
<Text style={s.gameButtonText}>进入游戏</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
@@ -205,4 +194,3 @@ export default function Lobby({
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user