mirror of
https://github.com/cloudreve/frontend.git
synced 2025-12-25 19:52:48 +00:00
Fix: 上传失败
This commit is contained in:
parent
d7d15b0c9a
commit
78ca29fc73
|
|
@ -29,5 +29,10 @@
|
|||
}else{
|
||||
ChunkSize = 10485760;
|
||||
}
|
||||
isMobile = window.innerWidth < 600;</script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div>
|
||||
isMobile = window.innerWidth < 600;
|
||||
|
||||
// 保留
|
||||
pathCache = {};
|
||||
|
||||
</script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div>
|
||||
</body></html>
|
||||
|
|
|
|||
|
|
@ -1,122 +1,113 @@
|
|||
import React, { Component } from 'react'
|
||||
import scriptLoader from '../loader/index.js'
|
||||
import { connect } from 'react-redux'
|
||||
import {
|
||||
refreshFileList,
|
||||
refreshStorage
|
||||
} from "../actions/index"
|
||||
import FileList from "./Upload/FileList.js"
|
||||
import React, { Component } from "react";
|
||||
import scriptLoader from "../loader/index.js";
|
||||
import { connect } from "react-redux";
|
||||
import { refreshFileList, refreshStorage } from "../actions/index";
|
||||
import FileList from "./Upload/FileList.js";
|
||||
|
||||
let loaded = false;
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
path:state.navigator.path,
|
||||
}
|
||||
}
|
||||
path: state.navigator.path
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
refreshFileList:()=>{
|
||||
dispatch(refreshFileList())
|
||||
refreshFileList: () => {
|
||||
dispatch(refreshFileList());
|
||||
},
|
||||
refreshStorage:()=>{
|
||||
dispatch(refreshStorage())
|
||||
refreshStorage: () => {
|
||||
dispatch(refreshStorage());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class UploaderCompoment extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state={
|
||||
queued:0,
|
||||
}
|
||||
this.state = {
|
||||
queued: 0
|
||||
};
|
||||
}
|
||||
|
||||
setRef(val){
|
||||
this.fileList=val;
|
||||
setRef(val) {
|
||||
this.fileList = val;
|
||||
}
|
||||
|
||||
cancelUpload(file){
|
||||
cancelUpload(file) {
|
||||
this.uploader.removeFile(file);
|
||||
}
|
||||
shouldComponentUpdate(nextProps,nextState){
|
||||
if(nextState.queued !== this.state.queued){
|
||||
this.props.queueChange(nextState.queued);
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
if (nextState.queued !== this.state.queued) {
|
||||
this.props.queueChange(nextState.queued);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
componentWillReceiveProps({ isScriptLoaded, isScriptLoadSucceed }) {
|
||||
if (isScriptLoaded && !this.props.isScriptLoaded) { // load finished
|
||||
if (isScriptLoaded && !this.props.isScriptLoaded) {
|
||||
// load finished
|
||||
if (isScriptLoadSucceed) {
|
||||
if(loaded){
|
||||
if (loaded) {
|
||||
return;
|
||||
}
|
||||
loaded = true;
|
||||
this.uploader = window.Qiniu.uploader({
|
||||
runtimes: 'html5',
|
||||
browse_button: 'pickfiles',
|
||||
container: 'container',
|
||||
drop_element: 'container',
|
||||
runtimes: "html5",
|
||||
browse_button: "pickfiles",
|
||||
container: "container",
|
||||
drop_element: "container",
|
||||
max_file_size: window.uploadConfig.maxSize,
|
||||
dragdrop: true,
|
||||
chunk_size: window.ChunkSize,
|
||||
filters: {
|
||||
mime_types: window.uploadConfig.allowedType,
|
||||
mime_types: window.uploadConfig.allowedType
|
||||
},
|
||||
multi_selection: !(window.moxie.core.utils.Env.OS.toLowerCase() === "ios"),
|
||||
// iOS不能多选?
|
||||
multi_selection: true,
|
||||
uptoken_url: "/Upload/Token",
|
||||
domain: "s",
|
||||
get_new_uptoken: true,
|
||||
auto_start: true,
|
||||
log_level: 5,
|
||||
init: {
|
||||
'FilesAdded':({up, files})=>{
|
||||
FilesAdded: ({ up, files }) => {
|
||||
this.fileList["openFileList"]();
|
||||
window.plupload.each(files, (files)=> {
|
||||
window.plupload.each(files, files => {
|
||||
window.pathCache[files.id] = this.props.path;
|
||||
this.fileList["enQueue"](files);
|
||||
})
|
||||
console.log(window.pathCache);
|
||||
});
|
||||
console.log(window.pathCache);
|
||||
},
|
||||
|
||||
|
||||
'BeforeUpload': function (up, file) {
|
||||
|
||||
BeforeUpload: function(up, file) {},
|
||||
QueueChanged: up => {
|
||||
this.setState({ queued: up.total.queued });
|
||||
},
|
||||
"QueueChanged":(up=>{
|
||||
this.setState({queued:up.total.queued});
|
||||
}),
|
||||
'UploadProgress': (up, file)=>{
|
||||
UploadProgress: (up, file) => {
|
||||
this.fileList["updateStatus"](file);
|
||||
},
|
||||
'UploadComplete': (up, file)=>{
|
||||
if(file.length===0){
|
||||
return
|
||||
UploadComplete: (up, file) => {
|
||||
if (file.length === 0) {
|
||||
return;
|
||||
}
|
||||
if(file[0].status === 5){
|
||||
if (file[0].status === 5) {
|
||||
this.fileList["setComplete"](file[0]);
|
||||
this.props.refreshFileList();
|
||||
this.props.refreshFileList();
|
||||
this.props.refreshStorage();
|
||||
}
|
||||
|
||||
},
|
||||
'FileUploaded': function (up, file, info) {
|
||||
|
||||
},
|
||||
'Error': (up, err, errTip)=>{
|
||||
FileUploaded: function(up, file, info) {},
|
||||
Error: (up, err, errTip) => {
|
||||
this.fileList["openFileList"]();
|
||||
this.fileList["setError"](err.file,errTip);
|
||||
},
|
||||
"FilesRemoved":(up, files)=>{
|
||||
this.fileList["setError"](err.file, errTip);
|
||||
},
|
||||
FilesRemoved: (up, files) => {}
|
||||
}
|
||||
});
|
||||
// this.fileList["openFileList"]();
|
||||
}
|
||||
else this.onError()
|
||||
// this.fileList["openFileList"]();
|
||||
} else this.onError();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,40 +115,37 @@ class UploaderCompoment extends Component {
|
|||
// // const { isScriptLoaded, isScriptLoadSucceed } = this.props
|
||||
// // if (isScriptLoaded && isScriptLoadSucceed) {
|
||||
// // }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
onError(){
|
||||
onError() {}
|
||||
|
||||
}
|
||||
|
||||
openFileList=()=>{
|
||||
openFileList = () => {
|
||||
this.fileList["openFileList"]();
|
||||
};
|
||||
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<FileList inRef= {this.setRef.bind(this)} cancelUpload={this.cancelUpload.bind(this)}/>
|
||||
</div>
|
||||
<div>
|
||||
<FileList
|
||||
inRef={this.setRef.bind(this)}
|
||||
cancelUpload={this.cancelUpload.bind(this)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const Uploader = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
null,
|
||||
{forwardRef : true}
|
||||
)( scriptLoader(
|
||||
['/static/js/uploader/moxie.js'],
|
||||
['/static/js/uploader/plupload.dev.js'],
|
||||
['/static/js/uploader/i18n/zh_CN.js'],
|
||||
['/static/js/uploader/ui.js'],
|
||||
['/static/js/uploader/uploader.js'],
|
||||
const Uploader = connect(mapStateToProps, mapDispatchToProps, null, {
|
||||
forwardRef: true
|
||||
})(
|
||||
scriptLoader(
|
||||
["/static/js/uploader/moxie.js"],
|
||||
["/static/js/uploader/plupload.dev.js"],
|
||||
["/static/js/uploader/i18n/zh_CN.js"],
|
||||
["/static/js/uploader/ui.js"],
|
||||
["/static/js/uploader/uploader.js"]
|
||||
)(UploaderCompoment)
|
||||
);
|
||||
|
||||
)(UploaderCompoment))
|
||||
|
||||
export default Uploader
|
||||
export default Uploader;
|
||||
|
|
|
|||
Loading…
Reference in New Issue