diff --git a/src/components/PipWindow.vue b/src/components/PipWindow.vue new file mode 100644 index 00000000..857659c3 --- /dev/null +++ b/src/components/PipWindow.vue @@ -0,0 +1,170 @@ + + + + + + + + + + + {{ $t('iframe_drawer.open_in_new_tab') }} + + + + + + + {{ $t('iframe_drawer.close') }} + + + + + + + {{ $t('iframe_drawer.press_esc_again_to_close') }} + + + + + + + diff --git a/src/components/VideoCard/VideoCard.vue b/src/components/VideoCard/VideoCard.vue index 48e12167..4aa98fb2 100644 --- a/src/components/VideoCard/VideoCard.vue +++ b/src/components/VideoCard/VideoCard.vue @@ -66,9 +66,8 @@ export interface Video { } const toast = useToast() -const { mainAppRef } = useBewlyApp() +const { mainAppRef, openIframeDrawer } = useBewlyApp() const api = useApiClient() -const { openIframeDrawer } = useBewlyApp() const showVideoOptions = ref(false) const videoOptionsFloatingStyles = ref({}) // Whether the user has marked it as disliked @@ -250,7 +249,7 @@ function handleUndo() { } } -function handleRemoved(selectedOpt: { dislikeReasonId: number }) { +function handleRemoved(selectedOpt?: { dislikeReasonId: number }) { selectedDislikeOpt.value = selectedOpt removed.value = true } @@ -582,7 +581,11 @@ function handleRemoved(selectedOpt: { dislikeReasonId: number }) { > import type { CSSProperties } from 'vue' +import { useBewlyApp } from '~/composables/useAppProvider' import { settings } from '~/logic' import { Type as ThreePointV2Type } from '~/models/video/appForYou' import type { Video } from '../VideoCard.vue' import DislikeDialog from './components/DislikeDialog.vue' -defineProps<{ +const props = defineProps<{ video: Video contextMenuStyles: CSSProperties }>() @@ -21,8 +22,32 @@ const videoOptions = reactive<{ id: number, name: string }[]>([ { id: 1, name: '不感兴趣' }, { id: 2, name: '不想看此UP主' }, ]) + const showContextMenu = ref(false) const showDislikeDialog = ref(false) +const showPipWindow = ref(false) +const { openIframeDrawer } = useBewlyApp() + +enum VideoOption { + OpenInNewTab, + OpenInNewWindow, + OpenInDrawer, + ViewTheOriginalCover, +} + +const commonOptions = computed((): { command: VideoOption, name: string, icon: string, color?: string }[][] => { + return [ + [ + { command: VideoOption.OpenInNewTab, name: 'Open in new tab', icon: 'i-solar:square-top-down-bold-duotone' }, + { command: VideoOption.OpenInNewWindow, name: 'Open in new window', icon: 'i-solar:maximize-square-3-bold-duotone' }, + { command: VideoOption.OpenInDrawer, name: 'Open in drawer', icon: 'i-solar:archive-up-minimlistic-bold-duotone' }, + ], + + [ + { command: VideoOption.ViewTheOriginalCover, name: 'View the original cover', icon: 'i-solar:gallery-minimalistic-bold-duotone' }, + ], + ] +}) onMounted(() => { showContextMenu.value = true @@ -42,6 +67,27 @@ function handleAppMoreCommand(command: ThreePointV2Type) { } } +function handleCommonCommand(command: VideoOption) { + switch (command) { + case VideoOption.OpenInNewTab: + window.open(props.video.url, '_blank') + handleClose() + break + case VideoOption.OpenInNewWindow: + showPipWindow.value = true + break + case VideoOption.OpenInDrawer: + openIframeDrawer(props.video.url || '') + handleClose() + break + + case VideoOption.ViewTheOriginalCover: + window.open(props.video.cover, '_blank') + handleClose() + break + } +} + function openAppDislikeDialog() { showDislikeDialog.value = true showContextMenu.value = false @@ -49,9 +95,8 @@ function openAppDislikeDialog() { function handleClose() { showContextMenu.value = false + showPipWindow.value = false emit('close') - nextTick(() => { - }) } function handleRemoved(selectedOpt?: { dislikeReasonId: number }) { @@ -96,6 +141,20 @@ function handleRemoved(selectedOpt?: { dislikeReasonId: number }) { {{ option.name }} + + + + + + + {{ option.name }} + + @@ -114,6 +173,12 @@ function handleRemoved(selectedOpt?: { dislikeReasonId: number }) { @close="handleClose" @removed="handleRemoved" /> + + @@ -124,6 +189,10 @@ function handleRemoved(selectedOpt?: { dislikeReasonId: number }) { } .item-icon { - --uno: "mr-2 inline-block"; + --uno: "mr-2 inline-block color-$bew-text-color-2"; +} + +.divider { + --uno: "w-full h-1px my-1 bg-$bew-border-color"; } diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue index aba50492..cd8655c2 100644 --- a/src/contentScripts/views/App.vue +++ b/src/contentScripts/views/App.vue @@ -231,7 +231,7 @@ provide('BEWLY_APP', {