From 35fc9546a193fdf02a6c4e7391603b075830a2a1 Mon Sep 17 00:00:00 2001 From: sheepluo Date: Sun, 5 Nov 2023 20:11:04 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(Upload):=20=E6=96=87=E4=BB=B6=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=94=AF=E6=8C=81=E6=98=BE=E7=A4=BA=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/upload/main.ts | 19 +++++++++++++++---- js/upload/types.ts | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/js/upload/main.ts b/js/upload/main.ts index 6983920a47..c0730ba233 100644 --- a/js/upload/main.ts +++ b/js/upload/main.ts @@ -15,6 +15,7 @@ import { handleSuccessParams, UploadTriggerUploadText, ErrorContext, + ResponseType, } from './types'; export interface BeforeUploadExtra { @@ -67,13 +68,15 @@ export interface OnErrorParams extends ErrorContext { export function handleError(options: OnErrorParams) { const { event, files, response, XMLHttpRequest, formatResponse } = options; - files.forEach((file) => { - file.status = 'fail'; - }); let res = response; if (isFunction(formatResponse)) { res = formatResponse(response, { file: files[0], currentFiles: files }); } + files.forEach((file) => { + file.status = 'fail'; + file.response = res; + }); + return { response: res, event, files, XMLHttpRequest }; } @@ -146,7 +149,15 @@ export function uploadOneRequest(params: HandleUploadParams): Promise; +export type ResponseType = { error?: string; url?: string; status?: 'fail' | 'success'; files?: UploadFile[] } & Record export interface HandleUploadParams { /** 已经上传过的文件 */ From 56f3acdc7c44c2a1dde6c74deb68f6b952de1a7d Mon Sep 17 00:00:00 2001 From: sheepluo Date: Sun, 5 Nov 2023 20:28:21 +0800 Subject: [PATCH 2/5] fix: lint error --- js/upload/main.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/upload/main.ts b/js/upload/main.ts index c0730ba233..7b2688cf38 100644 --- a/js/upload/main.ts +++ b/js/upload/main.ts @@ -76,7 +76,6 @@ export function handleError(options: OnErrorParams) { file.status = 'fail'; file.response = res; }); - return { response: res, event, files, XMLHttpRequest }; } @@ -149,7 +148,7 @@ export function uploadOneRequest(params: HandleUploadParams): Promise Date: Mon, 6 Nov 2023 19:27:48 +0800 Subject: [PATCH 3/5] feat: upload disabled style --- style/web/components/upload/_index.less | 21 +++++++++++++++++++-- style/web/components/upload/_var.less | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/style/web/components/upload/_index.less b/style/web/components/upload/_index.less index 590c3c6a51..cd5023e21d 100644 --- a/style/web/components/upload/_index.less +++ b/style/web/components/upload/_index.less @@ -205,17 +205,23 @@ border-radius: @upload-card-img-wrap-border-radius; .hover-transition(border); - &:hover { + &:hover:not(.@{prefix}-is-disabled) { border-color: @upload-card-item-bg-border-color-hover; .hover-transition(border-color); } + > .t-icon { + color: @upload-icon-color; + } + > .t-icon, .@{prefix}-loading { font-size: @upload-icon-size-large; margin-bottom: @upload-card-container-icon-add-margin-bottom; } + - > p { + > p, + .@{prefix}-upload__add-text { color: @text-color-placeholder; margin: 0; } @@ -683,3 +689,14 @@ display: flex; align-items: center; } + +.@{prefix}-upload__card-container.@{prefix}-is-disabled { + cursor: not-allowed; + .@{prefix}-upload__add-text { + color: @upload-text-disabled-color; + } + + .t-icon { + color: @upload-icon-disabled-color; + } +} diff --git a/style/web/components/upload/_var.less b/style/web/components/upload/_var.less index 05a61a7bf7..3c7b442634 100644 --- a/style/web/components/upload/_var.less +++ b/style/web/components/upload/_var.less @@ -15,6 +15,7 @@ @upload-z-index: 2; // 颜色 +@upload-text-disabled-color: @text-color-disabled; @upload-icon-check-circle-filled-color: @success-color; @upload-icon-error-circle-filled-color: @error-color; @upload-icon-loading-color: @brand-color; @@ -25,6 +26,7 @@ @upload-small-color: @text-color-placeholder; @upload-placeholder-color: @text-color-placeholder; @upload-icon-color: @text-color-placeholder; +@upload-icon-disabled-color: @text-color-disabled; @upload-icon-color-hover: @text-color-secondary; @upload-list-file-icon-color: @brand-color; @upload-list-item-error-color: @error-color; From f143e65ca763b7c08170207c9a4a9ea6e3506689 Mon Sep 17 00:00:00 2001 From: sheepluo Date: Mon, 6 Nov 2023 19:35:42 +0800 Subject: [PATCH 4/5] fix: lint error --- style/web/components/upload/_index.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/style/web/components/upload/_index.less b/style/web/components/upload/_index.less index cd5023e21d..f3e756acd0 100644 --- a/style/web/components/upload/_index.less +++ b/style/web/components/upload/_index.less @@ -218,7 +218,6 @@ font-size: @upload-icon-size-large; margin-bottom: @upload-card-container-icon-add-margin-bottom; } - > p, .@{prefix}-upload__add-text { @@ -692,6 +691,7 @@ .@{prefix}-upload__card-container.@{prefix}-is-disabled { cursor: not-allowed; + .@{prefix}-upload__add-text { color: @upload-text-disabled-color; } From 1a5b2116a6f14185cebfa195bc825fd3c7e34349 Mon Sep 17 00:00:00 2001 From: sheepluo Date: Mon, 6 Nov 2023 19:39:50 +0800 Subject: [PATCH 5/5] fix: lint error --- style/web/components/upload/_index.less | 1 + 1 file changed, 1 insertion(+) diff --git a/style/web/components/upload/_index.less b/style/web/components/upload/_index.less index f3e756acd0..f1254d7741 100644 --- a/style/web/components/upload/_index.less +++ b/style/web/components/upload/_index.less @@ -209,6 +209,7 @@ border-color: @upload-card-item-bg-border-color-hover; .hover-transition(border-color); } + > .t-icon { color: @upload-icon-color; }