Update EmMediaImage.vue
This commit is contained in:
parent
adef17a33d
commit
c6e60dc1cb
|
@ -4,20 +4,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="[hide ? $style.hidden : $style.visible, (image.isSensitive && defaultStore.state.highlightSensitiveMedia) && $style.sensitive]" :style="darkMode ? '--c: rgb(255 255 255 / 2%);' : '--c: rgb(0 0 0 / 2%);'" @click="onclick">
|
<div :class="[hide ? $style.hidden : $style.visible]" :style="darkMode ? '--c: rgb(255 255 255 / 2%);' : '--c: rgb(0 0 0 / 2%);'" @click="onclick">
|
||||||
<component
|
<a
|
||||||
:is="disableImageLink ? 'div' : 'a'"
|
:title="image.name"
|
||||||
v-bind="disableImageLink ? {
|
:class="$style.imageContainer"
|
||||||
title: image.name,
|
:href="image.url"
|
||||||
class: $style.imageContainer,
|
target="_blank"
|
||||||
} : {
|
rel="noopener"
|
||||||
title: image.name,
|
style="cursor: zoom-in;"
|
||||||
class: $style.imageContainer,
|
|
||||||
href: image.url,
|
|
||||||
target: '_blank',
|
|
||||||
rel: 'noopener',
|
|
||||||
style: 'cursor: zoom-in;'
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
<ImgWithBlurhash
|
<ImgWithBlurhash
|
||||||
:hash="image.blurhash"
|
:hash="image.blurhash"
|
||||||
|
@ -30,7 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:height="image.properties.height"
|
:height="image.properties.height"
|
||||||
:style="hide ? 'filter: brightness(0.7);' : null"
|
:style="hide ? 'filter: brightness(0.7);' : null"
|
||||||
/>
|
/>
|
||||||
</component>
|
</a>
|
||||||
<template v-if="hide">
|
<template v-if="hide">
|
||||||
<div :class="$style.hiddenText">
|
<div :class="$style.hiddenText">
|
||||||
<div :class="$style.hiddenTextWrapper">
|
<div :class="$style.hiddenTextWrapper">
|
||||||
|
@ -40,48 +34,35 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="controls">
|
|
||||||
<div :class="$style.indicators">
|
<div :class="$style.indicators">
|
||||||
<div v-if="['image/gif', 'image/apng'].includes(image.type)" :class="$style.indicator">GIF</div>
|
<div v-if="['image/gif', 'image/apng'].includes(image.type)" :class="$style.indicator">GIF</div>
|
||||||
<div v-if="image.comment" :class="$style.indicator">ALT</div>
|
<div v-if="image.comment" :class="$style.indicator">ALT</div>
|
||||||
<div v-if="image.isSensitive" :class="$style.indicator" style="color: var(--warn);" :title="i18n.ts.sensitive"><i class="ti ti-eye-exclamation"></i></div>
|
<div v-if="image.isSensitive" :class="$style.indicator" style="color: var(--warn);" :title="i18n.ts.sensitive"><i class="ti ti-eye-exclamation"></i></div>
|
||||||
</div>
|
</div>
|
||||||
<button :class="$style.menu" class="_button" @click.stop="showMenu"><i class="ti ti-dots" style="vertical-align: middle;"></i></button>
|
|
||||||
<i class="ti ti-eye-off" :class="$style.hide" @click.stop="hide = true"></i>
|
<i class="ti ti-eye-off" :class="$style.hide" @click.stop="hide = true"></i>
|
||||||
</template>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { watch, ref, computed } from 'vue';
|
import { watch, ref, computed } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { getStaticImageUrl } from '@/scripts/media-proxy.js';
|
|
||||||
import bytes from '@/filters/bytes.js';
|
import bytes from '@/filters/bytes.js';
|
||||||
import ImgWithBlurhash from '@/components/MkImgWithBlurhash.vue';
|
import ImgWithBlurhash from '@/components/MkImgWithBlurhash.vue';
|
||||||
import { defaultStore } from '@/store.js';
|
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import * as os from '@/os.js';
|
|
||||||
import { $i, iAmModerator } from '@/account.js';
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
image: Misskey.entities.DriveFile;
|
image: Misskey.entities.DriveFile;
|
||||||
raw?: boolean;
|
raw?: boolean;
|
||||||
cover?: boolean;
|
cover?: boolean;
|
||||||
disableImageLink?: boolean;
|
|
||||||
controls?: boolean;
|
|
||||||
}>(), {
|
}>(), {
|
||||||
cover: false,
|
cover: false,
|
||||||
disableImageLink: false,
|
|
||||||
controls: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const hide = ref(true);
|
const hide = ref(props.image.isSensitive);
|
||||||
const darkMode = ref<boolean>(defaultStore.state.darkMode);
|
const darkMode = ref<boolean>(false); // TODO
|
||||||
|
|
||||||
const url = computed(() => (props.raw || defaultStore.state.loadRawImages)
|
const url = computed(() => (props.raw)
|
||||||
? props.image.url
|
? props.image.url
|
||||||
: defaultStore.state.disableShowingAnimatedImages
|
|
||||||
? getStaticImageUrl(props.image.url)
|
|
||||||
: props.image.thumbnailUrl,
|
: props.image.thumbnailUrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -92,50 +73,9 @@ async function onclick(ev: MouseEvent) {
|
||||||
|
|
||||||
if (hide.value) {
|
if (hide.value) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
if (props.image.isSensitive && defaultStore.state.confirmWhenRevealingSensitiveMedia) {
|
|
||||||
const { canceled } = await os.confirm({
|
|
||||||
type: 'question',
|
|
||||||
text: i18n.ts.sensitiveMediaRevealConfirm,
|
|
||||||
});
|
|
||||||
if (canceled) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hide.value = false;
|
hide.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin:register_note_view_interruptor を使って書き換えられる可能性があるためwatchする
|
|
||||||
watch(() => props.image, () => {
|
|
||||||
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.image.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
|
||||||
}, {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
function showMenu(ev: MouseEvent) {
|
|
||||||
os.popupMenu([{
|
|
||||||
text: i18n.ts.hide,
|
|
||||||
icon: 'ti ti-eye-off',
|
|
||||||
action: () => {
|
|
||||||
hide.value = true;
|
|
||||||
},
|
|
||||||
}, ...(iAmModerator ? [{
|
|
||||||
text: i18n.ts.markAsSensitive,
|
|
||||||
icon: 'ti ti-eye-exclamation',
|
|
||||||
danger: true,
|
|
||||||
action: () => {
|
|
||||||
os.apiWithDialog('drive/files/update', { fileId: props.image.id, isSensitive: true });
|
|
||||||
},
|
|
||||||
}] : []), ...($i?.id === props.image.userId ? [{
|
|
||||||
type: 'divider' as const,
|
|
||||||
}, {
|
|
||||||
type: 'link' as const,
|
|
||||||
text: i18n.ts._fileViewer.title,
|
|
||||||
icon: 'ti ti-info-circle',
|
|
||||||
to: `/my/drive/file/${props.image.id}`,
|
|
||||||
}] : [])], ev.currentTarget ?? ev.target);
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
|
@ -143,22 +83,6 @@ function showMenu(ev: MouseEvent) {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sensitive {
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
pointer-events: none;
|
|
||||||
border-radius: inherit;
|
|
||||||
box-shadow: inset 0 0 0 4px var(--warn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hiddenText {
|
.hiddenText {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -202,22 +126,6 @@ function showMenu(ev: MouseEvent) {
|
||||||
background-size: 16px 16px;
|
background-size: 16px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu {
|
|
||||||
display: block;
|
|
||||||
position: absolute;
|
|
||||||
border-radius: 999px;
|
|
||||||
background-color: rgba(0, 0, 0, 0.3);
|
|
||||||
-webkit-backdrop-filter: var(--blur, blur(15px));
|
|
||||||
backdrop-filter: var(--blur, blur(15px));
|
|
||||||
color: #fff;
|
|
||||||
font-size: 0.8em;
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
text-align: center;
|
|
||||||
bottom: 10px;
|
|
||||||
right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.imageContainer {
|
.imageContainer {
|
||||||
display: block;
|
display: block;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
Loading…
Reference in a new issue