88 lines
1.8 KiB
JavaScript
88 lines
1.8 KiB
JavaScript
import { useState, useEffect } from 'react';
|
|
import {
|
|
View,
|
|
Text,
|
|
TextInput,
|
|
TouchableOpacity,
|
|
Image,
|
|
StyleSheet,
|
|
Alert,
|
|
StatusBar
|
|
} from 'react-native';
|
|
|
|
import { Toast, Button } from '@ant-design/react-native';
|
|
import { useContextHook } from '@/components/AuthContext/index';
|
|
|
|
import AsyncStorage from '@/storage/index';
|
|
import { useRouter } from '@/hooks/useRouter';
|
|
|
|
import {
|
|
statusBarHeight,
|
|
paddingTopStatusBarHeight,
|
|
flexRow,
|
|
flexColumn,
|
|
flexSub,
|
|
flexShrink,
|
|
flexWrap,
|
|
flexnoWrap,
|
|
justifyStart,
|
|
justifyEnd,
|
|
justifyCenter,
|
|
justifyBetween,
|
|
justifyAround,
|
|
justifyEvenly,
|
|
alignItemsStart,
|
|
alignItemsEnd,
|
|
alignItemsCenter,
|
|
alignItemsStretch,
|
|
positionRelative,
|
|
positionAbsolute,
|
|
useStyles,
|
|
} from '@/assets/styles/css';
|
|
|
|
const Index = () => {
|
|
const { themeColor } = useContextHook();
|
|
const { linkTo, resetAllRoutes, isFocused } = useRouter();
|
|
useEffect(() => {
|
|
const user = AsyncStorage.getItemAsync('user');
|
|
// 这里请求配置后,再跳转
|
|
setTimeout(() => {
|
|
console.log('user', user);
|
|
if (user && user.token) {
|
|
resetAllRoutes('Home');
|
|
} else {
|
|
resetAllRoutes('Login');
|
|
}
|
|
}, 1000);
|
|
}, [isFocused]);
|
|
|
|
return (
|
|
<View style={[flexSub, {}]}>
|
|
<View
|
|
style={[
|
|
flexSub,
|
|
justifyCenter,
|
|
alignItemsCenter,
|
|
flexRow
|
|
]}>
|
|
<Text
|
|
style={{
|
|
fontSize: 24,
|
|
fontWeight: 'bold',
|
|
backgroundColor: 'red',
|
|
}}>
|
|
login111
|
|
</Text>
|
|
<Button type="primary" onPress={() => {
|
|
Toast.show({
|
|
content: 'Please enter user name',
|
|
position: 'center',
|
|
mask: true,
|
|
});
|
|
}}>Click me</Button>
|
|
</View>
|
|
</View>
|
|
);
|
|
};
|
|
export default Index;
|