forked from Gitlink/forgeplus-react
Merge branch 'gitlink_server' of https://git.trustie.net/durian/forgeplus-react into gitlink_server
This commit is contained in:
commit
7a48179753
|
@ -57,7 +57,7 @@ export default (({ projectsId , branch , owner , changeBranch , branchList , tag
|
|||
<div className="branch-tagBox" ref={refBox} onClick={()=>setVisible(visible ? false : true)}>
|
||||
{/* {nav === 0 ?"分支":"标签"} */}
|
||||
<span className="color-grey-9 mr3 ml8"><i className="iconfont icon-fenzhi2 font-18"></i></span>
|
||||
<span className="ant-dropdown-link task-hide" style={{fontWeight:"500",minWidth:"45px",maxWidth:"270px"}}>
|
||||
<span className="ant-dropdown-link task-hide" style={{fontWeight:"500",minWidth:"45px",maxWidth:"180px"}}>
|
||||
{showValue}
|
||||
</span>
|
||||
<i className="showtag iconfont icon-sanjiaoxing-down font-15 color-grey-9 mr5 ml5 mt1" />
|
||||
|
|
|
@ -561,7 +561,7 @@ class Index extends Component {
|
|||
className="privatePart"
|
||||
>
|
||||
{getFieldDecorator('is_mirror')(
|
||||
<Checkbox value="limit">该仓库将是一个<span className="color-blue">镜像</span>(设置为镜像后,该项目为只读,不能进行push等相关操作)</Checkbox>
|
||||
<Checkbox value="limit">该仓库将是一个<span className="color-blue">镜像</span>(设置为镜像后,该仓库为只读,每24小时定时同步一次)</Checkbox>
|
||||
)}
|
||||
</Form.Item >
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
import React, { Component } from "react";
|
||||
import { Upload, Icon } from "antd";
|
||||
import { getUploadActionUrl, appendFileSizeToUploadFileAll } from "educoder";
|
||||
|
||||
import axios from "axios";
|
||||
const { Dragger } = Upload;
|
||||
class Read extends Component {
|
||||
constructor(props) {
|
||||
|
@ -22,57 +19,43 @@ class Read extends Component {
|
|||
});
|
||||
};
|
||||
|
||||
handleChange = (info) => {
|
||||
let reader = new FileReader();
|
||||
reader.readAsText(info.fileList[0].originFileObj, "UTF-8");
|
||||
reader.onload = (e) => {
|
||||
this.state.fileContent = e.target.result;
|
||||
this.props.load && this.props.load(this.state);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
beforeUpload = (file) => {
|
||||
const forbidden_type = [
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"png",
|
||||
"ico",
|
||||
"bmp",
|
||||
"gif",
|
||||
"pdf",
|
||||
"csv",
|
||||
"xlsx",
|
||||
"xls",
|
||||
"tif",
|
||||
"svg",
|
||||
"psd",
|
||||
"cdr",
|
||||
"webp",
|
||||
"vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"vnd.ms-powerpoint",
|
||||
"vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
"vnd.ms-excel"
|
||||
];
|
||||
const { fileList } = this.state;
|
||||
const { size } = this.props;
|
||||
const isLt100M = file.size / 1024 / 1024 < size;
|
||||
const file_type = file.type.split("/").slice(-1)[0];
|
||||
if (fileList && fileList.length > 0) {
|
||||
this.props.showNotification("文件已存在, 请删除后再上传");
|
||||
return false;
|
||||
} else if (!isLt100M) {
|
||||
this.props.showNotification(`文件大小必须小于${size}MB!`);
|
||||
} else if (file_type && forbidden_type.indexOf(file_type) !== -1) {
|
||||
this.props.showNotification(`仅支持文本格式,不支持图片,excel等不可以txt读取的文件`);
|
||||
return false;
|
||||
} else {
|
||||
this.setState({
|
||||
fileList: [file],
|
||||
fileName: file.name,
|
||||
})
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// 上传 文件转base64
|
||||
customRequest = (option) =>{
|
||||
const formData = new FormData();
|
||||
formData.append('files[]', option.file);
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(option.file);
|
||||
const {load} = this.props;
|
||||
reader.onloadend = function(e){
|
||||
if(e.target.result){
|
||||
option.onSuccess();
|
||||
const base64 = e.target.result.substring(e.target.result.indexOf('base64')+7, e.target.result.length);
|
||||
load({
|
||||
fileName: option.file.name,
|
||||
fileContent: base64
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
//判断是否已经提交,如已提交评论则上一条评论数据清除
|
||||
const { icon, size } = this.props;
|
||||
|
@ -80,10 +63,10 @@ class Read extends Component {
|
|||
const upload = {
|
||||
name: "file",
|
||||
fileList: fileList,
|
||||
onChange: this.handleChange,
|
||||
customRequest: this.customRequest,
|
||||
onRemove: this.onAttachmentRemove,
|
||||
beforeUpload: this.beforeUpload
|
||||
};
|
||||
beforeUpload: this.beforeUpload,
|
||||
};
|
||||
|
||||
return (
|
||||
<Dragger {...upload} className={this.props.className}>
|
||||
|
@ -95,9 +78,9 @@ class Read extends Component {
|
|||
<p className="ant-upload-text">
|
||||
拖动文件或<span className="color-blue">点击此处上传</span>
|
||||
</p>
|
||||
<p className="mt10">
|
||||
{/* <p className="mt10">
|
||||
暂仅支持文本格式,不支持图片,excel等不可以txt读取的文件
|
||||
</p>
|
||||
</p> */}
|
||||
<p className="mt10">
|
||||
文件名请使用英文且不得超过{size}MB
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue