fix(frontend): use logical OR for fallback of file comment

This commit is contained in:
poppingmoon 2026-01-10 16:30:46 +09:00
parent 141964e57c
commit 62b97dce75
2 changed files with 9 additions and 5 deletions

View File

@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
>
<template #header>{{ file.name }}</template>
<div :class="$style.container">
<img :src="file.url" :alt="file.comment ?? file.name" :class="$style.img"/>
<img :src="file.url" :alt="file.comment || file.name" :class="$style.img"/>
</div>
</MkModalWindow>
</template>

View File

@ -107,8 +107,10 @@ onMounted(() => {
src: media.url,
w: media.properties.width,
h: media.properties.height,
alt: media.comment ?? media.name,
comment: media.comment ?? media.name,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
alt: media.comment || media.name,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
comment: media.comment || media.name,
};
if (media.properties.orientation != null && media.properties.orientation >= 5) {
[item.w, item.h] = [item.h, item.w];
@ -155,8 +157,10 @@ onMounted(() => {
[itemData.w, itemData.h] = [itemData.h, itemData.w];
}
itemData.msrc = file.thumbnailUrl ?? undefined;
itemData.alt = file.comment ?? file.name;
itemData.comment = file.comment ?? file.name;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
itemData.alt = file.comment || file.name;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
itemData.comment = file.comment || file.name;
itemData.thumbCropped = true;
return itemData;