upload native
This commit is contained in:
parent
1eb423e0c0
commit
374b22a9e1
|
|
@ -48,7 +48,6 @@ export default function Render(props) {
|
|||
type: type,
|
||||
placement: placement,
|
||||
duration: data.duration || 4000,
|
||||
animationType: 'zoom-in',
|
||||
});
|
||||
}
|
||||
}, [data]);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ const withRouter = (Component, { path, properties }) => {
|
|||
const navigation = props.navigation;
|
||||
const route = props.route;
|
||||
const { params: routeParams } = route || {};
|
||||
const { forwardedRef, ...rest } = props;
|
||||
let params = {};
|
||||
/**
|
||||
* 由path来判定是否为Page。这里有个隐患,未来实现了keepAlive后,可能会影响到之前压栈的Page
|
||||
|
|
@ -71,8 +70,8 @@ const withRouter = (Component, { path, properties }) => {
|
|||
if (path) {
|
||||
params = Object.assign(params, getParams(routeParams, properties));
|
||||
}
|
||||
return (<Component {...rest} {...params} width="xs" ref={forwardedRef}/>);
|
||||
return <Component {...props} {...params} width="xs" />;
|
||||
};
|
||||
return React.forwardRef((props, ref) => <ComponentWithRouterProp {...props} forwardedRef={ref}/>);
|
||||
return ComponentWithRouterProp;
|
||||
};
|
||||
export default withRouter;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
export declare class Upload {
|
||||
uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record<string, any>, autoInform?: boolean): Promise<any>;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
export class Upload {
|
||||
async uploadFile(file, name, uploadUrl, formData, autoInform) {
|
||||
const formData2 = new FormData();
|
||||
for (const key of Object.keys(formData)) {
|
||||
formData2.append(key, formData[key]);
|
||||
}
|
||||
formData2.append(name || 'file', file);
|
||||
const options = {
|
||||
body: formData2,
|
||||
method: 'POST',
|
||||
};
|
||||
const result = await fetch(uploadUrl, options);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
export declare class Upload {
|
||||
uploadFile(file: File | string, name: string, uploadUrl: string, formData: Record<string, any>, autoInform?: boolean): Promise<any>;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Upload = void 0;
|
||||
class Upload {
|
||||
async uploadFile(file, name, uploadUrl, formData, autoInform) {
|
||||
const formData2 = new FormData();
|
||||
for (const key of Object.keys(formData)) {
|
||||
formData2.append(key, formData[key]);
|
||||
}
|
||||
formData2.append(name || 'file', file);
|
||||
const options = {
|
||||
body: formData2,
|
||||
method: 'POST',
|
||||
};
|
||||
const result = await fetch(uploadUrl, options);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.Upload = Upload;
|
||||
|
|
@ -54,7 +54,6 @@ export default function Render(props: { data: { data: MessageProps } }) {
|
|||
type: type,
|
||||
placement: placement,
|
||||
duration: data.duration || 4000,
|
||||
animationType: 'zoom-in',
|
||||
});
|
||||
}
|
||||
}, [data]);
|
||||
|
|
|
|||
|
|
@ -81,10 +81,7 @@ const withRouter = (Component: React.ComponentType<any>, { path, properties }: {
|
|||
const route = props.route;
|
||||
|
||||
const { params: routeParams } = route || {};
|
||||
const { forwardedRef, ...rest } = props;
|
||||
|
||||
let params = {};
|
||||
|
||||
/**
|
||||
* 由path来判定是否为Page。这里有个隐患,未来实现了keepAlive后,可能会影响到之前压栈的Page
|
||||
* 待测试。by Xc 20231102
|
||||
|
|
@ -93,16 +90,9 @@ const withRouter = (Component: React.ComponentType<any>, { path, properties }: {
|
|||
params = Object.assign(params, getParams(routeParams, properties));
|
||||
}
|
||||
|
||||
return (
|
||||
<Component
|
||||
{...rest}
|
||||
{...params}
|
||||
width="xs"
|
||||
ref={forwardedRef}
|
||||
/>
|
||||
);
|
||||
return <Component {...props} {...params} width="xs" />;
|
||||
};
|
||||
return React.forwardRef((props, ref) => <ComponentWithRouterProp {...props} forwardedRef={ref} />);
|
||||
return ComponentWithRouterProp;
|
||||
};
|
||||
|
||||
export default withRouter;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
|
||||
export class Upload {
|
||||
async uploadFile(
|
||||
file: File | string,
|
||||
name: string,
|
||||
uploadUrl: string,
|
||||
formData: Record<string, any>,
|
||||
autoInform?: boolean
|
||||
): Promise<any> {
|
||||
const formData2 = new FormData();
|
||||
for (const key of Object.keys(formData)) {
|
||||
formData2.append(key, formData[key]);
|
||||
}
|
||||
formData2.append(name || 'file', file as File);
|
||||
|
||||
const options = {
|
||||
body: formData2,
|
||||
method: 'POST',
|
||||
};
|
||||
|
||||
const result = await fetch(uploadUrl, options);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue