新建、上传文件filepath

This commit is contained in:
caishi 2023-04-26 15:36:30 +08:00
parent 5a85289dba
commit 757d7937e4
3 changed files with 12 additions and 6 deletions

View File

@ -28,6 +28,7 @@ onChangeFile,addonBefore , name , empty , onEmpty
}
},[name])
useEffect(()=>{
if(addonBefore){
setDefaultUrl(addonBefore.split('/'));
@ -50,7 +51,6 @@ onChangeFile,addonBefore , name , empty , onEmpty
function changeValue(e){
const value = e.target.value;
console.log(value);
if(value){
if(value === "/"){
setValue(undefined);

View File

@ -37,6 +37,11 @@ function Index(props){
function onChangeFile(value){
setFileName(value);
if(value){
setEmpty(false);
}else{
setEmpty(true);
}
}
return(

View File

@ -88,8 +88,8 @@ class UserSubmitComponent extends Component {
if (!err && !checkName) {
const url = `/${owner}/${projectsId}/create_file.json`;
axios.post(url, {
filepath: path.substr(1),
base64_filepath:Base64.encode(path.substr(1)),
filepath: returnbar(path.substr(1)),
base64_filepath:Base64.encode(returnbar(path.substr(1))),
branch: returnbar(branch),
new_branch: submitType === "1" ? values.branchname : undefined,
content:content ? (editor_type === "upload" ? content : Base64.encode(content)):"",
@ -130,8 +130,8 @@ class UserSubmitComponent extends Component {
if (!err && !checkName) {
axios
.put(url, {
filepath: detail.path,
base64_filepath:Base64.encode(detail.path),
filepath: returnbar(detail.path),
base64_filepath:Base64.encode(returnbar(detail.path)),
branch: submitType === "1" ? undefined : returnbar(b),
new_branch: submitType === "1" ? values.branchname : undefined,
content: content,
@ -185,7 +185,8 @@ class UserSubmitComponent extends Component {
onChangeFile=(value)=>{
const { changeName } = this.props;
this.setState({
filename:value
filename:value,
empty:value?false:true
})
changeName && changeName(value);
}