From ec6a84150bb5344c5cbfb97a3a4a4d0f36a9eb5e Mon Sep 17 00:00:00 2001 From: Hakadao Date: Sun, 23 Feb 2025 17:20:09 +0800 Subject: [PATCH] feat(notifications-drawer): improve notifications drawer experiences --- src/components/TopBar/TopBar.vue | 12 ++++--- .../TopBar/components/NotificationsDrawer.vue | 34 ++++++++++++++----- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index 8bc43ec0..00cf1ce5 100644 --- a/src/components/TopBar/TopBar.vue +++ b/src/components/TopBar/TopBar.vue @@ -928,11 +928,13 @@ defineExpose({ - + + + diff --git a/src/components/TopBar/components/NotificationsDrawer.vue b/src/components/TopBar/components/NotificationsDrawer.vue index b1064295..2705f72e 100644 --- a/src/components/TopBar/components/NotificationsDrawer.vue +++ b/src/components/TopBar/components/NotificationsDrawer.vue @@ -7,7 +7,7 @@ import { settings } from '~/logic' // TODO: support shortcuts like `Ctrl+Alt+T` to open in new tab, `Esc` to close const props = defineProps<{ - url?: string + url: string }>() const emit = defineEmits<{ @@ -17,19 +17,30 @@ const emit = defineEmits<{ const { mainAppRef } = useBewlyApp() const show = ref(false) -const headerShow = ref(false) const iframeRef = ref(null) const currentUrl = ref(props.url || 'https://message.bilibili.com/') const showIframe = ref(false) const delayCloseTimer = ref(null) onMounted(() => { + handleOpen() +}) + +onActivated(() => { + handleOpen() +}) + +const beforeUrl = ref('') +function handleOpen() { show.value = true - headerShow.value = true + if (beforeUrl.value !== props.url) { + currentUrl.value = props.url + beforeUrl.value = props.url + } nextTick(() => { iframeRef.value?.focus() }) -}) +} onBeforeUnmount(() => { releaseIframeResources() @@ -39,9 +50,8 @@ async function handleClose() { if (delayCloseTimer.value) { clearTimeout(delayCloseTimer.value) } - await releaseIframeResources() + // await releaseIframeResources() show.value = false - headerShow.value = false delayCloseTimer.value = setTimeout(() => { emit('close') }, 300) @@ -125,6 +135,7 @@ nextTick(() => {