enhance(frontend): サイズ制限を超過するファイルをアップロードしようとした際にエラーを出すように

This commit is contained in:
syuilo
2024-08-23 16:40:11 +09:00
parent 2f009f7d49
commit 8032a4e12a
8 changed files with 21 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ import { apiUrl } from '@/config.js';
import { $i } from '@/account.js';
import { alert } from '@/os.js';
import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
type Uploading = {
id: string;
@@ -39,6 +40,15 @@ export function uploadFile(
if (folder && typeof folder === 'object') folder = folder.id;
if (file.size > instance.maxFileSize) {
alert({
type: 'error',
title: i18n.ts.failedToUpload,
text: i18n.ts.cannotUploadBecauseExceedsFileSizeLimit,
});
return Promise.reject();
}
return new Promise((resolve, reject) => {
const id = uuid();