Giter Club home page Giter Club logo

react-juejin's Introduction

react-juejin

一个高仿的掘金,大部分是按照掘金的ui来实现的,个别地方就根据自己想法修修改改,只做了移动端的部分,还做pc的部分就要花太多时间了,支持服务端渲染、pwa等,写这个项目主要是对近几个月所学的技术做个实践,看看有哪里还有不足,以及在实际开发的时候会踩到哪些坑,该怎么解决

运行

yarn or npm install

# development
npm run dev:client
npm run dev:server

# production
npm run build
npm start

技术栈

  • react
  • react-dom
  • react-router-dom
  • react-helmet (设置title及meta)
  • react-loadable
  • react-redux
  • redux-connect (异步路由跳转)
  • react-router-config
  • react-virtual-list (长列表渲染)
  • prop-types
  • @rematch/core (rematch 一个更好用的redux)
  • @rematch/loading (调用effects时,自动设置loading)
  • immer (以带副作用的方式修改数据并返回新引用的数据,不会影响原始数据)
  • axios
  • babel-polyfill
  • classnames
  • lodash-es
  • react-swipe
  • react-toastify
  • react-content-loader (内容占位的loading)
  • react-lazyload
  • react-swipe
  • swipe-js-is
  • husky (husky注册git hook)
  • lint-staged (对被提交的文件依次执行写好的任务)
  • webpack
  • eslint
  • express

实现的功能

  • 公共头部
    • 登录
  • 首页
    • 文章点赞
    • 切换分类
  • 文章页
    • 评论列表
    • 评论点赞
    • 推荐文章列表
  • 沸点页
  • 小册
  • 开源库
  • 活动页
  • 用户主页
    • 关注用户
    • 用户动态列表
    • 用户专栏
    • 用户沸点
    • 用户的点赞
    • 用户关注的标签

大概就是以上的功能,登录的话只支持手机登录,或者可以手动设置一个这样的cookie,再刷新页面就登录成功了

const userInfo = {
    token: data.token,
    clientId: data.clientId,
    uid: data.user.uid
}
Cookies.set('userInfo', userInfo, { path: '/' })

项目结构

├─.gitattributes
├─ecosystem.json    pm2部署配置
├─src
|  ├─app.jsx
|  ├─entry-client.js
|  ├─entry-server.js
|  ├─registerServiceWorker.js
|  ├─utils      工具函数
|  ├─store      store配置
|  ├─routes     路由配置
|  ├─models     store的model文件,创建state、reducers、effects
|  ├─containers     页面组件
|  ├─components     展示组件
|  ├─assets     需要webpack处理的资源
|  ├─api      对请求库的封装及获取数据的方法
├─server    服务端渲染
├─public    静态资源
├─build     webpack配置
|   ├─dll   生成dll的配置
├─.vscode
|    └launch.json

预览

首页

首页

首页

文章页

文章页

文章页

沸点

沸点

小册

小册

开源库

开源库

活动

活动

用户页

用户页

用户页

用户页

用户页

最后

要是感兴趣的话,可以自行看代码,大部分内容还是比较简单的,有问题的话欢迎提出了一起讨论

项目地址 线上地址

react-juejin's People

Contributors

kim09ai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-juejin's Issues

非掘金站内文章无法显示

image
非掘金站内文章进入的是另一个页面entry
比如:https://juejin.im/entry/5be4b2026fb9a049e23180e2
正常的文章是这样的:https://juejin.im/post/5be3d54cf265da611d6624d3
接口地址:https://entry-view-storage-api-ms.juejin.im/v1/getEntryView?src=web&entryId=5be4b2026fb9a049e23180e2

<div styleName="title-wrapper">
    <Link to={`/post/${getPostId(item.originalUrl)}`} styleName="title">{item.title}</Link>
</div>

这里不能直接跳转,需要做判断,根据entrylist里的type字段,非站内文章是article,普通文章是post
image

npm start的时候报这个错,请问是

Error: Cannot find module '../../dist/asyncCommonCss'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object. (D:\项目\practice\react-juejin-master\server\ssr\render.js:11:22)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)

跑不起来,运行报错

noConflict.js:3 Uncaught Error: Cannot find module 'core-js/es6'
at webpackMissingModule (noConflict.js:3)
at Object../node_modules/@[email protected]@@babel/polyfill/lib/noConflict.js (noConflict.js:3)
at webpack_require (bootstrap:766)
at fn (bootstrap:129)
at Object../node_modules/
@[email protected]@@babel/polyfill/lib/index.js (index.js:3)
at webpack_require (bootstrap:766)
at fn (bootstrap:129)
at Module. (style.styl?c4cc:45)
at Module../src/entry-client.js (entry-client.js:27)
at webpack_require (bootstrap:766)

求助帖

您好,看到你fork了我的仓库,里面有部分内容写的有问题,能麻烦删除下吗?如果有疑问可以加我的微信:微信号为liangklfang 昵称(幻海之巅),谢谢啦。也希望后续有机会共同探讨。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.