1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-01 08:18:51 +09:00
This commit is contained in:
tamaina 2023-04-12 12:56:01 +00:00
parent 08046ad886
commit af7d86f69d
3 changed files with 36 additions and 9 deletions

View File

@ -476,7 +476,7 @@ regenerate: "再生成"
fontSize: "フォントサイズ"
mediaListWithOneImageAppearance: "画像が1枚のみのメディアリストの高さ"
expandAsImage: "画像に応じて拡張"
fixTo: "{x}に固定"
limitTo: "{x}を上限に"
noFollowRequests: "フォロー申請はありません"
openImageInNewTab: "画像を新しいタブで開く"
dashboard: "ダッシュボード"

View File

@ -2,10 +2,14 @@
<div>
<XBanner v-for="media in mediaList.filter(media => !previewable(media))" :key="media.id" :media="media"/>
<div v-if="mediaList.filter(media => previewable(media)).length > 0" :class="$style.container">
<div ref="gallery" :class="[
$style.medias,
count <= 4 ? $style['n' + count] : $style.nMany,
$style[`n1${defaultStore.reactiveState.mediaListWithOneImageAppearance.value}`]]">
<div
ref="gallery"
:class="[
$style.medias,
count <= 4 ? $style['n' + count] : $style.nMany,
$style[`n1${defaultStore.reactiveState.mediaListWithOneImageAppearance.value}`]
]"
>
<template v-for="media in mediaList.filter(media => previewable(media))">
<XVideo v-if="media.type.startsWith('video')" :key="`video:${media.id}`" :class="$style.media" :video="media"/>
<XImage v-else-if="media.type.startsWith('image')" :key="`image:${media.id}`" :class="$style.media" class="image" :data-id="media.id" :image="media" :raw="raw"/>
@ -16,7 +20,7 @@
</template>
<script lang="ts" setup>
import { onMounted, ref, useCssModule } from 'vue';
import { onMounted, ref, useCssModule, watch } from 'vue';
import * as misskey from 'misskey-js';
import PhotoSwipeLightbox from 'photoswipe/lightbox';
import PhotoSwipe from 'photoswipe';
@ -35,11 +39,34 @@ const props = defineProps<{
const $style = useCssModule();
const gallery = ref(null);
const gallery = ref<HTMLDivElement>();
const pswpZIndex = os.claimZIndex('middle');
document.documentElement.style.setProperty('--mk-pswp-root-z-index', pswpZIndex.toString());
const count = $computed(() => props.mediaList.filter(media => previewable(media)).length);
function calcAspectRatio() {
if (!gallery.value) return;
let img = props.mediaList[0];
if (!(img.properties.width && img.properties.height)) {
gallery.value.style.aspectRatio = '';
return;
}
switch (defaultStore.state.mediaListWithOneImageAppearance) {
//
case '16_9':
gallery.value.style.aspectRatio = Math.max(16 / 9, img.properties.width / img.properties.height).toString();
break;
default:
gallery.value.style.aspectRatio = '';
break;
}
}
watch([defaultStore.reactiveState.mediaListWithOneImageAppearance, gallery], () => calcAspectRatio());
onMounted(() => {
const lightbox = new PhotoSwipeLightbox({
dataSource: props.mediaList
@ -172,7 +199,7 @@ const previewable = (file: misskey.entities.DriveFile): boolean => {
&.n116_9 {
max-height: none;
aspect-ratio: 16/9;
aspect-ratio: 16 / 9; // fallback
}
}

View File

@ -84,7 +84,7 @@
<MkRadios v-model="mediaListWithOneImageAppearance">
<template #label>{{ i18n.ts.mediaListWithOneImageAppearance }}</template>
<option value="expand">{{ i18n.ts.expandAsImage }}</option>
<option value="16_9">{{ i18n.t('fixTo', { x: '16:9' }) }}</option>
<option value="16_9">{{ i18n.t('limitTo', { x: '16:9' }) }}</option>
</MkRadios>
</div>
</FormSection>