lazy load browser-image-resizer

This commit is contained in:
tamaina 2022-01-29 22:18:12 +09:00
parent 8a32cedf6e
commit 38f84a94ba

View file

@ -1,6 +1,5 @@
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import { readAndCompressImage } from 'browser-image-resizer';
import { apiUrl } from '@/config'; import { apiUrl } from '@/config';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { $i } from '@/account'; import { $i } from '@/account';
@ -52,6 +51,8 @@ export function uploadFile(file: File, folder?: any, name?: string, keepOriginal
debug: true, debug: true,
...compressTypeMap[file.type], ...compressTypeMap[file.type],
}; };
const { readAndCompressImage } = await import('browser-image-resizer');
resizedImage = await readAndCompressImage(file, config); resizedImage = await readAndCompressImage(file, config);
ctx.name = `${ctx.name}.${mimeTypeMap[compressTypeMap[file.type].mimeType]}`; ctx.name = `${ctx.name}.${mimeTypeMap[compressTypeMap[file.type].mimeType]}`;
} }