mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Uploader): render objectUrl to avoid perf issue (#12106)
This commit is contained in:
parent
f56634c4a5
commit
1e585b5ce0
@ -158,6 +158,7 @@ export default defineComponent({
|
|||||||
file,
|
file,
|
||||||
status: '',
|
status: '',
|
||||||
message: '',
|
message: '',
|
||||||
|
objectUrl: URL.createObjectURL(file)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (contents[index]) {
|
if (contents[index]) {
|
||||||
@ -175,6 +176,7 @@ export default defineComponent({
|
|||||||
file: files as File,
|
file: files as File,
|
||||||
status: '',
|
status: '',
|
||||||
message: '',
|
message: '',
|
||||||
|
objectUrl: URL.createObjectURL(files as File),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (content) {
|
if (content) {
|
||||||
@ -230,8 +232,8 @@ export default defineComponent({
|
|||||||
const imageFiles = props.modelValue.filter(isImageFile);
|
const imageFiles = props.modelValue.filter(isImageFile);
|
||||||
const images = imageFiles
|
const images = imageFiles
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
if (item.file && !item.url && item.status !== 'failed') {
|
if (item.objectUrl && !item.url && item.status !== 'failed') {
|
||||||
item.url = URL.createObjectURL(item.file);
|
item.url = item.objectUrl;
|
||||||
urls.push(item.url);
|
urls.push(item.url);
|
||||||
}
|
}
|
||||||
return item.url;
|
return item.url;
|
||||||
|
@ -111,7 +111,7 @@ export default defineComponent({
|
|||||||
<Image
|
<Image
|
||||||
v-slots={{ default: renderCover }}
|
v-slots={{ default: renderCover }}
|
||||||
fit={imageFit}
|
fit={imageFit}
|
||||||
src={item.content || item.url}
|
src={item.objectUrl || item.content || item.url}
|
||||||
class={bem('preview-image')}
|
class={bem('preview-image')}
|
||||||
width={Array.isArray(previewSize) ? previewSize[0] : previewSize}
|
width={Array.isArray(previewSize) ? previewSize[0] : previewSize}
|
||||||
height={Array.isArray(previewSize) ? previewSize[1] : previewSize}
|
height={Array.isArray(previewSize) ? previewSize[1] : previewSize}
|
||||||
|
@ -8,6 +8,7 @@ export type UploaderResultType = 'dataUrl' | 'text' | 'file';
|
|||||||
export type UploaderFileListItem = {
|
export type UploaderFileListItem = {
|
||||||
url?: string;
|
url?: string;
|
||||||
file?: File;
|
file?: File;
|
||||||
|
objectUrl?: string;
|
||||||
content?: string;
|
content?: string;
|
||||||
isImage?: boolean;
|
isImage?: boolean;
|
||||||
status?: '' | 'uploading' | 'done' | 'failed';
|
status?: '' | 'uploading' | 'done' | 'failed';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user