-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix enhance: 모바일 기기에서의 배치 개선 test
- Loading branch information
Showing
3 changed files
with
176 additions
and
129 deletions.
There are no files selected for viewing
142 changes: 142 additions & 0 deletions
142
packages/frontend/src/pages/user/index.timeline.files.files.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: syuilo and misskey-project | ||
SPDX-License-Identifier: AGPL-3.0-only | ||
--> | ||
|
||
<template> | ||
<div v-if="files.files.length > 0"> | ||
<div> | ||
<template v-for="file in files.files" :key="files.id + file.id"> | ||
<div v-if="file.isSensitive && !showingFiles.includes(file.id)" :class="$style.img" @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" :to="notePage(files)"> | ||
<!-- TODO: 画像以外のファイルに対応 --> | ||
<ImgWithBlurhash | ||
:hash="file.blurhash" | ||
:src="thumbnail(file)" | ||
:title="file.name" | ||
@mouseover="defaultStore.state.showingAnimatedImages === 'interaction' ? playAnimation = true : ''" | ||
@mouseout="defaultStore.state.showingAnimatedImages === 'interaction' ? playAnimation = false : ''" | ||
@touchstart="defaultStore.state.showingAnimatedImages === 'interaction' ? playAnimation = true : ''" | ||
@touchend="defaultStore.state.showingAnimatedImages === 'interaction' ? playAnimation = false : ''" | ||
/> | ||
</MkA> | ||
</template> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { onMounted, onUnmounted, ref } from 'vue'; | ||
import * as Misskey from 'cherrypick-js'; | ||
import { getStaticImageUrl } from '@/scripts/media-proxy.js'; | ||
import { notePage } from '@/filters/note.js'; | ||
import ImgWithBlurhash from '@/components/MkImgWithBlurhash.vue'; | ||
import MkA from '@/components/global/MkA.vue'; | ||
import { defaultStore } from '@/store.js'; | ||
import { i18n } from '@/i18n.js'; | ||
const props = defineProps<{ | ||
user: Misskey.entities.UserDetailed; | ||
files: Misskey.entities.DriveFile[]; | ||
}>(); | ||
const showingFiles = ref<string[]>([]); | ||
const playAnimation = ref(true); | ||
if (defaultStore.state.showingAnimatedImages === 'interaction') playAnimation.value = false; | ||
let playAnimationTimer = setTimeout(() => playAnimation.value = false, 5000); | ||
function thumbnail(image: Misskey.entities.DriveFile): string | null { | ||
return (defaultStore.state.disableShowingAnimatedImages || defaultStore.state.dataSaver.media) || (['interaction', 'inactive'].includes(<string>defaultStore.state.showingAnimatedImages) && !playAnimation.value) | ||
? getStaticImageUrl(image.url) | ||
: image.thumbnailUrl; | ||
} | ||
function resetTimer() { | ||
playAnimation.value = true; | ||
clearTimeout(playAnimationTimer); | ||
playAnimationTimer = setTimeout(() => playAnimation.value = false, 5000); | ||
} | ||
onMounted(() => { | ||
if (defaultStore.state.showingAnimatedImages === 'inactive') { | ||
window.addEventListener('mousemove', resetTimer); | ||
window.addEventListener('touchstart', resetTimer); | ||
window.addEventListener('touchend', resetTimer); | ||
} | ||
}); | ||
onUnmounted(() => { | ||
if (defaultStore.state.showingAnimatedImages === 'inactive') { | ||
window.removeEventListener('mousemove', resetTimer); | ||
window.removeEventListener('touchstart', resetTimer); | ||
window.removeEventListener('touchend', resetTimer); | ||
} | ||
}); | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.img { | ||
display: flex; | ||
position: relative; | ||
height: 256px; | ||
border-radius: 3px; | ||
overflow: clip; | ||
} | ||
.empty { | ||
margin: 0; | ||
padding: 16px; | ||
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; | ||
font-size: 0.8em; | ||
color: #fff; | ||
cursor: pointer; | ||
} | ||
@container (max-width: 785px) { | ||
.img { | ||
height: 192px; | ||
} | ||
} | ||
@container (max-width: 660px) { | ||
.img { | ||
height: 160px; | ||
} | ||
} | ||
@container (max-width: 530px) { | ||
.img { | ||
height: 145px; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters