├── .eslintignore ├── .gitignore ├── screenshots ├── home.gif ├── home.png ├── label.png ├── setter.png ├── user.gif └── user.png ├── src ├── assets │ ├── img │ │ ├── no.png │ │ ├── ok.png │ │ ├── close.png │ │ ├── email.png │ │ ├── home.png │ │ ├── logo.png │ │ ├── weibo.png │ │ ├── avatar.png │ │ ├── contact.png │ │ ├── dafault.png │ │ ├── message.png │ │ ├── password.png │ │ ├── popular.png │ │ ├── weixin.png │ │ └── login-background.png │ └── font │ │ ├── iconfont.eot │ │ ├── iconfont.ttf │ │ └── iconfont.woff ├── template │ └── index.html ├── store │ ├── index.js │ ├── Setterstore.js │ ├── Peoplestore.js │ └── Editorstore.js ├── components │ ├── Comment │ │ ├── Loading.js │ │ ├── Text.js │ │ ├── Header.js │ │ ├── Action.js │ │ ├── List.js │ │ ├── Author.js │ │ ├── Textarea.js │ │ └── index.js │ ├── Modal │ │ ├── click │ │ │ ├── Render.js │ │ │ └── index.js │ │ ├── remove │ │ │ ├── Portal.js │ │ │ └── index.js │ │ ├── mouseover │ │ │ ├── Render.js │ │ │ └── index.js │ │ └── Message.js │ ├── Header │ │ ├── User │ │ │ ├── LoginRegistered.js │ │ │ ├── index.js │ │ │ ├── Avatar.js │ │ │ ├── Menu.js │ │ │ ├── Message.js │ │ │ └── MessageList.js │ │ ├── index.js │ │ ├── Write.js │ │ └── Navigation.js │ ├── Collect │ │ ├── Title.js │ │ ├── Switch.js │ │ ├── List.js │ │ ├── Create.js │ │ └── index.js │ ├── Author │ │ ├── List.js │ │ ├── Avatar.js │ │ ├── Follow.js │ │ └── index.js │ ├── Forward │ │ └── index.js │ ├── Label │ │ └── index.js │ ├── Events │ │ └── index.js │ └── Page │ │ └── index.js ├── pages │ ├── 404 │ │ └── index.js │ ├── Posts │ │ ├── Sidebar │ │ │ ├── index.js │ │ │ ├── Order.js │ │ │ └── Search.js │ │ ├── Type.js │ │ ├── List.js │ │ ├── Author.js │ │ ├── Action.js │ │ ├── Article.js │ │ ├── Html.js │ │ └── index.js │ ├── Article │ │ ├── Html.js │ │ ├── Type.js │ │ ├── Header.js │ │ └── index.js │ ├── router.js │ ├── Setter │ │ ├── Links.js │ │ ├── Password.js │ │ ├── index.js │ │ ├── Account.js │ │ ├── PasswordView.js │ │ └── AccountView.js │ ├── People │ │ ├── Sidebar │ │ │ ├── index.js │ │ │ ├── Achieve.js │ │ │ └── Follow.js │ │ ├── Router.js │ │ ├── Links.js │ │ ├── Content │ │ │ ├── Dynamic.js │ │ │ ├── Article.js │ │ │ ├── Collect.js │ │ │ └── Follow.js │ │ ├── Header.js │ │ └── index.js │ ├── Editor │ │ ├── Title.js │ │ ├── Center.js │ │ ├── index.js │ │ ├── Image.js │ │ ├── Write.js │ │ └── Label.js │ ├── Login │ │ ├── index.js │ │ ├── Login.js │ │ ├── Register.js │ │ ├── Submit.js │ │ └── Controller.js │ ├── Collect │ │ ├── Sidebar.js │ │ └── index.js │ ├── Subscr │ │ ├── Search.js │ │ ├── List.js │ │ └── index.js │ └── App.js ├── index.js ├── utils │ └── index.js └── request │ └── index.js ├── .babelrc ├── dist └── index.html ├── .eslintrc.json ├── config └── index.js ├── LICENSE ├── package.json └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | package-lock.json 3 | .vscode/ -------------------------------------------------------------------------------- /screenshots/home.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/screenshots/home.gif -------------------------------------------------------------------------------- /screenshots/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/screenshots/home.png -------------------------------------------------------------------------------- /screenshots/label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/screenshots/label.png -------------------------------------------------------------------------------- /screenshots/setter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/screenshots/setter.png -------------------------------------------------------------------------------- /screenshots/user.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/screenshots/user.gif -------------------------------------------------------------------------------- /screenshots/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/screenshots/user.png -------------------------------------------------------------------------------- /src/assets/img/no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/no.png -------------------------------------------------------------------------------- /src/assets/img/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/ok.png -------------------------------------------------------------------------------- /src/assets/img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/close.png -------------------------------------------------------------------------------- /src/assets/img/email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/email.png -------------------------------------------------------------------------------- /src/assets/img/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/home.png -------------------------------------------------------------------------------- /src/assets/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/logo.png -------------------------------------------------------------------------------- /src/assets/img/weibo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/weibo.png -------------------------------------------------------------------------------- /src/assets/img/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/avatar.png -------------------------------------------------------------------------------- /src/assets/img/contact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/contact.png -------------------------------------------------------------------------------- /src/assets/img/dafault.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/dafault.png -------------------------------------------------------------------------------- /src/assets/img/message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/message.png -------------------------------------------------------------------------------- /src/assets/img/password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/password.png -------------------------------------------------------------------------------- /src/assets/img/popular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/popular.png -------------------------------------------------------------------------------- /src/assets/img/weixin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/weixin.png -------------------------------------------------------------------------------- /src/assets/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/font/iconfont.eot -------------------------------------------------------------------------------- /src/assets/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/font/iconfont.ttf -------------------------------------------------------------------------------- /src/assets/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/font/iconfont.woff -------------------------------------------------------------------------------- /src/assets/img/login-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/manyuewuxin/mengya/HEAD/src/assets/img/login-background.png -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env","react","es2015","stage-0"], 3 | 4 | "plugins": [ 5 | "syntax-dynamic-import", 6 | "transform-decorators-legacy", 7 | "transform-class-properties", 8 | "transform-regenerator", 9 | "react-hot-loader/babel", 10 | "transform-runtime" 11 | ] 12 | } -------------------------------------------------------------------------------- /src/template/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Appstore from "./Appstore"; 2 | import Editorstore from "./Editorstore"; 3 | import Peoplestore from "./Peoplestore"; 4 | import Setterstore from "./Setterstore"; 5 | 6 | export default { 7 | Appstore, 8 | Editorstore, 9 | Peoplestore, 10 | Setterstore 11 | }; 12 | -------------------------------------------------------------------------------- /src/components/Comment/Loading.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | export default function Loading() { 3 | return ( 4 |
5 |
6 |
7 |
8 |
9 |
10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/components/Comment/Text.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import PropTypes from "prop-types"; 3 | 4 | const CommentText = ({ text }) => { 5 | return
{text}
; 6 | }; 7 | 8 | CommentText.propTypes = { 9 | text: PropTypes.string 10 | }; 11 | 12 | export default CommentText; 13 | -------------------------------------------------------------------------------- /src/pages/Posts/Sidebar/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import Search from "./Search"; 3 | import Order from "./Order"; 4 | 5 | export default class SidebarList extends Component { 6 | render() { 7 | return ( 8 |
9 | 10 | 11 |
12 | ); 13 | } 14 | } -------------------------------------------------------------------------------- /src/components/Modal/click/Render.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | @observer 6 | export default class Index extends Component { 7 | static propTypes = { 8 | modal: PropTypes.object, 9 | render: PropTypes.func 10 | }; 11 | render() { 12 | return this.props.render(this.props.modal); 13 | } 14 | } -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import { Provider } from "mobx-react"; 4 | import { configure } from "mobx"; 5 | import Main from "./pages/router"; 6 | import store from "./store"; 7 | import "./assets/css/app.css"; 8 | 9 | configure({ enforceActions: true }); 10 | 11 | ReactDOM.render( 12 | 13 |
14 | , 15 | document.getElementById("root") 16 | ); 17 | -------------------------------------------------------------------------------- /src/components/Header/User/LoginRegistered.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Link } from "react-router-dom"; 3 | export default function Loginbutton() { 4 | return ( 5 |
6 | 7 | 8 | 登录 9 | 10 | 11 | 注册 12 | 13 |
14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /src/pages/404/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import PropTypes from "prop-types"; 3 | 4 | export default class NotFound extends Component { 5 | static propTypes = { 6 | location: PropTypes.object 7 | } 8 | render() { 9 | const { state } = this.props.location; 10 | return( 11 |
12 |

Not Found

13 |
{`没有找到${state?this.props.location.state.error:'该路径'}资源`}
14 |
15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /src/components/Header/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import Navigation from "./Navigation"; 3 | import Write from "./Write"; 4 | import User from "./User"; 5 | 6 | export default class Header extends Component { 7 | render() { 8 | return ( 9 |
10 | 17 |
18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/components/Collect/Title.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | @observer 6 | export default class CollectTitle extends Component { 7 | static propTypes = { 8 | is_create: PropTypes.bool, 9 | continues: PropTypes.func 10 | }; 11 | render() { 12 | return ( 13 |
14 |
{this.props.is_create ? "创建收藏夹" : "添加到收藏夹"}
15 |
X
16 |
17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/components/Collect/Switch.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | @observer 6 | export default class CollectCreate extends Component { 7 | static propTypes = { 8 | switchs: PropTypes.func, 9 | is_create: PropTypes.bool 10 | }; 11 | render() { 12 | return ( 13 |
14 | 17 |
18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser":"babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "node": true 6 | }, 7 | "extends": ["eslint:recommended", "plugin:react/recommended"], 8 | "parserOptions": { 9 | "ecmaVersion": 2018, 10 | "sourceType": "module", 11 | "ecmaFeatures": { 12 | "experimentalObjectRestSpread": true, 13 | "jsx": true 14 | } 15 | }, 16 | "plugins": ["react"], 17 | "globals": { 18 | "Promise":true 19 | }, 20 | "rules": { 21 | "semi": 2, 22 | "no-console":0, 23 | "no-mixed-spaces-and-tabs":0 24 | } 25 | } -------------------------------------------------------------------------------- /src/pages/Article/Html.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | import utils from "@utils"; 5 | 6 | @observer 7 | export default class Html extends Component { 8 | static propTypes = { 9 | html: PropTypes.string, 10 | date: PropTypes.string 11 | }; 12 | render() { 13 | const { html, date } = this.props; 14 | const dt = utils.format(date); 15 | return ( 16 |
17 |
18 |
{`发布于 ${dt.date} ${dt.time}`}
19 |
20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/utils/index.js: -------------------------------------------------------------------------------- 1 | const format = (timestamp) => { 2 | const dt = new Date(timestamp); 3 | 4 | const date=`${dt.getFullYear()}-${dt.getMonth()+1}-${dt.getDate()}`; //日期 5 | 6 | const h=dt.getHours(); 7 | const m=dt.getMinutes()<10 ? `0${dt.getMinutes()}` : dt.getMinutes(); 8 | const s=dt.getSeconds()<10 ? `0${dt.getSeconds()}` : dt.getSeconds(); 9 | 10 | const time=`${h}:${m}:${s}`; //时间 11 | 12 | return {date,time}; 13 | }; 14 | 15 | const search = (search) => { 16 | var regExp = /([^&=]+)=([\w\W]*?)(&|$)/g; 17 | var obj = {}; 18 | var result; 19 | while ((result = regExp.exec(search)) !== null) { 20 | obj[result[1]] = result[2]; 21 | } 22 | return obj; 23 | }; 24 | 25 | export default { 26 | format, 27 | search 28 | }; -------------------------------------------------------------------------------- /src/pages/router.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; 3 | 4 | import App from "./App"; 5 | import NotFound from "./404"; 6 | import Login from "./Login"; 7 | 8 | export default class Routers extends Component { 9 | render() { 10 | return ( 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |
21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | build: { 5 | env: "production", 6 | index: path.resolve(__dirname, "../src/dist/index.html"), 7 | assetsRoot: path.resolve(__dirname, "../dist"), 8 | assetsPublicPath: "/", 9 | productionSourceMap: true, 10 | productionGzip: false, 11 | productionGzipExtensions: ["js", "css"] 12 | }, 13 | dev: { 14 | env: "development", 15 | port: 3000, 16 | assetsPublicPath: "/", 17 | context: [ 18 | "/user", 19 | "/posts", 20 | "/file", 21 | "/editor", 22 | "/logo", 23 | "/collect", 24 | "/avatar" 25 | ], 26 | proxypath: "http://localhost:8000" 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/components/Header/User/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer, inject } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | import Avatar from "./Avatar"; 6 | import Message from "./Message"; 7 | import LoginRegistered from "./LoginRegistered"; 8 | 9 | @inject("Appstore") 10 | @observer 11 | export default class User extends Component { 12 | static propTypes = { 13 | Appstore: PropTypes.object 14 | }; 15 | render() { 16 | if (this.props.Appstore.id !== null) { 17 | return ( 18 | 19 | 20 | 21 | 22 | ); 23 | } else { 24 | return ; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/pages/Article/Type.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | import { Link } from "react-router-dom"; 5 | 6 | @observer 7 | export default class ArticleType extends Component { 8 | static propTypes = { 9 | type: PropTypes.object 10 | }; 11 | render() { 12 | const { type } = this.props; 13 | const list = type.map((types) => { 14 | return ( 15 |
  • 19 | {types} 20 |
  • 21 | ); 22 | }); 23 | return
      {list}
    ; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/components/Author/List.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import { Link } from "react-router-dom"; 4 | import PropTypes from "prop-types"; 5 | 6 | @observer 7 | export default class List extends Component { 8 | static propTypes = { 9 | posts: PropTypes.array 10 | }; 11 | render() { 12 | const list = this.props.posts.map((p, index) => { 13 | return ( 14 |
  • 15 | {`${index + 1}、${p.title}`} 16 |
  • 17 | ); 18 | }); 19 | return ( 20 | 21 |

    最近发表的文章:

    22 |
      {list}
    23 |
    24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/components/Comment/Header.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import PropTypes from "prop-types"; 3 | 4 | export default class CommentCount extends Component { 5 | static propTypes = { 6 | count: PropTypes.number, 7 | setReversed: PropTypes.func, 8 | sort: PropTypes.number 9 | }; 10 | render() { 11 | const { count, sort } = this.props; 12 | return ( 13 |
    14 |
    15 |

    {count > 0 ? `${count} 条评论` : "还没有评论"}

    16 | {count > 0 ? ( 17 |

    18 | {sort === -1 ? "正序显示" : "倒序显示"} 19 |

    20 | ) : null} 21 |
    22 |
    23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/pages/Posts/Type.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import { Link } from "react-router-dom"; 4 | import PropTypes from "prop-types"; 5 | import { toJS } from "mobx"; 6 | 7 | @observer 8 | export default class ArticleType extends Component { 9 | static propTypes = { 10 | type: PropTypes.oneOfType([PropTypes.object, PropTypes.string]) 11 | }; 12 | render() { 13 | const t = toJS(this.props.type); 14 | const type = Array.isArray(t) ? t[0] : t; 15 | return ( 16 |
    17 |
    18 | 来自分类: 19 | 20 | {type} 21 | 22 |
    23 |
    24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/components/Author/Avatar.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import { Link } from "react-router-dom"; 4 | import PropTypes from "prop-types"; 5 | 6 | @observer 7 | export default class Header extends Component { 8 | static propTypes = { 9 | author: PropTypes.object 10 | }; 11 | render() { 12 | const { author } = this.props; 13 | return ( 14 |
    15 |
    16 | 17 | 18 | 19 |
    20 |
    21 | {author.name} 22 | {author.information} 23 |
    24 |
    25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/pages/Setter/Links.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { Link } from "react-router-dom"; 3 | import PropTypes from "prop-types"; 4 | 5 | export default class SwitchLike extends Component { 6 | static propTypes = { 7 | location: PropTypes.object 8 | }; 9 | render() { 10 | const link = [ 11 | { path: "/setter/account", type: "个人资料" }, 12 | { path: "/setter/password", type: "修改密码" } 13 | ]; 14 | const list = link.map((elem) => { 15 | return ( 16 | 20 | {elem.type} 21 | 22 | ); 23 | }); 24 | return
    {list}
    ; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/components/Modal/remove/Portal.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import PropTypes from "prop-types"; 3 | import ReactDOM from "react-dom"; 4 | 5 | export default class RemoveModal extends Component { 6 | static propTypes = { 7 | children: PropTypes.node 8 | }; 9 | constructor(props) { 10 | super(props); 11 | this.node = document.createElement("div"); 12 | this.child = document.createElement("div"); 13 | 14 | this.node.className = "animation_opacity"; 15 | this.child.className = "animation_backdrop"; 16 | 17 | this.node.appendChild(this.child); 18 | } 19 | render() { 20 | return ReactDOM.createPortal(this.props.children, this.node); 21 | } 22 | 23 | componentDidMount() { 24 | //初始化后 25 | document.body.appendChild(this.node); //插入 26 | } 27 | 28 | componentWillUnmount() { 29 | //卸载 30 | this.node.removeChild(this.child); 31 | document.body.removeChild(this.node); //删除 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/pages/People/Sidebar/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | import Achieve from "./Achieve"; 6 | import Follow from "./Follow"; 7 | 8 | @observer 9 | export default class Sidebar extends Component { 10 | static propTypes = { 11 | author: PropTypes.object, 12 | is_myhome: PropTypes.bool 13 | }; 14 | render() { 15 | const { author } = this.props; 16 | return ( 17 |
    18 | 23 | 28 |
    29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/pages/People/Sidebar/Achieve.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | @observer 6 | export default class Create extends Component { 7 | static propTypes = { 8 | create_p_count: PropTypes.number, 9 | collect: PropTypes.number, 10 | like: PropTypes.number 11 | }; 12 | render() { 13 | const { create_p_count, collect, like } = this.props; 14 | return ( 15 |
    16 |

    个人成就

    17 |
    18 |

    19 | 20 | {`创建${create_p_count}篇文章`} 21 |

    22 |

    23 | 24 | {`获得${like}喜欢,${collect}个收藏`} 25 |

    26 |
    27 |
    28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/pages/Editor/Title.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer, inject } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | @inject("Editorstore") 6 | @observer 7 | export default class Title extends Component { 8 | static propTypes = { 9 | Editorstore: PropTypes.object 10 | }; 11 | constructor(props) { 12 | super(props); 13 | this.change = this.change.bind(this); 14 | } 15 | change(e) { 16 | e.stopPropagation(); 17 | this.props.Editorstore.changeTitle(e.target.value); 18 | } 19 | render() { 20 | const { title } = this.props.Editorstore; 21 | return ( 22 |
    23 | 31 |
    32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/components/Author/Follow.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import { Link } from "react-router-dom"; 4 | import PropTypes from "prop-types"; 5 | 6 | @observer 7 | export default class Follow extends Component { 8 | static propTypes = { 9 | author: PropTypes.object, 10 | is_follow: PropTypes.bool, 11 | follow: PropTypes.func 12 | }; 13 | render() { 14 | const { author, is_follow } = this.props; 15 | return ( 16 |
    17 |

    18 | 关注者: 19 | 20 | {author.followers_count} 21 | 22 |

    23 | 28 |
    29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/pages/People/Sidebar/Follow.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | @observer 6 | export default class FollowCount extends Component { 7 | static propTypes = { 8 | is_myhome: PropTypes.bool, 9 | followers_count: PropTypes.number, 10 | following_count: PropTypes.number 11 | }; 12 | render() { 13 | const { is_myhome, followers_count, following_count } = this.props; 14 | return ( 15 |
    16 |

    关注用户

    17 |
    18 |
    19 |

    {`${is_myhome ? "我" : "他"}关注的用户`}

    20 |

    {following_count}

    21 |
    22 |
    23 |

    {`关注${is_myhome ? "我" : "他"}的用户`}

    24 |

    {followers_count}

    25 |
    26 |
    27 |
    28 | ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/pages/Posts/List.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | import Article from "./Article"; 5 | 6 | @observer 7 | export default class List extends Component { 8 | //防更新抖动,利用mobx监听render引用精确更新 9 | static propTypes = { 10 | posts: PropTypes.object.isRequired, 11 | is_my_people: PropTypes.bool.isRequired 12 | }; 13 | render() { 14 | const { posts, is_my_people } = this.props; 15 | const list = posts.map((article, index) => { 16 | return ( 17 |
    25 | ); 26 | }); 27 | return list.length === 0 ? ( 28 |
    列表为空
    29 | ) : ( 30 |
    {list}
    31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 mengya 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/pages/Posts/Sidebar/Order.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { Link } from "react-router-dom"; 3 | import { inject, observer } from "mobx-react"; 4 | import PropTypes from "prop-types"; 5 | 6 | @inject("Appstore") 7 | @observer 8 | export default class Order extends Component { 9 | static propTypes = { 10 | Appstore: PropTypes.object 11 | }; 12 | render() { 13 | const list = this.props.Appstore.app.order.map((p, index) => { 14 | return ( 15 |
  • 19 | 20 | {index + 1} 21 | {p.title} 22 | 23 |
  • 24 | ); 25 | }); 26 | return ( 27 |
    28 |

    热门文章排行

    29 |
      {list}
    30 |
    31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/pages/Login/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { inject, observer } from "mobx-react"; 3 | import { withRouter } from "react-router-dom"; 4 | import PropTypes from "prop-types"; 5 | import Controller from "./Controller"; 6 | 7 | @inject("Appstore") 8 | @withRouter 9 | @observer 10 | export default class Index extends Component { 11 | static propTypes = { 12 | history: PropTypes.object, 13 | location: PropTypes.object, 14 | Appstore: PropTypes.object 15 | }; 16 | render() { 17 | const { Appstore, location, history } = this.props; 18 | 19 | if (Appstore.app.loginPath !== null) { 20 | return ( 21 | 26 | ); 27 | } else if (location.pathname === "/signin" || location.pathname === "/signup") { 28 | return ( 29 | 30 | ); 31 | } 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/pages/Posts/Author.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import { Link } from "react-router-dom"; 4 | import PropTypes from "prop-types"; 5 | 6 | @observer 7 | export default class ArticleAuthor extends Component { 8 | static propTypes = { 9 | author: PropTypes.object, 10 | index: PropTypes.number 11 | }; 12 | render() { 13 | const author = this.props.author[0]; 14 | const index = this.props.index; 15 | return ( 16 |
    17 | 18 | 19 | 20 |
    21 | 25 | {author.name} 26 | 27 | {`,${author.information}`} 28 |
    29 |
    30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/components/Modal/mouseover/Render.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | 5 | @observer 6 | export default class Hove extends Component { 7 | static propTypes = { 8 | Appstore: PropTypes.object, 9 | render: PropTypes.func 10 | }; 11 | constructor(props) { 12 | super(props); 13 | this.transition = this.transition.bind(this); 14 | } 15 | transition(e) { 16 | e.stopPropagation(); 17 | if (this.props.Appstore.hove.opacity === 0) this.props.Appstore.setState("hove", { hove_type: null }); 18 | } 19 | render() { 20 | const { position, opacity } = this.props.Appstore.hove; 21 | const style = { 22 | position: "absolute", 23 | top: position.top, 24 | left: position.left, 25 | opacity: opacity, 26 | transition: "opacity 0.3s" 27 | }; 28 | return ( 29 |
    30 | {this.props.render(this.props.Appstore.hove)} 31 |
    32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/components/Modal/mouseover/index.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | import { inject, observer } from "mobx-react"; 3 | import PropTypes from "prop-types"; 4 | import Render from "./Render"; 5 | import Author from "../../Author"; 6 | import Label from "../../Label"; 7 | 8 | @inject("Appstore") 9 | @observer 10 | export default class Index extends Component { 11 | static propTypes = { 12 | Appstore:PropTypes.object 13 | }; 14 | render() { 15 | if (this.props.Appstore.hove.hove_type !== null){ 16 | return ( 17 | { 18 | switch(hove_type){ 19 | case "author": 20 | return ; 21 | 22 | case "label": 23 | return