Skip to content

Commit

Permalink
fix(uploader): 修复data外部修改后提交时依然是旧值问题 (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohe0601 authored Nov 11, 2024
1 parent 072a8d0 commit c1e7a58
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 108 deletions.
1 change: 0 additions & 1 deletion docs/components/dentry/uploader.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ setup() {
| name | 文件名称 | - |
| url | 文件路径 | - |
| type | 文件类型,可选`image`,`video`,`audio` | - |
| formData | 上传所需的data | `{}` |
| percentage | 上传百分比 | `0` |
### Events
Expand Down
12 changes: 4 additions & 8 deletions packages/nutui/components/uploader/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '../progress/index';
@import '../button/index';
@import "../progress/index";
@import "../button/index";

.nut-theme-dark {
.nut-uploader {
Expand Down Expand Up @@ -35,8 +35,6 @@
width: $uploader-picture-width;
height: $uploader-picture-height;
background: $uploader-background;


}

&__input {
Expand Down Expand Up @@ -67,12 +65,13 @@
position: absolute;
top: 0;
left: 0;

/* #ifdef H5 */

z-index: 99;

/* #endif */

display: flex;
flex-direction: column;
align-items: center;
Expand All @@ -81,9 +80,6 @@
height: 100%;
background: rgb(0 0 0 / 60%);




&__msg {
margin-top: 6px;
font-size: 12px;
Expand Down
2 changes: 1 addition & 1 deletion packages/nutui/components/uploader/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './type'
export * from './types'
export * from './uploader'
export * from './use-uploader'
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@ export type AcceptType = 'image' | 'media' | 'video' | 'all'
export type MediaType = 'image' | 'video' | 'mix'
export type FileType = 'image' | 'video' | 'audio'
export type FileItemStatus = 'ready' | 'uploading' | 'success' | 'error'

export interface FileItem {
status: FileItemStatus

message: string

uid?: string

name: string

url?: string

type?: FileType

path?: string

percentage?: string | number
}

formData?: any
export interface UploaderInst {
/**
* @description 手动上传模式,执行上传操作
*/
submit: () => void
/**
* @description 调用选择文件的方法,效果等同于点击 nut-uploader 组件
*/
chooseImage: () => void
/**
* @description 清空已选择的文件队列(该方法一般配合在手动模式上传时使用)
* @param index
* @returns
*/
clearUploadQueue: (index: number) => void
}
19 changes: 1 addition & 18 deletions packages/nutui/components/uploader/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
nullableBooleanProp,
truthProp,
} from '../_utils'
import type { AcceptType, FileItem, MediaType, SizeType, SourceType } from './type'
import type { AcceptType, FileItem, MediaType, SizeType, SourceType } from './types'
import type { UploadOptions } from './use-uploader'

export const uploaderProps = {
Expand Down Expand Up @@ -150,20 +150,3 @@ export const uploaderEmits = {
}

export type UploaderEmits = typeof uploaderEmits

export interface UploaderInst {
/**
* @description 手动上传模式,执行上传操作
*/
submit: () => void
/**
* @description 调用选择文件的方法,效果等同于点击 nut-uploader 组件
*/
chooseImage: () => void
/**
* @description 清空已选择的文件队列(该方法一般配合在手动模式上传时使用)
* @param index
* @returns
*/
clearUploadQueue: (index: number) => void
}
Loading

0 comments on commit c1e7a58

Please sign in to comment.