mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
fix: 消息页修改为日志也
This commit is contained in:
parent
5029e1199c
commit
d6f0c102ae
@ -3,57 +3,47 @@ import {
|
|||||||
FETCH_MORE_NEWS
|
FETCH_MORE_NEWS
|
||||||
} from '../constants/action-types.js';
|
} from '../constants/action-types.js';
|
||||||
|
|
||||||
export function fetchNewsData () {
|
export function fetchNewsData (logId) {
|
||||||
const data = [
|
const data = {
|
||||||
{ key: 1, type: 'John Brown', news: '您好!亲爱的用户:您已成功申请接口:实时空气质量数据查询,请于两个月内进行应用验证,逾期接口将不能正常使用。如果您在使用的过程中遇到任何问题,欢迎前往交流社区反馈意见,谢谢!',time: '2014-12-01' },
|
newsList:[
|
||||||
{ key: 2, type: 'John Brown', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
{ key: 1,title: '日志标题', username: 'John Brown', content: '您好!亲爱的用户:您已成功申请接口:实时空气质量数据查询,请于两个月内进行应用验证,逾期接口将不能正常使用。如果您在使用的过程中遇到任何问题,欢迎前往交流社区反馈意见,谢谢!',time: '2014-12-01' },
|
||||||
{ key: 3, type: 'John Brown', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }
|
{ key: 2,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
||||||
];
|
{ key: 3,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }
|
||||||
|
],
|
||||||
|
totalPage: 34
|
||||||
|
};
|
||||||
|
console.log(logId);
|
||||||
return {
|
return {
|
||||||
type: FETCH_NEWS_DATA,
|
type: FETCH_NEWS_DATA,
|
||||||
payload: data
|
payload: new Promise(function(reslove,reject){
|
||||||
|
if(data){
|
||||||
|
reslove(data);
|
||||||
|
}else{
|
||||||
|
reject("chucuole");
|
||||||
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchViewedNews () {
|
export function fetchMoreNews (current,pageSize) {
|
||||||
const data = [
|
// id,type,news,time,totalPage
|
||||||
{ key: 1, type: 'John Brown1', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
const newsList = [
|
||||||
{ key: 2, type: 'John Brown2', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
{ key: 1,title: '日志标题1', username: 'John Brown', content: '您好!亲爱的用户:您已成功申请接口:实时空气质量数据查询,请于两个月内进行应用验证,逾期接口将不能正常使用。如果您在使用的过程中遇到任何问题,欢迎前往交流社区反馈意见,谢谢!',time: '2014-12-01' },
|
||||||
{ key: 3, type: 'John Brown3å', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }
|
{ key: 2,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
||||||
];
|
{ key: 3,title: '日志标题', username: 'John Brown', content: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }
|
||||||
|
]
|
||||||
return {
|
console.log(current,pageSize);
|
||||||
type: FETCH_NEWS_DATA,
|
return ({
|
||||||
payload: data
|
type: FETCH_MORE_NEWS,
|
||||||
}
|
payload: new Promise(function(resolve,reject){
|
||||||
}
|
if(newsList){
|
||||||
|
resolve(newsList);
|
||||||
export function fetchNotVieweNews () {
|
}else{
|
||||||
const data = [
|
reject("出现了错误");
|
||||||
{ key: 1, type: 'John Brown', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2015-11-11 13:00:15' },
|
}
|
||||||
{ key: 2, type: 'John Brown', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2015-11-11 13:00:15' },
|
|
||||||
{ key: 3, type: 'John Brown', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2015-11-11 13:00:15' }
|
|
||||||
];
|
|
||||||
|
|
||||||
return {
|
|
||||||
type: FETCH_NEWS_DATA,
|
|
||||||
payload: data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchMoreNews () {
|
|
||||||
return (dispatch)=>{
|
|
||||||
const data = [
|
|
||||||
{ key: 1, type: 'John Brown', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
|
||||||
{ key: 2, type: 'John Brown', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' },
|
|
||||||
{ key: 3, type: 'John Brown', news: 'My name is John Brown, I am 32 years old, living in New York No. 1 Lake Park.',time: '2014-12-01' }
|
|
||||||
];
|
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: FETCH_MORE_NEWS,
|
|
||||||
payload: data
|
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import NewsTimeline from './NewsTimeline/NewsTimeline'
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import NewsList from './NewsList/NewsList.js'
|
import NewsList from './NewsList/NewsList.js'
|
||||||
import { fetchNotVieweNews } from '../../actions/news.js'
|
import { fetchNewsData } from '../../actions/news.js'
|
||||||
|
|
||||||
|
|
||||||
@connect(
|
@connect(
|
||||||
@ -14,27 +14,35 @@ import { fetchNotVieweNews } from '../../actions/news.js'
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fetchNotVieweNews: fetchNotVieweNews
|
fetchNewsData: fetchNewsData
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
class News extends Component {
|
class News extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
this.state = {
|
||||||
|
loading: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
newsData: PropTypes.array,
|
newsData: PropTypes.object,
|
||||||
fetchNotVieweNews: PropTypes.func
|
fetchNewsData: PropTypes.func
|
||||||
|
}
|
||||||
|
setLoading(bool){
|
||||||
|
this.setState({
|
||||||
|
loading: bool
|
||||||
|
})
|
||||||
}
|
}
|
||||||
componentWillMount(){
|
componentWillMount(){
|
||||||
this.props.fetchNotVieweNews()
|
this.props.fetchNewsData()
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const data = this.props.newsData
|
const data = this.props.newsData
|
||||||
return (
|
return (
|
||||||
<section className="news-box">
|
<section className="news-box">
|
||||||
<NewsList />
|
<NewsList loading={this.state.loading} setLoading={this.setLoading.bind(this)} />
|
||||||
<NewsTimeline newsData = {data} />
|
<NewsTimeline loading={this.state.loading} setLoading={this.setLoading.bind(this)} newsData = {data} />
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7,20 +7,12 @@
|
|||||||
font-size: 0.14rem;
|
font-size: 0.14rem;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
|
|
||||||
.news-list {
|
.logList {
|
||||||
width: 216px;
|
width: 216px;
|
||||||
line-height: 45px;
|
line-height: 45px;
|
||||||
background: #f9fafe;
|
background: #f9fafe;
|
||||||
|
h3{
|
||||||
li {
|
text-indent: 1em;
|
||||||
padding: 0 0 0 30px;
|
|
||||||
color: #344562;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover, &.active {
|
|
||||||
background: #657289;
|
|
||||||
color: #FFF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
import { Menu } from 'antd'
|
||||||
import {
|
import {
|
||||||
fetchNewsData,
|
fetchNewsData
|
||||||
fetchViewedNews,
|
} from '../../../actions/news.js'
|
||||||
fetchNotVieweNews } from '../../../actions/news.js'
|
|
||||||
|
|
||||||
|
|
||||||
|
const logList = [{
|
||||||
|
name: '用户'
|
||||||
|
},{
|
||||||
|
name: '分组'
|
||||||
|
},{
|
||||||
|
name: '接口'
|
||||||
|
},{
|
||||||
|
name: '项目'
|
||||||
|
}];
|
||||||
@connect(
|
@connect(
|
||||||
state => {
|
state => {
|
||||||
return {
|
return {
|
||||||
@ -14,9 +23,7 @@ import {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fetchNewsData,
|
fetchNewsData
|
||||||
fetchViewedNews,
|
|
||||||
fetchNotVieweNews
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,52 +31,46 @@ class NewsList extends Component {
|
|||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
fetchNewsData: PropTypes.func,
|
fetchNewsData: PropTypes.func,
|
||||||
fetchViewedNews: PropTypes.func,
|
setLoading: PropTypes.func
|
||||||
fetchNotVieweNews: PropTypes.func
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
}
|
this.state = {
|
||||||
|
selectedKeys: 0
|
||||||
|
|
||||||
|
|
||||||
fetchData(e){
|
|
||||||
const mark = e.target.className;
|
|
||||||
if(mark.indexOf('allnews')>-1){
|
|
||||||
this.props.fetchNewsData()
|
|
||||||
this.switchColor(mark.indexOf('allnews'),e.target)
|
|
||||||
}else if(mark.indexOf('viewednews')>-1){
|
|
||||||
this.props.fetchViewedNews();
|
|
||||||
this.switchColor(mark.indexOf('viewednews'),e.target)
|
|
||||||
}else if(mark.indexOf('notview')>-1){
|
|
||||||
this.props.fetchNotVieweNews();
|
|
||||||
this.switchColor(mark.indexOf('notview'),e.target)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
switchColor(index,e){
|
getLogData(e){
|
||||||
let childNodes = e.parentNode.childNodes;
|
// page,size,logId
|
||||||
if(e.className.indexOf('active')> -1) return;
|
// console.log(e.key);
|
||||||
for(let j = 0;j<childNodes.length;j++){
|
this.setState({
|
||||||
const i = childNodes[j].className.indexOf('active');
|
selectedKeys: +e.key
|
||||||
if(i> -1){
|
})
|
||||||
// console.log( childNodes[i].className.splice);
|
const that = this;
|
||||||
let className = childNodes[j].className;
|
this.props.setLoading(true);
|
||||||
className = className.split('');
|
this.props.fetchNewsData(+e.key).then(function(){
|
||||||
className.splice(i,6);
|
that.props.setLoading(false);
|
||||||
childNodes[j].className = className.join('');
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
e.className = e.className + ' active';
|
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<ul onClick = {this.fetchData.bind(this)} className="news-list">
|
<div className='logList'>
|
||||||
{/*<li className="allnews">全部消息</li>*/}
|
<h3>日志类型</h3>
|
||||||
<li className='active notview'>未读消息</li>
|
<Menu
|
||||||
<li className='viewednews'>已读消息</li>
|
mode='inline'
|
||||||
</ul>
|
selectedKeys = {[`${this.state.selectedKeys}`]}
|
||||||
|
onClick = {this.getLogData.bind(this)}
|
||||||
|
>
|
||||||
|
{logList.map((item,i)=>{
|
||||||
|
return (
|
||||||
|
<Menu.Item key={i} className="log-item">
|
||||||
|
{item.name}
|
||||||
|
</Menu.Item>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { Table, Icon, Popconfirm } from 'antd'
|
import { Table, Popconfirm } from 'antd'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { fetchMoreNews } from '../../../actions/news.js'
|
import { fetchMoreNews } from '../../../actions/news.js'
|
||||||
@ -20,25 +20,39 @@ const removeConfirm = function(e){
|
|||||||
|
|
||||||
class NewsTimeline extends Component {
|
class NewsTimeline extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
newsData: PropTypes.array,
|
newsData: PropTypes.object,
|
||||||
fetchMoreNews: PropTypes.func
|
fetchMoreNews: PropTypes.func,
|
||||||
|
setLoading: PropTypes.func,
|
||||||
|
loading: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
pagination: {
|
||||||
|
pageSize: 10,
|
||||||
|
total: 34
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
removeOneNews(id){
|
|
||||||
return ()=>{
|
handleChange(pagination){
|
||||||
console.log(id);
|
const pager = { ...this.state.pagination };
|
||||||
}
|
pager.current = pagination.current;
|
||||||
|
this.props.setLoading(true);
|
||||||
|
const that = this;
|
||||||
|
this.props.fetchMoreNews(pagination.current,pagination.pageSize).then(function(){
|
||||||
|
that.props.setLoading(false);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const columns = [
|
const columns = [
|
||||||
{ title: '类型',width:100, dataIndex: 'type', key: 'type' },
|
{ title: '操作用户',width:100, dataIndex: 'username', key: 'username' },
|
||||||
{ title: '消息', dataIndex: 'news', key: 'news' },
|
{ title: '日志标题',width: 200, dataIndex: 'title', key: 'title' },
|
||||||
{ title: '发布时间',width:150, dataIndex: 'time', key: 'time' }
|
{ title: '具体改动描述', dataIndex: 'content', key: 'content' },
|
||||||
|
{ title: '时间',width: 150, dataIndex: 'time', key: 'time' }
|
||||||
];
|
];
|
||||||
const data = this.props.newsData;
|
const data = this.props.newsData.newsList;
|
||||||
return (
|
return (
|
||||||
<section className="news-timeline">
|
<section className="news-timeline">
|
||||||
<span className='removeAllNews'>
|
<span className='removeAllNews'>
|
||||||
@ -47,9 +61,12 @@ class NewsTimeline extends Component {
|
|||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
</span>
|
</span>
|
||||||
<Table
|
<Table
|
||||||
|
loading={this.props.loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
expandedRowRender={record => <div className='newsDesc'><p>{record.news}</p><span onClick = {this.removeOneNews(record.key)} ><Icon type="delete" />删除</span></div>}
|
expandedRowRender={record => <div className='newsDesc'><p>{record.content}</p></div>}
|
||||||
dataSource={data}
|
dataSource={data}
|
||||||
|
pagination={{...this.state.pagination,total:this.props.newsData.totalPage}}
|
||||||
|
onChange={this.handleChange.bind(this)}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
@ -4,22 +4,24 @@ import {
|
|||||||
} from '../../constants/action-types.js'
|
} from '../../constants/action-types.js'
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
newsData: []
|
newsData: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (state = initialState, action) => {
|
export default (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case FETCH_NEWS_DATA: {
|
case FETCH_NEWS_DATA: {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
newsData: action.payload
|
newsData: action.payload
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case FETCH_MORE_NEWS: {
|
case FETCH_MORE_NEWS: {
|
||||||
state.newsData.push(...action.payload);
|
// console.log(action.payload);
|
||||||
return {
|
return {
|
||||||
...state
|
newsData: {
|
||||||
|
...state.newsData,
|
||||||
|
newsList: action.payload
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user