-
Notifications
You must be signed in to change notification settings - Fork 0
/
API.md
459 lines (258 loc) · 8.89 KB
/
API.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
### Table of Contents
- [app.js](#appjs)
- [App](#app)
- [store/index.js](#storeindexjs)
- [makeRootSaga](#makerootsaga)
- [injectSagas](#injectsagas)
- [location.js](#locationjs)
- [pushRoute](#pushroute)
- [replaceRoute](#replaceroute)
- [CreateStotre.js](#createstotrejs)
- [OperateReducer.js](#operatereducerjs)
- [makeRootReducer](#makerootreducer)
- [injectReducer](#injectreducer)
- [路由入口文件](#路由入口文件)
- [Routes](#routes)
- [首页主体路由文件](#首页主体路由文件)
- [Home](#home)
- [React](#react)
- [Article/index.js](#articleindexjs)
- [ArticleContainer](#articlecontainer)
- [Component](#component)
- [AppFlux.js](#appfluxjs)
- [toggleMobileSideBar](#togglemobilesidebar)
- [requestPostList](#requestpostlist)
- [receivePostList](#receivepostlist)
- [appReducer](#appreducer)
- [getPostList](#getpostlist)
- [getPostList](#getpostlist-1)
- [getPostListSaga](#getpostlistsaga)
- [getPostListSaga](#getpostlistsaga-1)
- [AppSaga](#appsaga)
- [dataAdapter.js](#dataadapterjs)
- [formatPostListData](#formatpostlistdata)
- [flux.js](#fluxjs)
- [articleReducer](#articlereducer)
- [formatPostData](#formatpostdata)
- [getPostSaga](#getpostsaga)
- [ArticleSaga](#articlesaga)
- [SET_WILL_AUTO_FETCH_POSTS](#set_will_auto_fetch_posts)
- [takeLatest](#takelatest)
- [CategoryListSaga](#categorylistsaga)
## app.js
项目入口文件
**Meta**
- **copyright**: src/app.js 2017/12/14
- **author**: codingplayboy
## App
**Extends Component**
- **See: src/app.js**
项目根组件
## store/index.js
store模块入口
**Meta**
- **copyright**: src/store/index.js
- **author**: codingplayboy
## makeRootSaga
- **See: src/store/index.js**
fork所有saga分支
**Parameters**
- `sagas` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** saga数组
## injectSagas
- **See: src/store/index.js**
插入异步saga,更新store中fork的saga
**Parameters**
- `store` **any**
- `param` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `param.key`
- `param.sagas`
## location.js
封装更新路由的actionCreators
**Meta**
- **copyright**: src/store/location.js
- **author**: codingplayboy
## pushRoute
- **See: src/store/location.js**
使用histytory.push方式更新路由
**Parameters**
- `payload` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** route pathname
## replaceRoute
- **See: src/store/location.js**
使用histytory.preplace方式更新路由
**Parameters**
- `payload` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** route pathname
## CreateStotre.js
创建redux store
**Meta**
- **copyright**: src/store/CreateStore.js 2017/12/19
- **author**: codingplayboy
## OperateReducer.js
处理Reducers方法
**Meta**
- **copyright**: src/store/OperateReducer.js 2017/12/19
- **author**: codingplayboy
## makeRootReducer
- **See: src/store/OperateReducer.js**
创建根Reducer
**Parameters**
- `reducers`
- `asyncReducers` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** reducers
## injectReducer
- **See: src/store/OperateReducer.js**
插入异步Reducers
**Parameters**
- `store` **any** redux store
- `$1` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `$1.key`
- `$1.reducer`
## 路由入口文件
应用路由入口文件
**Meta**
- **copyright**: src/routes/index.js 2017/12/14
- **author**: codingplayboy
## Routes
**Extends Component**
- **See: src/routes/index.js**
应用路由组件
## 首页主体路由文件
应用首页模块
**Meta**
- **copyright**: src/routes/Home/index.js 2017/12/19
- **author**: codingplayboy
## Home
**Extends Component**
- **See: src/routes/Home/index.js**
首页主体容器组件
## React
/about
**Meta**
- **author**: codingplayboy
## Article/index.js
文章正文路由文件
**Meta**
- **copyright**: src/routes/Article/index.js
- **author**: codingplayboy
## ArticleContainer
**Extends Component**
- **See: src/routes/Article/index.js**
文章正文容器组件
## Component
- **See: src/routes/Category/index.js**
分类页面
**Meta**
- **author**: codingplayboy
## AppFlux.js
应用初始化时期望处理的异步请求管理Sagas模块
**Meta**
- **copyright**: src/store/appFlux.js 2017/12/23
- **author**: codingplayboy
## toggleMobileSideBar
- **See: src/store/appFlux.js**
切换顶部/左部导航栏ActionCreator
**Parameters**
- `payload` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** 负载参数 (optional, default `{}`)
Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** [action] action object
## requestPostList
- **See: src/store/appFlux.js**
请求文章列表ActionCreator
**Parameters**
- `payload` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 请求文章列表参数负载
Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** [action] action object
## receivePostList
- **See: src/store/appFlux.js**
接收文章列表ActionCreator
**Parameters**
- `payload` **any** 接收文章列表数据负载
Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** [action] action object
## appReducer
- **See: src/store/appFlux.js**
应用初始reducer
**Parameters**
- `state` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 应用状态树节点状态对象 (optional, default `initialState`)
- `action` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** action object
Returns **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** state 应用新状态对象
## getPostList
- **See: src/store/appFlux.js**
请求文章列表方法
**Parameters**
- `params` **any** 请求参数
eg: {
page: Num,
per_page: Num
} (optional, default `{page:1,per_page:10}`)
## getPostList
fetch请求分类文章列表
**Parameters**
- `params` **any**
- `params.data`
## getPostListSaga
- **See: src/store/appFlux.js**
处理请求文章列表Saga
**Parameters**
- `payload` **any** 请求参数负载
- `payload.payload`
## getPostListSaga
- **See: src/containers/CategoryList/flux.js**
定义请求分类文章列表Saga
**Parameters**
- `param` **any**
- `param.payload`
## AppSaga
- **See: src/store/appFlux.js**
定义AppSaga
**Parameters**
- `action`
## dataAdapter.js
数据适配功能文件
**Meta**
- **copyright**: src/store/dataAdapter.js 2017/12/28
- **author**: codingplayboy
## formatPostListData
- **See: src/store/dataAdapter.js**
适配PostList数组
**Parameters**
- `data` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** postList
Returns **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** new list of post
## flux.js
正文页flux文件
**Meta**
- **copyright**: src/routes/Article/flux.js 2017/01/12
- **author**: codingplayboy
## articleReducer
- **See: src/routes/Article/flux.js**
Article Reducer
**Parameters**
- `state` **any** store状态节点 (optional, default `initialState`)
- `action` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** action对象 (optional, default `{}`)
## formatPostData
- **See: see src/routes/Article/flux.js**
格式化文章信息DataAdapter
**Parameters**
- `post` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** post文章信息对象 (optional, default `{}`)
## getPostSaga
- **See: src/routes/Article/flux.js**
处理请求文章列表Saga
**Parameters**
- `$0` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `$0.payload`
## ArticleSaga
- **See: src/routes/Article/flux.js**
定义ArticleSaga
**Parameters**
- `action`
## SET_WILL_AUTO_FETCH_POSTS
首页组件相关action, reducer, saga
Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
**Meta**
- **author**: codingplayboy
## takeLatest
- **See: src/routes/Category/flux.js**
分类模块flux
**Meta**
- **author**: codingplayboy
## CategoryListSaga
- **See: src/store/appFlux.js**
定义TagListSaga
**Parameters**
- `action`