// 开发说明 大致步骤
// 如何监听登录注册  通过events 插件定义事件

// 编写一个中间界面 在这里判断是否存在登录的信息 如果存在信息,则保持登录,否则重新登录
// 通过事件绑定on 和事件触发emit共同实现
//主菜单
// const HomePage = {
//     HomeScreen: { 
//         screen:Home, // 对应的路由页面
//         navigationOptions: ({ navigation }) => ({
//             tabBarLabel: '首页',
//             tabBarIcon: ({ focused }) => ( 
//                 <Image resizeMode = 'contain' 
//                        source = { focused ?require('./src/image/tabHomeActive.png'):require('./src/image/tabHome.png') } 
//                        style = { { width: isIpd?25:20, height: isIpd?25:20 } }
//                 />
//             )
//         }),
//     },
//     My: { 
//         screen:My, // 对应的路由页面
//         navigationOptions: ({ navigation }) => ({
//             tabBarLabel: '我的',
//             tabBarIcon: ({ focused }) => ( 
//                 <Image resizeMode = 'contain' 
//                     source = { focused ?require('./src/image/tabMyActive.png'):require('./src/image/tabMy.png') } 
//                     style = { { width: isIpd?25:20, height: isIpd?25:20} }
//                 />
//             )
//         }),
//     },
//   };

// const TabNavigatorConfigs = {
//     initialRouteName: 'HomeScreen', // 初始显示的Tab对应的页面路由名
//     // tabBarComponent: TabBarTop, // Tab选项卡组件,TabBarBottom TabBarTop 两个值,在iOS中默认为 TabBarBottom ,在Android中默认为 TabBarTop
//     tabBarPosition: 'bottom', // 设置选项卡的位置,在顶部或是底部,有top  bottom
//     lazy: true, // 是否懒加载页面
//     header:null,
//     swipeEnabled: true, 
//     tabBarOptions: {
//         activeTintColor: '#0094d4',
//         inactiveTintColor: '#43a5d3',
//         style:{
//             alignItems: 'center',
//             height:isIpd?80:50,
//         },
//         tabStyle:{
//             height:isIpd?60:40
//         }
//     },
// }
// const Tab = createBottomTabNavigator(HomePage, TabNavigatorConfigs);

// 在app.js中 将该中间界面设置为默认路由
// const StackNavigatorConfigs={
//     initialRouteName:"LoginCheck",//默认路由 LoginCheck登录验证
//     headerMode:'none'
// }

//页面路由定义
// const StackRouteConfigs={
//     Tab: {
//         screen: Tab,
//     },
//     Login:{
//         screen:Login,
//     }
// }
// const Navigators = createStackNavigator(StackRouteConfigs,StackNavigatorConfigs);
// 在app.js中注册登录和退出事件
// componentDidMount(){
//     User.on('login',this.Login());
//     User.on('loginOut',this.LoginOut());
// }

// componentWillUnmount(){
//     User.removeListener('login',this.Login());
//     User.removeListener('loginOut',this.LoginOut());
// }


// 在需要调用的时候
// User.emit('login',Login)
// User.emit('loginOut,LoginOut)

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐