mirror of
https://github.com/cloudreve/frontend.git
synced 2025-12-30 00:22:49 +00:00
文件分类过滤/搜索 修复搜索文件后仍可拖拽上传
This commit is contained in:
parent
3f5c826c06
commit
8a860b625c
|
|
@ -6,7 +6,7 @@ import SpeedDialAction from "@material-ui/lab/SpeedDialAction";
|
|||
import CreateNewFolderIcon from "@material-ui/icons/CreateNewFolder";
|
||||
import PublishIcon from "@material-ui/icons/Publish";
|
||||
import {openCreateFolderDialog, openRemoteDownloadDialog, toggleSnackbar} from "../../actions";
|
||||
import { useDispatch } from "react-redux";
|
||||
import {useDispatch, useSelector} from "react-redux";
|
||||
import AutoHidden from "./AutoHidden";
|
||||
import statusHelper from "../../untils/page"
|
||||
import Backdrop from "@material-ui/core/Backdrop";
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { baseURL } from "../../middleware/Api";
|
|||
import { showImgPreivew } from "../../actions/index";
|
||||
import { imgPreviewSuffix } from "../../config";
|
||||
import { withStyles } from "@material-ui/core";
|
||||
import "react-image-lightbox/style.css";
|
||||
import pathHelper from "../../untils/page";
|
||||
import {withRouter} from "react-router";
|
||||
import {PhotoSlider} from "react-photo-view";
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ class NavbarCompoment extends Component {
|
|||
};
|
||||
|
||||
filterFile = type => {
|
||||
this.props.searchMyFile("{filterType:" + type + "}");
|
||||
this.props.searchMyFile(type+"/internal");
|
||||
};
|
||||
|
||||
openPreview = () => {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ import {
|
|||
} from "@material-ui/core";
|
||||
import {withRouter} from "react-router";
|
||||
import pathHelper from "../../untils/page";
|
||||
import {HotKeys,configure} from "react-hotkeys";
|
||||
|
||||
configure({
|
||||
ignoreTags:[],
|
||||
});
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {};
|
||||
|
|
@ -85,10 +90,29 @@ const styles = theme => ({
|
|||
}
|
||||
});
|
||||
|
||||
const keyMap = {
|
||||
SEARCH: "enter",
|
||||
};
|
||||
|
||||
class SearchBarCompoment extends Component {
|
||||
state = {
|
||||
anchorEl: null,
|
||||
input: ""
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
anchorEl: null,
|
||||
input: ""
|
||||
};
|
||||
}
|
||||
|
||||
handlers={
|
||||
SEARCH:(e)=>{
|
||||
if(pathHelper.isHomePage(this.props.location.pathname)){
|
||||
this.searchMyFile();
|
||||
}else{
|
||||
this.searchShare();
|
||||
}
|
||||
e.target.blur();
|
||||
},
|
||||
};
|
||||
|
||||
handleChange = event => {
|
||||
|
|
@ -114,6 +138,7 @@ class SearchBarCompoment extends Component {
|
|||
window.location.href = "/Explore/Search/" + this.input;
|
||||
};
|
||||
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
const { anchorEl } = this.state;
|
||||
|
|
@ -121,20 +146,22 @@ class SearchBarCompoment extends Component {
|
|||
const isHomePage = pathHelper.isHomePage(this.props.location.pathname);
|
||||
|
||||
return (
|
||||
<div className={classes.search}>
|
||||
<div className={classes.search}>
|
||||
<div className={classes.searchIcon}>
|
||||
<SearchIcon />
|
||||
</div>
|
||||
<InputBase
|
||||
placeholder="搜索..."
|
||||
classes={{
|
||||
root: classes.inputRoot,
|
||||
input: classes.inputInput
|
||||
}}
|
||||
onChange={this.handleChange}
|
||||
onBlur={this.cancelSuggest}
|
||||
value={this.state.input}
|
||||
/>
|
||||
<HotKeys keyMap={keyMap} handlers={this.handlers}>
|
||||
<InputBase
|
||||
placeholder="搜索..."
|
||||
classes={{
|
||||
root: classes.inputRoot,
|
||||
input: classes.inputInput
|
||||
}}
|
||||
onChange={this.handleChange}
|
||||
onBlur={this.cancelSuggest}
|
||||
value={this.state.input}
|
||||
/>
|
||||
</HotKeys>
|
||||
<Popper
|
||||
id={id}
|
||||
open={this.state.input !== ""}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
import React, { Component } from "react";
|
||||
import uploaderLoader from "../../loader";
|
||||
import { connect } from "react-redux";
|
||||
import {refreshFileList, refreshStorage, toggleSnackbar} from "../../actions";
|
||||
import { refreshFileList, refreshStorage, toggleSnackbar } from "../../actions";
|
||||
import FileList from "./FileList.js";
|
||||
import Auth from "../../middleware/Auth"
|
||||
import UploadButton from "../Dial/Create.js"
|
||||
import {withRouter} from "react-router";
|
||||
import Auth from "../../middleware/Auth";
|
||||
import UploadButton from "../Dial/Create.js";
|
||||
import { withRouter } from "react-router";
|
||||
import pathHelper from "../../untils/page";
|
||||
|
||||
let loaded = false;
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
path: state.navigator.path
|
||||
path: state.navigator.path,
|
||||
keywords: state.explorer.keywords
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
refreshFileList: () => {
|
||||
|
|
@ -26,7 +27,7 @@ const mapDispatchToProps = dispatch => {
|
|||
},
|
||||
toggleSnackbar: (vertical, horizontal, msg, color) => {
|
||||
dispatch(toggleSnackbar(vertical, horizontal, msg, color));
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -46,24 +47,30 @@ class UploaderComponent extends Component {
|
|||
this.uploader.removeFile(file);
|
||||
}
|
||||
|
||||
getChunkSize(policyType){
|
||||
if(policyType === "qiniu"){
|
||||
return 4*1024*1024
|
||||
getChunkSize(policyType) {
|
||||
if (policyType === "qiniu") {
|
||||
return 4 * 1024 * 1024;
|
||||
}
|
||||
if(policyType === "onedrive"){
|
||||
return 10*1024*1024
|
||||
if (policyType === "onedrive") {
|
||||
return 10 * 1024 * 1024;
|
||||
}
|
||||
return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
fileAdd = (up,files)=>{
|
||||
if(window.location.href.split("#")[1].toLowerCase().startsWith("/home")){
|
||||
fileAdd = (up, files) => {
|
||||
if (
|
||||
this.props.keywords === null &&
|
||||
window.location.href
|
||||
.split("#")[1]
|
||||
.toLowerCase()
|
||||
.startsWith("/home")
|
||||
) {
|
||||
window.fileList["openFileList"]();
|
||||
window.plupload.each(files, files => {
|
||||
window.pathCache[files.id] = this.props.path;
|
||||
window.fileList["enQueue"](files);
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
window.plupload.each(files, files => {
|
||||
up.removeFile(files);
|
||||
});
|
||||
|
|
@ -88,14 +95,17 @@ class UploaderComponent extends Component {
|
|||
dragdrop: true,
|
||||
chunk_size: this.getChunkSize(user.policy.saveType),
|
||||
filters: {
|
||||
mime_types: user.policy.allowedType === null ? [] : user.policy.allowedType,
|
||||
mime_types:
|
||||
user.policy.allowedType === null
|
||||
? []
|
||||
: user.policy.allowedType
|
||||
},
|
||||
// iOS不能多选?
|
||||
multi_selection: true,
|
||||
uptoken_url: "/api/v3/file/upload/credential",
|
||||
uptoken:user.policy.saveType === "local" ? "token" : null,
|
||||
uptoken: user.policy.saveType === "local" ? "token" : null,
|
||||
domain: "s",
|
||||
max_retries:0,
|
||||
max_retries: 0,
|
||||
get_new_uptoken: true,
|
||||
auto_start: true,
|
||||
log_level: 5,
|
||||
|
|
@ -113,20 +123,26 @@ class UploaderComponent extends Component {
|
|||
if (file.length === 0) {
|
||||
return;
|
||||
}
|
||||
console.log("UploadComplete",file[0].status,file[0]);
|
||||
console.log(
|
||||
"UploadComplete",
|
||||
file[0].status,
|
||||
file[0]
|
||||
);
|
||||
for (var i = 0; i < file.length; i++) {
|
||||
if (file[i].status === 5) {
|
||||
window.fileList["setComplete"](file[i]);
|
||||
}
|
||||
}
|
||||
// 无异步操作的策略,直接刷新
|
||||
if (user.policy.saveType !== "onedrive" && user.policy.saveType !== "cos"){
|
||||
if (
|
||||
user.policy.saveType !== "onedrive" &&
|
||||
user.policy.saveType !== "cos"
|
||||
) {
|
||||
this.props.refreshFileList();
|
||||
this.props.refreshStorage();
|
||||
}
|
||||
|
||||
},
|
||||
Fresh:()=>{
|
||||
Fresh: () => {
|
||||
this.props.refreshFileList();
|
||||
this.props.refreshStorage();
|
||||
},
|
||||
|
|
@ -156,7 +172,10 @@ class UploaderComponent extends Component {
|
|||
inRef={this.setRef.bind(this)}
|
||||
cancelUpload={this.cancelUpload.bind(this)}
|
||||
/>
|
||||
<UploadButton Queued={this.state.queued} openFileList={this.openFileList} />
|
||||
{this.props.keywords === null &&<UploadButton
|
||||
Queued={this.state.queued}
|
||||
openFileList={this.openFileList}
|
||||
/>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -164,8 +183,6 @@ class UploaderComponent extends Component {
|
|||
|
||||
const Uploader = connect(mapStateToProps, mapDispatchToProps, null, {
|
||||
forwardRef: true
|
||||
})(
|
||||
uploaderLoader()(UploaderComponent)
|
||||
);
|
||||
})(uploaderLoader()(UploaderComponent));
|
||||
|
||||
export default Uploader;
|
||||
|
|
|
|||
Loading…
Reference in New Issue