mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 21:30:39 +00:00
Large catalog optimization
This commit is contained in:
@@ -29,6 +29,7 @@ const propTypes = {
|
|||||||
showShareBtn: PropTypes.bool.isRequired,
|
showShareBtn: PropTypes.bool.isRequired,
|
||||||
showDirentDetail: PropTypes.func.isRequired,
|
showDirentDetail: PropTypes.func.isRequired,
|
||||||
onAddFolder: PropTypes.func.isRequired,
|
onAddFolder: PropTypes.func.isRequired,
|
||||||
|
onFileTagChanged: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
class DirGridView extends React.Component {
|
class DirGridView extends React.Component {
|
||||||
@@ -53,6 +54,7 @@ class DirGridView extends React.Component {
|
|||||||
draftCounts={this.props.draftCounts}
|
draftCounts={this.props.draftCounts}
|
||||||
usedRepoTags={this.props.usedRepoTags}
|
usedRepoTags={this.props.usedRepoTags}
|
||||||
updateUsedRepoTags={this.props.updateUsedRepoTags}
|
updateUsedRepoTags={this.props.updateUsedRepoTags}
|
||||||
|
onFileTagChanged={this.props.onFileTagChanged}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<DirentGridView
|
<DirentGridView
|
||||||
|
@@ -61,10 +61,27 @@ class DirentGridView extends React.Component{
|
|||||||
isMutipleOperation: false,
|
isMutipleOperation: false,
|
||||||
isGridItemFreezed: false,
|
isGridItemFreezed: false,
|
||||||
activeDirent: null,
|
activeDirent: null,
|
||||||
|
direntItemsList: [],
|
||||||
|
itemIdex: 100,
|
||||||
}
|
}
|
||||||
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
|
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
window.addEventListener('scroll', this.handleScroll, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
let direntItemsList = nextProps.direntList.filter((item, index) => {
|
||||||
|
return index < 100
|
||||||
|
})
|
||||||
|
this.setState({direntItemsList: direntItemsList, itemIdex: 100,})
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
window.removeEventListener('scroll', this.handleScroll, true);
|
||||||
|
}
|
||||||
|
|
||||||
onCreateFileToggle = () => {
|
onCreateFileToggle = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
isCreateFileDialogShow: !this.state.isCreateFileDialogShow,
|
isCreateFileDialogShow: !this.state.isCreateFileDialogShow,
|
||||||
@@ -76,6 +93,22 @@ class DirentGridView extends React.Component{
|
|||||||
this.props.onGridItemClick(dirent);
|
this.props.onGridItemClick(dirent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleScroll = (e) => {
|
||||||
|
let target = e.target;
|
||||||
|
let itemIdex = this.state.itemIdex;
|
||||||
|
|
||||||
|
const { direntList } = this.props;
|
||||||
|
|
||||||
|
|
||||||
|
if (target.scrollTop + document.documentElement.clientHeight - target.offsetTop >= target.scrollHeight) {
|
||||||
|
itemIdex += 100;
|
||||||
|
let direntItemsList = direntList.filter((item, index) => {
|
||||||
|
return index < itemIdex
|
||||||
|
})
|
||||||
|
this.setState({direntItemsList: direntItemsList, itemIdex: itemIdex})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMoveToggle = () => {
|
onMoveToggle = () => {
|
||||||
this.setState({isMoveDialogShow: !this.state.isMoveDialogShow});
|
this.setState({isMoveDialogShow: !this.state.isMoveDialogShow});
|
||||||
}
|
}
|
||||||
@@ -477,15 +510,21 @@ class DirentGridView extends React.Component{
|
|||||||
let dirent = this.state.activeDirent ? this.state.activeDirent : '';
|
let dirent = this.state.activeDirent ? this.state.activeDirent : '';
|
||||||
let direntPath = Utils.joinPath(path, dirent.name);
|
let direntPath = Utils.joinPath(path, dirent.name);
|
||||||
|
|
||||||
|
let direntItemsList = direntList.filter((item, index) => {
|
||||||
|
return index < 100
|
||||||
|
})
|
||||||
|
|
||||||
|
direntItemsList = this.state.direntItemsList.length === 0 ? direntItemsList : this.state.direntItemsList;
|
||||||
|
|
||||||
if (this.props.isDirentListLoading) {
|
if (this.props.isDirentListLoading) {
|
||||||
return (<Loading />);
|
return (<Loading />);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<ul className="grid-view" onClick={this.gridContainerClick} onContextMenu={this.onGridContainerContextMenu} onMouseDown={this.onGridContainerMouseDown}>
|
<ul className="grid-view" onClick={this.gridContainerClick} onContextMenu={this.onGridContainerContextMenu} onMouseDown={this.onGridContainerMouseDown} onScroll={this.handleScroll}>
|
||||||
{
|
{
|
||||||
direntList.length !== 0 && direntList.map((dirent, index) => {
|
direntList.length !== 0 && direntItemsList.map((dirent, index) => {
|
||||||
return (
|
return (
|
||||||
<DirentGridItem
|
<DirentGridItem
|
||||||
key={index}
|
key={index}
|
||||||
|
@@ -65,6 +65,8 @@ class DirentListView extends React.Component {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
isMutipleOperation: true,
|
isMutipleOperation: true,
|
||||||
activeDirent: null,
|
activeDirent: null,
|
||||||
|
direntItemsList: [],
|
||||||
|
itemIdex: 100,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
|
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
|
||||||
@@ -82,6 +84,22 @@ class DirentListView extends React.Component {
|
|||||||
this.setState({isItemFreezed: true});
|
this.setState({isItemFreezed: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
window.addEventListener('scroll', this.handleScroll, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
let direntItemsList = nextProps.direntList.filter((item, index) => {
|
||||||
|
return index < 100
|
||||||
|
})
|
||||||
|
this.setState({direntItemsList: direntItemsList, itemIdex: 100,})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
window.removeEventListener('scroll', this.handleScroll, true);
|
||||||
|
}
|
||||||
|
|
||||||
unfreezeItem = () => {
|
unfreezeItem = () => {
|
||||||
this.setState({isItemFreezed: false});
|
this.setState({isItemFreezed: false});
|
||||||
}
|
}
|
||||||
@@ -521,9 +539,31 @@ class DirentListView extends React.Component {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleScroll = (e) => {
|
||||||
|
let target = e.target;
|
||||||
|
let itemIdex = this.state.itemIdex;
|
||||||
|
|
||||||
|
const { direntList } = this.props;
|
||||||
|
|
||||||
|
|
||||||
|
if (target.scrollTop + document.documentElement.clientHeight - target.offsetTop >= target.scrollHeight) {
|
||||||
|
itemIdex += 100;
|
||||||
|
let direntItemsList = direntList.filter((item, index) => {
|
||||||
|
return index < itemIdex
|
||||||
|
})
|
||||||
|
this.setState({direntItemsList: direntItemsList, itemIdex: itemIdex})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { direntList, sortBy, sortOrder } = this.props;
|
const { direntList, sortBy, sortOrder } = this.props;
|
||||||
|
|
||||||
|
let direntItemsList = direntList.filter((item, index) => {
|
||||||
|
return index < 100
|
||||||
|
})
|
||||||
|
|
||||||
|
direntItemsList = this.state.direntItemsList.length === 0 ? direntItemsList : this.state.direntItemsList
|
||||||
|
|
||||||
if (this.props.isDirentListLoading) {
|
if (this.props.isDirentListLoading) {
|
||||||
return (<Loading />);
|
return (<Loading />);
|
||||||
}
|
}
|
||||||
@@ -534,7 +574,7 @@ class DirentListView extends React.Component {
|
|||||||
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
|
const sortIcon = sortOrder == 'asc' ? <span className="fas fa-caret-up"></span> : <span className="fas fa-caret-down"></span>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="table-container" onMouseDown={this.onContainerMouseDown} onContextMenu={this.onContainerContextMenu} onClick={this.onContainerClick}>
|
<div className="table-container" ref="table_container" onMouseDown={this.onContainerMouseDown} onContextMenu={this.onContainerContextMenu} onClick={this.onContainerClick} onScroll={this.handleScroll}>
|
||||||
<table>
|
<table>
|
||||||
<thead onMouseDown={this.onThreadMouseDown} onContextMenu={this.onThreadContextMenu}>
|
<thead onMouseDown={this.onThreadMouseDown} onContextMenu={this.onThreadContextMenu}>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -551,7 +591,7 @@ class DirentListView extends React.Component {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{direntList.map((dirent, index) => {
|
{direntItemsList.map((dirent, index) => {
|
||||||
return (
|
return (
|
||||||
<DirentListItem
|
<DirentListItem
|
||||||
ref={this.setDirentItemRef(index)}
|
ref={this.setDirentItemRef(index)}
|
||||||
|
@@ -234,6 +234,7 @@ class LibContentContainer extends React.Component {
|
|||||||
onGridItemClick={this.onGridItemClick}
|
onGridItemClick={this.onGridItemClick}
|
||||||
isDirentDetailShow={this.props.isDirentDetailShow}
|
isDirentDetailShow={this.props.isDirentDetailShow}
|
||||||
onItemRename={this.props.onItemRename}
|
onItemRename={this.props.onItemRename}
|
||||||
|
onFileTagChanged={this.props.onFileTagChanged}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{this.props.currentMode === 'column' && (
|
{this.props.currentMode === 'column' && (
|
||||||
|
Reference in New Issue
Block a user