Commit 9bfbdf37 authored by XieZhiXiong's avatar XieZhiXiong

feat: 抽离 formily Upload 组件

parent 5093e150
......@@ -11,9 +11,7 @@ import {
FileFilled,
DeleteOutlined
} from '@ant-design/icons'
import { getAuth } from '@/utils/auth'
const { userId, memberId, token } = getAuth() || {}
const { Dragger: UploadDragger } = AntdUpload
const exts = [
......@@ -262,7 +260,6 @@ export const Upload = connect({
onChange={this.onChangeHandler}
onRemove={this.onRemoveHandler}
listType={'picture-card'}
headers={{token}}
>
{!others.readOnly ? (
<UploadPlaceholder />
......@@ -279,7 +276,6 @@ export const Upload = connect({
onRemove={this.onRemoveHandler}
// TODO image 类型是跟 picture 一样 ?
listType={listType.indexOf('image') > -1 ? 'picture' : 'text'}
headers={{token}}
>
<p className={'ant-upload-drag-icon'}>
<InboxOutlined />
......@@ -301,7 +297,6 @@ export const Upload = connect({
onChange={this.onChangeHandler}
onRemove={this.onRemoveHandler}
listType={listType}
headers={{token}}
itemRender={() => null}
>
{!others.readOnly ? (
......
/*
* @Author: XieZhiXiong
* @Date: 2021-06-01 17:32:51
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-01 17:44:27
* @Description: 默认带上 token 的 AntUpload
*/
import React from 'react';
import { getAuth } from '@/utils/auth';
import AntUpload from './AntUpload';
const FixUpload = (props) => {
const { token } = (getAuth() || {});
return (
<AntUpload
headers={{
token,
}}
{...props}
/>
);
};
FixUpload.isFieldComponent = true;
export default FixUpload;
......@@ -37,6 +37,7 @@ import Loading from '../Loading';
import MultAddress from './components/MultAddress';
import CustomAddress from './components/CustomAddress';
import CustomCascader from './components/CustomCascader';
import FixUpload from './components/FixUpload';
import { currentStateType, getCurrentState } from './utils/keepAlive';
import { useRouteMatch } from 'umi';
......@@ -119,6 +120,7 @@ export const componentExport = {
MultAddress,
CustomAddress,
CustomCascader,
FixUpload,
}
const NiceForm: React.FC<NiceFormProps> = props => {
const { children, components, effects, expressionScope, loading = false, ...reset } = props;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment