From f7f7698403670839ea256cc6494e4e5daf676841 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Thu, 15 Feb 2024 02:09:44 +0800 Subject: [PATCH] refactor: #204 --- .../LongCoverCard/LongCoverCard.vue | 19 +++++---- .../TopBar/components/HistoryPop.vue | 39 +++++++++---------- .../TopBar/components/MomentsPop.vue | 32 +++++++-------- src/components/VideoCard/VideoCard.vue | 36 ++++++++--------- .../views/Favorites/Favorites.vue | 3 +- src/contentScripts/views/History/History.vue | 28 +++++-------- .../views/WatchLater/WatchLater.vue | 14 +++---- src/utils/main.ts | 3 +- 8 files changed, 77 insertions(+), 97 deletions(-) diff --git a/src/components/LongCoverCard/LongCoverCard.vue b/src/components/LongCoverCard/LongCoverCard.vue index 5160b57b..2a711b9d 100644 --- a/src/components/LongCoverCard/LongCoverCard.vue +++ b/src/components/LongCoverCard/LongCoverCard.vue @@ -18,20 +18,20 @@ defineProps<{ diff --git a/src/components/TopBar/components/HistoryPop.vue b/src/components/TopBar/components/HistoryPop.vue index d33f2c3b..37caf46c 100644 --- a/src/components/TopBar/components/HistoryPop.vue +++ b/src/components/TopBar/components/HistoryPop.vue @@ -5,7 +5,7 @@ import { onMounted, reactive, ref, watch } from 'vue' import { useDateFormat } from '@vueuse/core' import type { HistoryItem } from '../types' import { HistoryType } from '../types' -import { removeHttpFromUrl, smoothScrollToTop } from '~/utils/main' +import { isHomePage, removeHttpFromUrl, smoothScrollToTop } from '~/utils/main' import { calcCurrentTime } from '~/utils/dataFormatter' const { t } = useI18n() @@ -199,7 +199,10 @@ function getHistoryList(type: HistoryType, viewAt = 0 as number) { {{ tab.name }} - + {{ $t('common.view_all') }} @@ -208,7 +211,7 @@ function getHistoryList(type: HistoryType, viewAt = 0 as number) {
- + - + -
+
- + diff --git a/src/components/TopBar/components/MomentsPop.vue b/src/components/TopBar/components/MomentsPop.vue index 42128575..fc2922bd 100644 --- a/src/components/TopBar/components/MomentsPop.vue +++ b/src/components/TopBar/components/MomentsPop.vue @@ -5,7 +5,7 @@ import { onMounted, reactive, ref, watch } from 'vue' import { isNewArticle, isNewVideo, setLastestOffsetID } from '../notify' import { MomentType } from '../types' import type { MomentItem } from '../types' -import { getCSRF, getUserID, smoothScrollToTop } from '~/utils/main' +import { getCSRF, getUserID, isHomePage, smoothScrollToTop } from '~/utils/main' import { calcTimeSince } from '~/utils/dataFormatter' const { t } = useI18n() @@ -308,7 +308,10 @@ function toggleWatchLater(aid: number) { {{ tab.name }}
- + {{ $t('common.view_all') }} @@ -317,7 +320,7 @@ function toggleWatchLater(aid: number) {
- @@ -342,17 +341,12 @@ function toggleWatchLater(aid: number) { @@ -373,7 +367,7 @@ function toggleWatchLater(aid: number) { ? `https://space.bilibili.com/${moment.uid}` : moment.url " - target="_blank" + :target="isHomePage() ? '_blank' : '_self'" rel="noopener noreferrer" > -
+ @@ -314,10 +315,8 @@ function handelMouseLeave() { - - {{ title }} + + {{ title }} + diff --git a/src/contentScripts/views/Favorites/Favorites.vue b/src/contentScripts/views/Favorites/Favorites.vue index 476c230d..b1f43be7 100644 --- a/src/contentScripts/views/Favorites/Favorites.vue +++ b/src/contentScripts/views/Favorites/Favorites.vue @@ -195,7 +195,6 @@ function handleUnfavorite(favoriteResource: FavoriteResource) { diff --git a/src/contentScripts/views/History/History.vue b/src/contentScripts/views/History/History.vue index 15b25863..043ce6c7 100644 --- a/src/contentScripts/views/History/History.vue +++ b/src/contentScripts/views/History/History.vue @@ -261,12 +261,12 @@ function jumpToLoginPage() {
- +

- {{ - historyItem.show_title - ? historyItem.show_title - : historyItem.title - }} + {{ historyItem.show_title ? historyItem.show_title : historyItem.title }}

diff --git a/src/contentScripts/views/WatchLater/WatchLater.vue b/src/contentScripts/views/WatchLater/WatchLater.vue index 57d516db..9a1154b6 100644 --- a/src/contentScripts/views/WatchLater/WatchLater.vue +++ b/src/contentScripts/views/WatchLater/WatchLater.vue @@ -117,11 +117,9 @@ function jumpToLoginPage() {
{{ item.title }} @@ -214,8 +211,7 @@ function jumpToLoginPage() { hover:bg="$bew-theme-color-10" duration-300 pr-2 - :href="`//space.bilibili.com/${item.owner.mid}`" target="_blank" - @click.stop="" + :href="`//space.bilibili.com/${item.owner.mid}`" target="_blank" rel="noopener noreferrer" > diff --git a/src/utils/main.ts b/src/utils/main.ts index 39696e40..45fd492c 100644 --- a/src/utils/main.ts +++ b/src/utils/main.ts @@ -8,6 +8,7 @@ export function getCookie(name: string): string { const parts: Array = value.split(`; ${name}=`) if (parts.length === 2) return parts?.pop()?.split(';').shift() || '' + return '' } /** @@ -43,7 +44,7 @@ export function removeHttpFromUrl(url: string): string { } export function openLinkToNewTab(url: string) { - window.open(url, '_blank') + window.open(url, '_blank', 'noopener noreferrer') } /**