import React, { Component } from 'react' import PropTypes from 'prop-types'; import { connect } from 'react-redux' import {navitateTo,changeContextMenu,navitateUp} from "../../actions/index" import ObjectIcon from "./ObjectIcon" import ContextMenu from "./ContextMenu" import Table from '@material-ui/core/Table'; import TableBody from '@material-ui/core/TableBody'; import TableCell from '@material-ui/core/TableCell'; import TableHead from '@material-ui/core/TableHead'; import TableRow from '@material-ui/core/TableRow'; import { withStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; import Grid from '@material-ui/core/Grid'; import CircularProgress from '@material-ui/core/CircularProgress'; import Paper from '@material-ui/core/Paper' import EmptyIcon from "@material-ui/icons/Unarchive" import SadIcon from "@material-ui/icons/SentimentVeryDissatisfied" import classNames from 'classnames'; import ImgPreivew from "./ImgPreview" import Button from '@material-ui/core/Button'; import UpIcon from '@material-ui/icons/ArrowUpward' const styles = theme => ({ paper: { padding: theme.spacing.unit * 2, textAlign: 'center', color: theme.palette.text.secondary, margin:"10px", }, root: { flexGrow: 1, padding:"10px", overflowY: "auto", height: "calc(100vh - 112px)", [theme.breakpoints.up('sm')]: { overflowY: "auto", height: "calc(100vh - 112px)", }, [theme.breakpoints.down('sm')]: { height: "100%", }, }, rootTable:{ padding:"0px", backgroundColor:theme.palette.background.paper.white, [theme.breakpoints.up('sm')]: { overflowY: "auto", height: "calc(100vh - 112px)", }, [theme.breakpoints.down('sm')]: { height: "100%", }, }, typeHeader:{ margin: "10px 25px", color: "#6b6b6b", fontWeight: "500", }, loading:{ justifyContent: "center", display: "flex", marginTop:"40px", }, errorBox:{ padding: theme.spacing.unit * 4, }, errorMsg:{ marginTop:"10px", }, emptyContainer:{ bottom: "0", height: "300px", margin: "50px auto", width: "300px", color: theme.palette.explorer.emptyIcon, textAlign: "center", paddingTop: "20px", }, emptyIcon:{ fontSize: "160px", }, emptyInfoBig:{ fontSize: "25px", color:theme.palette.text.disabled, }, emptyInfoSmall:{ color:theme.palette.text.hint, }, hideAuto:{ [theme.breakpoints.down('sm')]: { display:"none", } }, flexFix:{ minWidth: 0, }, upButton:{ marginLeft: "20px", marginTop: "10px", marginBottom: "10px", } }) const mapStateToProps = state => { return { path: state.navigator.path, drawerDesktopOpen:state.viewUpdate.open, viewMethod:state.viewUpdate.explorerViewMethod, sortMethod:state.viewUpdate.sortMethod, fileList:state.explorer.fileList, dirList:state.explorer.dirList, loading:state.viewUpdate.navigatorLoading, navigatorError:state.viewUpdate.navigatorError, navigatorErrorMsg:state.viewUpdate.navigatorErrorMsg, keywords:state.explorer.keywords, } } const mapDispatchToProps = dispatch => { return { navigateToPath: path => { dispatch(navitateTo(path)) }, changeContextMenu: (type,open) => { dispatch(changeContextMenu(type,open)) }, navitateUp:()=>{ dispatch(navitateUp()) } } } class ExplorerCompoment extends Component { contextMenu = (e) => { e.preventDefault(); if(this.props.keywords===null&&!window.isSharePage){ if(!this.props.loading){ this.props.changeContextMenu("empty",true); } } } render() { const { classes} = this.props; return (
{this.props.navigatorError&& :( 请求时出现错误 {this.props.navigatorErrorMsg.message} } {(this.props.loading && !this.props.navigatorError) &&
} {(window.isMobile&&this.props.path!=="/"&&!this.props.loading)&& } {(this.props.keywords===null&&window.isHomePage&&this.props.dirList.length===0&&this.props.fileList.length===0&&!this.props.loading&&!this.props.navigatorError)&&
拖拽文件至此
或点击左侧“上传文件”按钮添加文件
} {((this.props.keywords!==null&&this.props.dirList.length===0&&this.props.fileList.length===0&&!this.props.loading&&!this.props.navigatorError)||(this.props.dirList.length===0&&this.props.fileList.length===0&&!this.props.loading&&!this.props.navigatorError&&window.isSharePage))&&
什么都没有找到
} {(this.props.viewMethod!=="list" &&(this.props.dirList.length!==0||this.props.fileList.length!==0)&&!this.props.loading)&&
{(this.props.dirList.length!==0 && !this.props.loading)&&
文件夹 {this.props.dirList.map((value,index)=>( ))}
} {(this.props.fileList.length!==0 && !this.props.loading)&&
文件 {this.props.fileList.map((value,index)=>( ))}
}
} {(this.props.viewMethod==="list" &&(this.props.dirList.length!==0 || this.props.fileList.length!==0)&&!this.props.loading)&& 名称 大小 日期 {this.props.dirList.map((value,index)=>( ))} {this.props.fileList.map((value,index)=>( ))}
}
); } } ExplorerCompoment.propTypes = { classes: PropTypes.object.isRequired, path:PropTypes.string.isRequired, }; const Explorer = connect( mapStateToProps, mapDispatchToProps )( withStyles(styles)(ExplorerCompoment)) export default Explorer