极乐门资源网 Design By www.ioogu.com
一、项目概况
基于react+react-dom+react-router-dom+redux+react-redux+webpack2.0+react-photoswipe+swiper等技术混合开发的手机端仿微信界面聊天室——reactChatRoom,实现了聊天记录下拉刷新、发送消息、表情(动图),图片、视频预览,打赏、红包等功能。
二、技术栈MVVM框架:
react / react-dom状态管理:redux / react-redux页面路由:react-router-dom
弹窗插件:wcPop打包工具:webpack 2.0环境配置:node.js + cnpm图片预览:react-photoswipe轮播滑动:swiper
◆package.json依赖安装:
{ "name": "react-chatroom", "version": "0.1.0", "private": true, "author": "andy", "dependencies": { "react": "^16.8.6", "react-dom": "^16.8.6", "react-redux": "^7.0.3", "react-router-dom": "^5.0.0", "react-scripts": "0.9.x", "redux": "^4.0.1" }, "devDependencies": { "jquery": "^2.2.3", "react-loadable": "^5.5.0", "react-photoswipe": "^1.3.0", "react-pullload": "^1.2.0", "redux-thunk": "^2.3.0", "swiper": "^4.5.0", "webpack": "^1.13.1", "webpack-dev-server": "^1.12.0" }, "scripts": { "start": "set HOST=localhost&&set PORT=3003 && react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" } }
◆ 入口页面index.js配置
/* * @desc 入口页面index.js */ import React from 'react'; import ReactDOM from 'react-dom'; // import {HashRouter as Router, Route} from 'react-router-dom' import App from './App'; // 引入状态管理 import {Provider} from 'react-redux' import {store} from './store' // 导入公共样式 import './assets/fonts/iconfont.css' import './assets/css/reset.css' import './assets/css/layout.css' // 引入wcPop弹窗样式 import './assets/js/wcPop/skin/wcPop.css' // 引入js import './assets/js/fontSize' ReactDOM.render( <Provider store={store}> <App /> </Provider>, document.getElementById('app') );
◆ 页面App.js主模板
import React, { Component } from 'react'; import {HashRouter as Router, Route, Switch, Redirect} from 'react-router-dom' import {connect} from 'react-redux' import $ from 'jquery' // 引入wcPop弹窗插件 import { wcPop } from './assets/js/wcPop/wcPop' // 引入地址路由 import routers from './router' // 导入顶部、底部tabbar import HeaderBar from './components/header' import TabBar from './components/tabbar' class App extends Component { constructor(props){ super(props) console.log('App主页面参数:\n' + JSON.stringify(props, null, 2)) } render() { let token = this.props.token return ( <Router> <div className="weChatIM__panel clearfix"> <div className="we__chatIM-wrapper flexbox flex__direction-column"> {/* 顶部 */} <Switch> <HeaderBar /> </Switch> {/* 主页面 */} <div className="wcim__container flex1"> {/* 路由容器 */} <Switch> { routers.map((item, index) => { return <Route key={index} path={item.path} exact render={props => ( !item.meta || !item.meta.requireAuth "/index" /> </Switch> </div> {/* 底部tabbar */} <Switch> <TabBar /> </Switch> </div> </div> </Router> ); } } const mapStateToProps = (state) =>{ return { ...state.auth } } export default connect(mapStateToProps)(App);
◆ react登录、注册模块 / react登录注册验证
import React, { Component } from 'react'; import { Link } from 'react-router-dom' import { connect } from 'react-redux'; import * as actions from '../../store/action' // 引入wcPop弹窗插件 import { wcPop } from '../../assets/js/wcPop/wcPop.js' class Login extends Component { constructor(props) { super(props) this.state = { tel: '', pwd: '', vcode: '', vcodeText: '获取验证码', disabled: false, time: 0 } } componentDidMount(){ if(this.props.token){ this.props.history.push('/') } } render() { return ( <div className="wcim__lgregWrapper flexbox flex__direction-column"> ...... </div> ) } // 提交表单 handleSubmit = (e) => { e.preventDefault(); var that = this this.state.tel = this.refs.tel.value this.state.pwd = this.refs.pwd.value this.state.vcode = this.refs.vcode.value if (!this.state.tel) { wcPop({ content: '手机号不能为空!', style: 'background:#ff3b30;color:#fff;', time: 2 }); } else if (!checkTel(this.state.tel)) { wcPop({ content: '手机号格式不正确!', style: 'background:#ff3b30;color:#fff;', time: 2 }); } else if (!this.state.pwd) { wcPop({ content: '密码不能为空!', style: 'background:#ff3b30;color:#fff;', time: 2 }); } else if (!this.state.vcode) { wcPop({ content: '验证码不能为空!', style: 'background:#ff3b30;color:#fff;', time: 2 }); } else { // 获取登录之前的页面地址 let redirectUrl = this.props.location.state "color: #ff0000">总结以上所述是小编给大家介绍的react+redux仿微信聊天界面,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
极乐门资源网 Design By www.ioogu.com
极乐门资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
极乐门资源网 Design By www.ioogu.com
暂无react+redux仿微信聊天界面的评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年12月28日
2024年12月28日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]