update: avatar translation and lower limit
This commit is contained in:
@@ -19,8 +19,9 @@ export async function onRequestPut(context) {
|
||||
return createErrorResponse("Missing avatar", 400);
|
||||
}
|
||||
|
||||
if (avatar.size > 2 * 1024 * 1024) {
|
||||
return createErrorResponse("Avatar must be less than 2MB", 400);
|
||||
if (avatar.size > 1 * 1024 * 1024) {
|
||||
// Entity too large
|
||||
return createErrorResponse("Avatar must be less than 1MB", 413);
|
||||
}
|
||||
|
||||
const buffer = await avatar.arrayBuffer();
|
||||
|
||||
@@ -25,17 +25,17 @@ const onSubmit = async () => {
|
||||
avatarError.value = '';
|
||||
|
||||
if (!avatarFile.value) {
|
||||
avatarError.value = 'Avatar is required.';
|
||||
avatarError.value = '必須選擇新頭貼。';
|
||||
return;
|
||||
}
|
||||
|
||||
if (avatarFile.value.size > 2 * 1024 * 1024) {
|
||||
avatarError.value = 'Avatar must be less than 2MB.';
|
||||
if (avatarFile.value.size > 1 * 1024 * 1024) {
|
||||
avatarError.value = '頭貼檔案需小於 1MB。';
|
||||
return;
|
||||
}
|
||||
|
||||
if (avatarFile.value.type !== 'image/jpeg' && avatarFile.value.type !== 'image/png') {
|
||||
avatarError.value = 'Avatar must be a JPG or PNG image.';
|
||||
avatarError.value = '頭貼必須是 JPG 或 PNG 格式。';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ const avatarUrl = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
<div class="ts-control is-wide">
|
||||
<div class="label">Avatar</div>
|
||||
<div class="label">頭貼</div>
|
||||
<div class="content is-fluid">
|
||||
<div v-if="avatarUrl">
|
||||
<img :src="avatarUrl" alt="Avatar" style="max-width: 100px; max-height: 100px;" />
|
||||
@@ -81,7 +81,7 @@ const avatarUrl = computed(() => {
|
||||
<input type="file" accept="image/jpeg, image/png" @change="onFileChange" />
|
||||
</div>
|
||||
<div class="ts-text is-small is-negative" v-if="avatarError">{{ avatarError }}</div>
|
||||
<div class="ts-text is-small">Avatar 必須是 JPG 或 PNG 格式。檔案需小於 2MB。</div>
|
||||
<div class="ts-text is-small">頭貼必須是 JPG 或 PNG 格式。檔案需小於 1MB。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user