mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-13 06:08:14 +09:00
improve menu
This commit is contained in:
parent
b4fc96ca5b
commit
e814f3d740
@ -82,9 +82,7 @@ const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.data
|
|||||||
const menuShowing = ref(false);
|
const menuShowing = ref(false);
|
||||||
|
|
||||||
function showMenu(ev: MouseEvent) {
|
function showMenu(ev: MouseEvent) {
|
||||||
let menu: MenuItem[] = [];
|
const menu: MenuItem[] = [
|
||||||
|
|
||||||
menu = [
|
|
||||||
// TODO: 再生キューに追加
|
// TODO: 再生キューに追加
|
||||||
{
|
{
|
||||||
text: i18n.ts.hide,
|
text: i18n.ts.hide,
|
||||||
@ -95,6 +93,12 @@ function showMenu(ev: MouseEvent) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($i?.id === props.audio.userId || iAmModerator) {
|
||||||
|
menu.push({
|
||||||
|
type: 'divider',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (iAmModerator) {
|
if (iAmModerator) {
|
||||||
menu.push({
|
menu.push({
|
||||||
text: props.audio.isSensitive ? i18n.ts.unmarkAsSensitive : i18n.ts.markAsSensitive,
|
text: props.audio.isSensitive ? i18n.ts.unmarkAsSensitive : i18n.ts.markAsSensitive,
|
||||||
@ -102,12 +106,19 @@ function showMenu(ev: MouseEvent) {
|
|||||||
danger: true,
|
danger: true,
|
||||||
action: () => toggleSensitive(props.audio),
|
action: () => toggleSensitive(props.audio),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ($i?.id !== props.audio.userId) {
|
||||||
|
menu.push({
|
||||||
|
type: 'link' as const,
|
||||||
|
text: i18n.ts._fileViewer.title,
|
||||||
|
icon: 'ti ti-info-circle',
|
||||||
|
to: `/admin/file/${props.audio.id}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i?.id === props.audio.userId) {
|
if ($i?.id === props.audio.userId) {
|
||||||
menu.push({
|
menu.push({
|
||||||
type: 'divider',
|
|
||||||
}, {
|
|
||||||
type: 'link' as const,
|
type: 'link' as const,
|
||||||
text: i18n.ts._fileViewer.title,
|
text: i18n.ts._fileViewer.title,
|
||||||
icon: 'ti ti-info-circle',
|
icon: 'ti ti-info-circle',
|
||||||
|
@ -53,6 +53,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<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 type { MenuItem } from '@/types/menu.js';
|
||||||
import { getStaticImageUrl } from '@/scripts/media-proxy.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';
|
||||||
@ -84,6 +85,51 @@ const url = computed(() => (props.raw || defaultStore.state.loadRawImages)
|
|||||||
: props.image.thumbnailUrl,
|
: props.image.thumbnailUrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function showMenu(ev: MouseEvent) {
|
||||||
|
const menu: MenuItem[] = [{
|
||||||
|
text: i18n.ts.hide,
|
||||||
|
icon: 'ti ti-eye-off',
|
||||||
|
action: () => {
|
||||||
|
hide.value = true;
|
||||||
|
},
|
||||||
|
}];
|
||||||
|
|
||||||
|
if ($i?.id === props.image.userId || iAmModerator) {
|
||||||
|
menu.push({
|
||||||
|
type: 'divider',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iAmModerator) {
|
||||||
|
menu.push({
|
||||||
|
text: props.image.isSensitive ? i18n.ts.unmarkAsSensitive : i18n.ts.markAsSensitive,
|
||||||
|
icon: props.image.isSensitive ? 'ti ti-eye' : 'ti ti-eye-exclamation',
|
||||||
|
danger: true,
|
||||||
|
action: () => toggleSensitive(props.image),
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($i?.id !== props.image.userId) {
|
||||||
|
menu.push({
|
||||||
|
type: 'link' as const,
|
||||||
|
text: i18n.ts._fileViewer.title,
|
||||||
|
icon: 'ti ti-info-circle',
|
||||||
|
to: `/admin/file/${props.image.id}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($i?.id === props.image.userId) {
|
||||||
|
menu.push({
|
||||||
|
type: 'link' as const,
|
||||||
|
text: i18n.ts._fileViewer.title,
|
||||||
|
icon: 'ti ti-info-circle',
|
||||||
|
to: `/my/drive/file/${props.image.id}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
os.popupMenu(menu, ev.currentTarget ?? ev.target);
|
||||||
|
}
|
||||||
|
|
||||||
function showHiddenContent(ev: MouseEvent) {
|
function showHiddenContent(ev: MouseEvent) {
|
||||||
if (!props.controls) {
|
if (!props.controls) {
|
||||||
return;
|
return;
|
||||||
@ -103,6 +149,13 @@ function showHiddenContent(ev: MouseEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleSensitive(file: Misskey.entities.DriveFile) {
|
||||||
|
os.apiWithDialog('drive/files/update', {
|
||||||
|
fileId: file.id,
|
||||||
|
isSensitive: !file.isSensitive,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Plugin:register_note_view_interruptor を使って書き換えられる可能性があるためwatchする
|
// Plugin:register_note_view_interruptor を使って書き換えられる可能性があるためwatchする
|
||||||
watch(() => props.image, () => {
|
watch(() => props.image, () => {
|
||||||
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.image.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.image.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
||||||
@ -110,31 +163,6 @@ watch(() => props.image, () => {
|
|||||||
deep: true,
|
deep: true,
|
||||||
immediate: 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>
|
||||||
|
@ -112,9 +112,7 @@ const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.data
|
|||||||
const menuShowing = ref(false);
|
const menuShowing = ref(false);
|
||||||
|
|
||||||
function showMenu(ev: MouseEvent) {
|
function showMenu(ev: MouseEvent) {
|
||||||
let menu: MenuItem[] = [];
|
const menu: MenuItem[] = [
|
||||||
|
|
||||||
menu = [
|
|
||||||
// TODO: 再生キューに追加
|
// TODO: 再生キューに追加
|
||||||
{
|
{
|
||||||
text: i18n.ts.hide,
|
text: i18n.ts.hide,
|
||||||
@ -125,6 +123,12 @@ function showMenu(ev: MouseEvent) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($i?.id === props.video.userId || iAmModerator) {
|
||||||
|
menu.push({
|
||||||
|
type: 'divider',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (iAmModerator) {
|
if (iAmModerator) {
|
||||||
menu.push({
|
menu.push({
|
||||||
text: props.video.isSensitive ? i18n.ts.unmarkAsSensitive : i18n.ts.markAsSensitive,
|
text: props.video.isSensitive ? i18n.ts.unmarkAsSensitive : i18n.ts.markAsSensitive,
|
||||||
@ -132,12 +136,19 @@ function showMenu(ev: MouseEvent) {
|
|||||||
danger: true,
|
danger: true,
|
||||||
action: () => toggleSensitive(props.video),
|
action: () => toggleSensitive(props.video),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ($i?.id !== props.video.userId) {
|
||||||
|
menu.push({
|
||||||
|
type: 'link' as const,
|
||||||
|
text: i18n.ts._fileViewer.title,
|
||||||
|
icon: 'ti ti-info-circle',
|
||||||
|
to: `/admin/file/${props.video.id}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i?.id === props.video.userId) {
|
if ($i?.id === props.video.userId) {
|
||||||
menu.push({
|
menu.push({
|
||||||
type: 'divider',
|
|
||||||
}, {
|
|
||||||
type: 'link' as const,
|
type: 'link' as const,
|
||||||
text: i18n.ts._fileViewer.title,
|
text: i18n.ts._fileViewer.title,
|
||||||
icon: 'ti ti-info-circle',
|
icon: 'ti ti-info-circle',
|
||||||
|
Loading…
Reference in New Issue
Block a user