共通化

This commit is contained in:
kakkokari-gtyih 2024-12-14 19:41:30 +09:00
parent 5dba738a4a
commit c580f5e4cd
3 changed files with 36 additions and 40 deletions

View file

@ -5,10 +5,14 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<template v-for="file in note.files">
<div v-if="file.isSensitive && !showingFiles.includes(file.id)" :class="[$style.sensitive, { [$style.square]: square }]" @click="showingFiles.push(file.id)">
<div>
<div><i class="ti ti-eye-exclamation"></i> {{ i18n.ts.sensitive }}</div>
<div>{{ i18n.ts.clickToShow }}</div>
<div v-if="file.isSensitive && !showingFiles.includes(file.id)" :class="[$style.img, { [$style.square]: square }]" @click="showingFiles.push(file.id)">
<!-- TODO: 画像以外のファイルに対応 -->
<ImgWithBlurhash :class="$style.sensitiveImg" :hash="file.blurhash" :src="thumbnail(file)" :title="file.name" :forceBlurhash="true"/>
<div :class="$style.sensitive">
<div>
<div><i class="ti ti-eye-exclamation"></i> {{ i18n.ts.sensitive }}</div>
<div>{{ i18n.ts.clickToShow }}</div>
</div>
</div>
</div>
<MkA v-else :class="[$style.img, { [$style.square]: square }]" :to="notePage(note)">
@ -50,7 +54,8 @@ function thumbnail(image: Misskey.entities.DriveFile): string {
}
.img {
height: 220px;
position: relative;
height: 128px;
border-radius: 6px;
overflow: clip;
@ -65,8 +70,25 @@ function thumbnail(image: Misskey.entities.DriveFile): string {
text-align: center;
}
.sensitiveImg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
filter: brightness(0.7);
}
.sensitive {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: grid;
place-items: center;
place-items: center;
font-size: 0.8em;
color: #fff;
cursor: pointer;
}
</style>

View file

@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed } from 'vue';
import * as Misskey from 'misskey-js';
import MkMedias from '@/components/MkMedias.vue';
import MkMedias from '@/components/MkNoteMediaGrid.vue';
import MkPagination from '@/components/MkPagination.vue';
const props = defineProps<{

View file

@ -9,25 +9,10 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #header>{{ i18n.ts.files }}</template>
<div :class="$style.root">
<MkLoading v-if="fetching"/>
<div v-if="!fetching && files.length > 0" :class="$style.stream">
<template v-for="file in files" :key="file.note.id + file.file.id">
<div v-if="file.file.isSensitive && !showingFiles.includes(file.file.id)" :class="$style.img" @click="showingFiles.push(file.file.id)">
<!-- TODO: 画像以外のファイルに対応 -->
<ImgWithBlurhash :class="$style.sensitiveImg" :hash="file.file.blurhash" :src="thumbnail(file.file)" :title="file.file.name" :forceBlurhash="true"/>
<div :class="$style.sensitive">
<div>
<div><i class="ti ti-eye-exclamation"></i> {{ i18n.ts.sensitive }}</div>
<div>{{ i18n.ts.clickToShow }}</div>
</div>
</div>
</div>
<MkA v-else :class="$style.img" :to="notePage(file.note)">
<!-- TODO: 画像以外のファイルに対応 -->
<ImgWithBlurhash :hash="file.file.blurhash" :src="thumbnail(file.file)" :title="file.file.name"/>
</MkA>
</template>
<div v-if="!fetching && notes.length > 0" :class="$style.stream">
<MkNoteMediaGrid v-for="note in notes" :note="note"/>
</div>
<p v-if="!fetching && files.length == 0" :class="$style.empty">{{ i18n.ts.nothing }}</p>
<p v-if="!fetching && notes.length == 0" :class="$style.empty">{{ i18n.ts.nothing }}</p>
</div>
</MkContainer>
</template>
@ -42,6 +27,7 @@ import MkContainer from '@/components/MkContainer.vue';
import ImgWithBlurhash from '@/components/MkImgWithBlurhash.vue';
import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js';
import MkNoteMediaGrid from '@/components/MkNoteMediaGrid.vue';
const props = defineProps<{
user: Misskey.entities.UserDetailed;
@ -52,11 +38,7 @@ const emit = defineEmits<{
}>();
const fetching = ref(true);
const files = ref<{
note: Misskey.entities.Note;
file: Misskey.entities.DriveFile;
}[]>([]);
const showingFiles = ref<string[]>([]);
const notes = ref<Misskey.entities.Note[]>([]);
function unfoldContainer(): boolean {
emit('unfold');
@ -74,16 +56,8 @@ onMounted(() => {
userId: props.user.id,
withFiles: true,
limit: 15,
}).then(notes => {
for (const note of notes) {
if (!note.files) continue;
for (const file of note.files) {
files.value.push({
note,
file,
});
}
}
}).then(_notes => {
notes.value = _notes;
fetching.value = false;
});
});