fix: some upload issue
parent
a325bf2319
commit
e623fc12cd
|
@ -1,20 +1,21 @@
|
||||||
import { getOptionProps, getListeners } from '../_util/props-util';
|
import { getOptionProps, getSlot } from '../_util/props-util';
|
||||||
import Upload from './Upload';
|
import Upload from './Upload';
|
||||||
import { UploadProps } from './interface';
|
import { UploadProps } from './interface';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AUploadDragger',
|
name: 'AUploadDragger',
|
||||||
|
inheritAttrs: false,
|
||||||
props: UploadProps,
|
props: UploadProps,
|
||||||
render() {
|
render() {
|
||||||
const props = getOptionProps(this);
|
const props = getOptionProps(this);
|
||||||
|
const { height, ...restProps } = props;
|
||||||
|
const { style, ...restAttrs } = this.$attrs;
|
||||||
const draggerProps = {
|
const draggerProps = {
|
||||||
props: {
|
...restProps,
|
||||||
...props,
|
...restAttrs,
|
||||||
type: 'drag',
|
type: 'drag',
|
||||||
},
|
style: { ...style, height },
|
||||||
on: getListeners(this),
|
|
||||||
style: { height: this.height },
|
|
||||||
};
|
};
|
||||||
return <Upload {...draggerProps}>{this.$slots.default}</Upload>;
|
return <Upload {...draggerProps}>{getSlot(this)}</Upload>;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -244,6 +244,7 @@ export default {
|
||||||
disabled,
|
disabled,
|
||||||
} = getOptionProps(this);
|
} = getOptionProps(this);
|
||||||
const { sFileList: fileList, dragState } = this.$data;
|
const { sFileList: fileList, dragState } = this.$data;
|
||||||
|
const { class: className, style } = this.$attrs;
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('upload', customizePrefixCls);
|
const prefixCls = getPrefixCls('upload', customizePrefixCls);
|
||||||
|
|
||||||
|
@ -257,7 +258,6 @@ export default {
|
||||||
onSuccess: this.onSuccess,
|
onSuccess: this.onSuccess,
|
||||||
onReject: this.onReject,
|
onReject: this.onReject,
|
||||||
ref: 'uploadRef',
|
ref: 'uploadRef',
|
||||||
...this.$attrs,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const uploadList = showUploadList ? (
|
const uploadList = showUploadList ? (
|
||||||
|
@ -272,6 +272,7 @@ export default {
|
||||||
|
|
||||||
if (type === 'drag') {
|
if (type === 'drag') {
|
||||||
const dragCls = classNames(prefixCls, {
|
const dragCls = classNames(prefixCls, {
|
||||||
|
[className]: !!className,
|
||||||
[`${prefixCls}-drag`]: true,
|
[`${prefixCls}-drag`]: true,
|
||||||
[`${prefixCls}-drag-uploading`]: fileList.some(file => file.status === 'uploading'),
|
[`${prefixCls}-drag-uploading`]: fileList.some(file => file.status === 'uploading'),
|
||||||
[`${prefixCls}-drag-hover`]: dragState === 'dragover',
|
[`${prefixCls}-drag-hover`]: dragState === 'dragover',
|
||||||
|
@ -284,6 +285,7 @@ export default {
|
||||||
onDrop={this.onFileDrop}
|
onDrop={this.onFileDrop}
|
||||||
onDragover={this.onFileDrop}
|
onDragover={this.onFileDrop}
|
||||||
onDragleave={this.onFileDrop}
|
onDragleave={this.onFileDrop}
|
||||||
|
style={style}
|
||||||
>
|
>
|
||||||
<VcUpload {...vcUploadProps} class={`${prefixCls}-btn`}>
|
<VcUpload {...vcUploadProps} class={`${prefixCls}-btn`}>
|
||||||
<div class={`${prefixCls}-drag-container`}>{children}</div>
|
<div class={`${prefixCls}-drag-container`}>{children}</div>
|
||||||
|
@ -303,7 +305,7 @@ export default {
|
||||||
// Remove id to avoid open by label when trigger is hidden
|
// Remove id to avoid open by label when trigger is hidden
|
||||||
// https://github.com/ant-design/ant-design/issues/14298
|
// https://github.com/ant-design/ant-design/issues/14298
|
||||||
if (!children || disabled) {
|
if (!children || disabled) {
|
||||||
delete vcUploadProps.props.id;
|
delete vcUploadProps.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadButton = (
|
const uploadButton = (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { inject, TransitionGroup } from 'vue';
|
import { inject, Transition, TransitionGroup } from 'vue';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import { getOptionProps, initDefaultProps, getListeners } from '../_util/props-util';
|
import { getOptionProps, initDefaultProps } from '../_util/props-util';
|
||||||
import getTransitionProps from '../_util/getTransitionProps';
|
import getTransitionProps from '../_util/getTransitionProps';
|
||||||
import { ConfigConsumerProps } from '../config-provider';
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
import { previewImage, isImageUrl } from './utils';
|
import { previewImage, isImageUrl } from './utils';
|
||||||
|
@ -66,17 +66,17 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handlePreview(file, e) {
|
handlePreview(file, e) {
|
||||||
const { preview } = getListeners(this);
|
const { onPreview } = this.$attrs;
|
||||||
if (!preview) {
|
if (!onPreview) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return this.$emit('preview', file);
|
return this.$emit('preview', file);
|
||||||
},
|
},
|
||||||
handleDownload(file) {
|
handleDownload(file) {
|
||||||
const { download } = getListeners(this);
|
const { onDownload } = this.$attrs;
|
||||||
if (typeof download === 'function') {
|
if (typeof onDownload === 'function') {
|
||||||
download(file);
|
onDownload(file);
|
||||||
} else if (file.url) {
|
} else if (file.url) {
|
||||||
window.open(file.url);
|
window.open(file.url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
import Upload from './Upload';
|
import Upload from './Upload';
|
||||||
import Dragger from './Dragger';
|
import Dragger from './Dragger';
|
||||||
import Base from '../base';
|
|
||||||
|
|
||||||
export { UploadProps, UploadListProps, UploadChangeParam } from './interface';
|
export { UploadProps, UploadListProps, UploadChangeParam } from './interface';
|
||||||
|
|
||||||
Upload.Dragger = Dragger;
|
Upload.Dragger = Dragger;
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
Upload.install = function(Vue) {
|
Upload.install = function(app) {
|
||||||
Vue.use(Base);
|
app.component(Upload.name, Upload);
|
||||||
Vue.component(Upload.name, Upload);
|
app.component(Dragger.name, Dragger);
|
||||||
Vue.component(Dragger.name, Dragger);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Upload;
|
export default Upload;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import PropTypes from '../../_util/vue-types';
|
import PropTypes from '../../_util/vue-types';
|
||||||
import antRef from '../../_util/ant-ref';
|
|
||||||
import { initDefaultProps } from '../../_util/props-util';
|
import { initDefaultProps } from '../../_util/props-util';
|
||||||
import enhancer from './enhancer';
|
import enhancer from './enhancer';
|
||||||
import { propTypes, defaultProps } from './types';
|
import { propTypes, defaultProps } from './types';
|
||||||
|
@ -71,7 +70,6 @@ function getPathStyles(offset, percent, strokeColor, strokeWidth, gapDegree = 0,
|
||||||
|
|
||||||
const Circle = {
|
const Circle = {
|
||||||
props: initDefaultProps(circlePropTypes, circleDefaultProps),
|
props: initDefaultProps(circlePropTypes, circleDefaultProps),
|
||||||
directives: { antRef },
|
|
||||||
created() {
|
created() {
|
||||||
this.paths = {};
|
this.paths = {};
|
||||||
this.gradientId = gradientSeed;
|
this.gradientId = gradientSeed;
|
||||||
|
@ -119,7 +117,7 @@ const Circle = {
|
||||||
class: `${prefixCls}-circle-path`,
|
class: `${prefixCls}-circle-path`,
|
||||||
style: pathStyle,
|
style: pathStyle,
|
||||||
};
|
};
|
||||||
return <path v-antRef={c => (this.paths[index] = c)} {...pathProps} />;
|
return <path ref={c => (this.paths[index] = c)} {...pathProps} />;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { initDefaultProps } from '../../_util/props-util';
|
import { initDefaultProps } from '../../_util/props-util';
|
||||||
import antRef from '../../_util/ant-ref';
|
|
||||||
import enhancer from './enhancer';
|
import enhancer from './enhancer';
|
||||||
import { propTypes, defaultProps } from './types';
|
import { propTypes, defaultProps } from './types';
|
||||||
|
|
||||||
const Line = {
|
const Line = {
|
||||||
props: initDefaultProps(propTypes, defaultProps),
|
props: initDefaultProps(propTypes, defaultProps),
|
||||||
directives: { antRef },
|
|
||||||
created() {
|
created() {
|
||||||
this.paths = {};
|
this.paths = {};
|
||||||
},
|
},
|
||||||
|
@ -78,7 +76,7 @@ const Line = {
|
||||||
style: pathStyle,
|
style: pathStyle,
|
||||||
};
|
};
|
||||||
|
|
||||||
return <path v-antRef={c => (this.paths[index] = c)} {...pathProps} />;
|
return <path ref={c => (this.paths[index] = c)} {...pathProps} />;
|
||||||
})}
|
})}
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import defaultRequest from './request';
|
||||||
import getUid from './uid';
|
import getUid from './uid';
|
||||||
import attrAccept from './attr-accept';
|
import attrAccept from './attr-accept';
|
||||||
import traverseFileTree from './traverseFileTree';
|
import traverseFileTree from './traverseFileTree';
|
||||||
import { getListeners, getSlot } from '../../_util/props-util';
|
import { getSlot } from '../../_util/props-util';
|
||||||
|
|
||||||
const upLoadPropTypes = {
|
const upLoadPropTypes = {
|
||||||
componentTag: PropTypes.string,
|
componentTag: PropTypes.string,
|
||||||
|
@ -216,9 +216,11 @@ const AjaxUploader = {
|
||||||
directory,
|
directory,
|
||||||
openFileDialogOnClick,
|
openFileDialogOnClick,
|
||||||
} = $props;
|
} = $props;
|
||||||
|
const { class: className, style, id } = $attrs;
|
||||||
const cls = classNames({
|
const cls = classNames({
|
||||||
[prefixCls]: true,
|
[prefixCls]: true,
|
||||||
[`${prefixCls}-disabled`]: disabled,
|
[`${prefixCls}-disabled`]: disabled,
|
||||||
|
[className]: className,
|
||||||
});
|
});
|
||||||
const events = disabled
|
const events = disabled
|
||||||
? {}
|
? {}
|
||||||
|
@ -233,11 +235,12 @@ const AjaxUploader = {
|
||||||
role: 'button',
|
role: 'button',
|
||||||
tabIndex: disabled ? null : '0',
|
tabIndex: disabled ? null : '0',
|
||||||
class: cls,
|
class: cls,
|
||||||
|
style,
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Tag {...tagProps}>
|
<Tag {...tagProps}>
|
||||||
<input
|
<input
|
||||||
id={$attrs.id}
|
id={id}
|
||||||
type="file"
|
type="file"
|
||||||
ref="fileInputRef"
|
ref="fileInputRef"
|
||||||
onClick={e => e.stopPropagation()} // https://github.com/ant-design/ant-design/issues/19948
|
onClick={e => e.stopPropagation()} // https://github.com/ant-design/ant-design/issues/19948
|
||||||
|
|
|
@ -257,6 +257,7 @@ const IframeUploader = {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { componentTag: Tag, disabled, prefixCls } = this.$props;
|
const { componentTag: Tag, disabled, prefixCls } = this.$props;
|
||||||
|
const { class: className, style } = this.$attrs;
|
||||||
const iframeStyle = {
|
const iframeStyle = {
|
||||||
...IFRAME_STYLE,
|
...IFRAME_STYLE,
|
||||||
display: this.uploading || disabled ? 'none' : '',
|
display: this.uploading || disabled ? 'none' : '',
|
||||||
|
@ -264,10 +265,11 @@ const IframeUploader = {
|
||||||
const cls = classNames({
|
const cls = classNames({
|
||||||
[prefixCls]: true,
|
[prefixCls]: true,
|
||||||
[`${prefixCls}-disabled`]: disabled,
|
[`${prefixCls}-disabled`]: disabled,
|
||||||
|
[className]: className,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tag className={cls} style={{ position: 'relative', zIndex: 0 }}>
|
<Tag class={cls} style={{ position: 'relative', zIndex: 0, ...style }}>
|
||||||
<iframe ref="iframeRef" onLoad={this.onLoad} style={iframeStyle} />
|
<iframe ref="iframeRef" onLoad={this.onLoad} style={iframeStyle} />
|
||||||
{getSlot(this)}
|
{getSlot(this)}
|
||||||
</Tag>
|
</Tag>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { initDefaultProps, getSlot } from '../../_util/props-util';
|
||||||
import BaseMixin from '../../_util/BaseMixin';
|
import BaseMixin from '../../_util/BaseMixin';
|
||||||
import AjaxUpload from './AjaxUploader';
|
import AjaxUpload from './AjaxUploader';
|
||||||
import IframeUpload from './IframeUploader';
|
import IframeUpload from './IframeUploader';
|
||||||
|
import { nextTick } from 'vue';
|
||||||
|
|
||||||
function empty() {}
|
function empty() {}
|
||||||
|
|
||||||
|
@ -51,21 +52,19 @@ export default {
|
||||||
openFileDialogOnClick: true,
|
openFileDialogOnClick: true,
|
||||||
}),
|
}),
|
||||||
data() {
|
data() {
|
||||||
|
this.Component = null;
|
||||||
return {
|
return {
|
||||||
Component: null,
|
// Component: null, // 组件作为响应式数据,性能比较低,采用强制刷新
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.supportServerRender) {
|
if (this.supportServerRender) {
|
||||||
this.setState(
|
this.Component = this.getComponent();
|
||||||
{
|
this.$forceUpdate();
|
||||||
Component: this.getComponent(),
|
nextTick(() => {
|
||||||
},
|
this.$emit('ready');
|
||||||
() => {
|
});
|
||||||
this.$emit('ready');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import demo from '../antdv-demo/docs/result/demo/index';
|
import demo from '../antdv-demo/docs/upload/demo/drag';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import '@babel/polyfill';
|
import '@babel/polyfill';
|
||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
import { Button, Upload, Icon, notification, message } from 'ant-design-vue';
|
import { Button, Upload, Icon, Modal, notification, message } from 'ant-design-vue';
|
||||||
import 'ant-design-vue/style.js';
|
import 'ant-design-vue/style.js';
|
||||||
|
|
||||||
const basic = {
|
const basic = {
|
||||||
|
@ -21,4 +21,5 @@ app
|
||||||
.use(Upload)
|
.use(Upload)
|
||||||
.use(Button)
|
.use(Button)
|
||||||
.use(Icon)
|
.use(Icon)
|
||||||
|
.use(Modal)
|
||||||
.mount('#app');
|
.mount('#app');
|
||||||
|
|
Loading…
Reference in New Issue