Commit 9bfbdf37 authored by XieZhiXiong's avatar XieZhiXiong

feat: 抽离 formily Upload 组件

parent 5093e150
...@@ -11,9 +11,7 @@ import { ...@@ -11,9 +11,7 @@ import {
FileFilled, FileFilled,
DeleteOutlined DeleteOutlined
} from '@ant-design/icons' } from '@ant-design/icons'
import { getAuth } from '@/utils/auth'
const { userId, memberId, token } = getAuth() || {}
const { Dragger: UploadDragger } = AntdUpload const { Dragger: UploadDragger } = AntdUpload
const exts = [ const exts = [
...@@ -262,7 +260,6 @@ export const Upload = connect({ ...@@ -262,7 +260,6 @@ export const Upload = connect({
onChange={this.onChangeHandler} onChange={this.onChangeHandler}
onRemove={this.onRemoveHandler} onRemove={this.onRemoveHandler}
listType={'picture-card'} listType={'picture-card'}
headers={{token}}
> >
{!others.readOnly ? ( {!others.readOnly ? (
<UploadPlaceholder /> <UploadPlaceholder />
...@@ -279,7 +276,6 @@ export const Upload = connect({ ...@@ -279,7 +276,6 @@ export const Upload = connect({
onRemove={this.onRemoveHandler} onRemove={this.onRemoveHandler}
// TODO image 类型是跟 picture 一样 ? // TODO image 类型是跟 picture 一样 ?
listType={listType.indexOf('image') > -1 ? 'picture' : 'text'} listType={listType.indexOf('image') > -1 ? 'picture' : 'text'}
headers={{token}}
> >
<p className={'ant-upload-drag-icon'}> <p className={'ant-upload-drag-icon'}>
<InboxOutlined /> <InboxOutlined />
...@@ -301,7 +297,6 @@ export const Upload = connect({ ...@@ -301,7 +297,6 @@ export const Upload = connect({
onChange={this.onChangeHandler} onChange={this.onChangeHandler}
onRemove={this.onRemoveHandler} onRemove={this.onRemoveHandler}
listType={listType} listType={listType}
headers={{token}}
itemRender={() => null} itemRender={() => null}
> >
{!others.readOnly ? ( {!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'; ...@@ -37,6 +37,7 @@ import Loading from '../Loading';
import MultAddress from './components/MultAddress'; import MultAddress from './components/MultAddress';
import CustomAddress from './components/CustomAddress'; import CustomAddress from './components/CustomAddress';
import CustomCascader from './components/CustomCascader'; import CustomCascader from './components/CustomCascader';
import FixUpload from './components/FixUpload';
import { currentStateType, getCurrentState } from './utils/keepAlive'; import { currentStateType, getCurrentState } from './utils/keepAlive';
import { useRouteMatch } from 'umi'; import { useRouteMatch } from 'umi';
...@@ -119,6 +120,7 @@ export const componentExport = { ...@@ -119,6 +120,7 @@ export const componentExport = {
MultAddress, MultAddress,
CustomAddress, CustomAddress,
CustomCascader, CustomCascader,
FixUpload,
} }
const NiceForm: React.FC<NiceFormProps> = props => { const NiceForm: React.FC<NiceFormProps> = props => {
const { children, components, effects, expressionScope, loading = false, ...reset } = 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