Skip to content

Commit 076bc60

Browse files
committed
first commit
0 parents  commit 076bc60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2155
-0
lines changed

.babelrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compact": false,
3+
"presets": [
4+
["latest", { "modules": false }],
5+
"babel-preset-stage-0",
6+
"react"
7+
],
8+
"plugins": ["babel-plugin-transform-decorators-legacy"],
9+
"env": {
10+
"development": {
11+
"presets": [
12+
"react-hmre"
13+
]
14+
}
15+
}
16+
}

.editorconfig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig is awesome:
2+
http://EditorConfig.org
3+
4+
# top-most EditorConfig file
5+
root = true
6+
7+
# Unix-style newlines with a newline ending every file
8+
[*]
9+
charset = utf-8
10+
end_of_line = lf
11+
indent_style = space
12+
insert_final_newline = true
13+
trim_trailing_whitespace = true
14+
15+
[*.{js,jsx,scss}]
16+
indent_size = 2
17+
18+
# Tab indentation (no size specified)
19+
[Makefile]
20+
indent_style = tab

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
.DS_Store
4+
.idea
5+
.project

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry=https://registry.npm.taobao.org/
2+
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7

app.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Created by Weil on 2017/5/10.
3+
*/
4+
const Koa = require('koa');
5+
const app = new Koa();
6+
const port = 8333;
7+
const path = require('path');
8+
const convert = require('koa-convert');
9+
10+
const cors = require('koa-cors');
11+
const serve = require('koa-static-server');
12+
const bodyParser = require('koa-bodyparser');
13+
14+
app.use(bodyParser());
15+
// app.use(async (ctx, next) => {
16+
// console.log(ctx.request.body, ctx.path, 'ppp');
17+
// await next();
18+
// });
19+
app.use(convert(cors()));
20+
const router = require('./router')(app);
21+
app.use(serve({rootDir: path.join(__dirname, './static'), rootPath: '/static'}));
22+
23+
app.listen(port, () => {
24+
console.log(`earlyjoy已经启动,监听${port}端口`);
25+
});
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import './feedCard.scss';
2+
import React, { Component } from 'react';
3+
import PropTypes from 'prop-types';
4+
import { Link } from 'react-router-dom';
5+
6+
export default class extends Component {
7+
constructor () {
8+
super();
9+
}
10+
11+
static propTypes = {
12+
item: PropTypes.object,
13+
route: PropTypes.string
14+
};
15+
16+
static defaultProps = {
17+
item: {},
18+
route: ''
19+
};
20+
21+
render () {
22+
let { img, text, time } = this.props.item;
23+
let { route } = this.props;
24+
25+
return (
26+
<Link to={route}>
27+
<div className="weui-cells feed-card-item">
28+
<div className="img-wrap">
29+
<img src={img}/>
30+
</div>
31+
<div className="info">
32+
<span className="text">{text}</span>
33+
<span className="time">{time}</span>
34+
</div>
35+
</div>
36+
</Link>
37+
)
38+
}
39+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.feed-card-item {
2+
height: 70px;
3+
display: flex;
4+
align-items: center;
5+
margin-top: 10px;
6+
padding: 10px;
7+
.img-wrap {
8+
flex: none;
9+
margin-right: 10px;
10+
height: 100%;
11+
display: flex;
12+
align-items: center;
13+
img {
14+
height: 50px;
15+
}
16+
}
17+
.info {
18+
flex: 1;
19+
display: flex;
20+
flex-direction: column;
21+
.text {
22+
23+
}
24+
.time {
25+
26+
}
27+
}
28+
}

client/component/footer/index.jsx

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import './index.scss';
2+
import React, { Component } from 'react';
3+
import { Link } from 'react-router-dom';
4+
5+
export default class extends Component {
6+
constructor () {
7+
super();
8+
}
9+
10+
render () {
11+
return (
12+
<ul className="footer">
13+
<li className="footer-item">
14+
<Link to="/index">
15+
<span className="iconfont icon-zhuye" title="主页"/>
16+
<span className="footer-item-text">主页</span>
17+
</Link>
18+
</li>
19+
<li className="footer-item">
20+
<Link to="/today">
21+
<span className="iconfont icon-liebiao" title="今日列表"/>
22+
<span className="footer-item-text">今日列表</span>
23+
</Link>
24+
</li>
25+
<li className="footer-item">
26+
<Link to="/rank">
27+
<span className="iconfont icon-paixingbang" title="排行榜"/>
28+
<span className="footer-item-text">排行榜</span>
29+
</Link>
30+
</li>
31+
<li className="footer-item">
32+
<Link to="/mine">
33+
<span className="iconfont icon-gerenzhongxin" title="个人中心"/>
34+
<span className="footer-item-text">个人中心</span>
35+
</Link>
36+
</li>
37+
</ul>
38+
)
39+
}
40+
}

client/component/footer/index.scss

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.footer {
2+
display: flex;
3+
position: fixed;
4+
width: 100%;
5+
left: 0;
6+
bottom: 0;
7+
height: 50px;
8+
border-top: 1px solid #ccc;
9+
background-color: #fff;
10+
z-index: 10;
11+
.footer-item {
12+
flex: 1;
13+
}
14+
.footer-item a {
15+
flex: 1;
16+
display: flex;
17+
height: 100%;
18+
flex-direction: column;
19+
align-items: center;
20+
justify-content: center;
21+
color: #666;
22+
.footer-item-text {
23+
font-size: 12px;
24+
}
25+
.iconfont {
26+
27+
}
28+
}
29+
}

client/component/header/index.jsx

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import './index.scss';
2+
import React, { Component } from 'react';
3+
import { connect } from 'react-redux';
4+
5+
@connect(state => ({
6+
routing: state.routing
7+
}))
8+
export default class extends Component {
9+
constructor () {
10+
super();
11+
}
12+
13+
getTitle () {
14+
let { location: { pathname } } = this.props.routing;
15+
switch (pathname) {
16+
case '/index':
17+
return '首页';
18+
break;
19+
default:
20+
return '我是早鸟';
21+
}
22+
}
23+
24+
render () {
25+
return (
26+
<div className="header">
27+
<div className="inner">
28+
{this.getTitle()}
29+
</div>
30+
</div>
31+
)
32+
}
33+
}

client/component/header/index.scss

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.header {
2+
display: flex;
3+
height: 50px;
4+
background-color: #fff;
5+
align-items: center;
6+
justify-content: center;
7+
border-bottom: 1px solid #f0f0f0;
8+
position: fixed;
9+
width: 100%;
10+
top: 0;
11+
left: 0;
12+
z-index: 10;
13+
.inner {
14+
color: #333;
15+
font-size: 20px;
16+
}
17+
}
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import './scrollList.scss';
2+
import React, { Component, Children } from 'react';
3+
import { findDOMNode } from 'react-dom';
4+
import PropTypes from 'prop-types';
5+
6+
export default class extends Component {
7+
constructor () {
8+
super();
9+
this.state = {
10+
isBindScrollEvent: false,
11+
status: 'init' // init wait
12+
};
13+
this.elementScrollHandlerBind = this.elementScrollHandler.bind(this);
14+
}
15+
16+
static propTypes = {
17+
hasMore: PropTypes.bool, // 是否还有更多
18+
loading: PropTypes.bool, // 是否能够加载,请求中的状态不允许加载
19+
onLoad: PropTypes.func, // 加载的函数
20+
element: PropTypes.object, // 监听的元素
21+
extra: PropTypes.number, // 额外的底边距
22+
isEmpty: PropTypes.bool // 是否为空
23+
};
24+
25+
static defaultProps = {
26+
hasMore: true,
27+
loading: true,
28+
onLoad: ()=>{},
29+
element: null,
30+
extra: 10
31+
};
32+
33+
elementScrollHandler (e) {
34+
let { scrollHeight, clientHeight, scrollTop } = e.target;
35+
let { loading, onLoad, hasMore, extra } = this.props;
36+
37+
console.log('loading:', loading, 'hasMore', hasMore);
38+
if ( clientHeight + scrollTop + extra >= scrollHeight && !loading && hasMore ) {
39+
onLoad();
40+
}
41+
}
42+
43+
componentWillReceiveProps (nextProps) {
44+
this.tryToBindScrollEvent(nextProps.element);
45+
}
46+
47+
componentDidMount () {
48+
this.tryToBindScrollEvent(this.props.element);
49+
}
50+
51+
tryToBindScrollEvent (element) {
52+
let { isBindScrollEvent } = this.state;
53+
54+
if ( element && isBindScrollEvent === false ) {
55+
element.addEventListener('scroll', this.elementScrollHandlerBind, false);
56+
this.setState({ isBindScrollEvent: true });
57+
}
58+
}
59+
60+
componentWillUnmount () {
61+
let { element } = this.props;
62+
if ( element ) {
63+
element.removeEventListener('scroll', this.elementScrollHandlerBind, false);
64+
}
65+
}
66+
67+
render () {
68+
let { loading, hasMore, isEmpty } = this.props;
69+
70+
return (
71+
<div className="scroll-list">
72+
{this.props.children}
73+
{
74+
loading &&
75+
<div className="weui-loadmore">
76+
<i className="weui-loading"/>
77+
<span className="weui-loadmore__tips">正在加载</span>
78+
</div>
79+
}
80+
{
81+
!hasMore &&
82+
<div className="weui-loadmore weui-loadmore_line weui-loadmore_dot">
83+
<span className="weui-loadmore__tips"/>
84+
</div>
85+
}
86+
{
87+
isEmpty &&
88+
<div className="weui-loadmore weui-loadmore_line">
89+
<span className="weui-loadmore__tips">暂无数据</span>
90+
</div>
91+
}
92+
</div>
93+
);
94+
}
95+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.scroll-list {
2+
.weui-loadmore__tips {
3+
background-color: transparent;
4+
}
5+
.weui-loadmore_line {
6+
margin-top: 40px;
7+
}
8+
}

client/component/userCard/userCard.jsx

Whitespace-only changes.

client/component/userCard/userCard.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)