From 61159a88ef947c03bdf85d96d288ff2d710b7b08 Mon Sep 17 00:00:00 2001 From: kjqwer <2990346238@qq.com> Date: Sat, 4 Oct 2025 07:06:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=85=E7=9C=8B=E5=90=8D=E5=8D=95=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=BE=85=E7=9C=8B=E5=90=8D=E5=8D=95=E6=AF=94=E8=BE=83?= =?UTF-8?q?=E5=8F=97baseurl=E5=BD=B1=E5=93=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/common/WatchlistWidget.vue | 32 +--- .../common/watchlist/WatchlistPanel.vue | 73 ++++++++- ui/src/stores/watchlist.ts | 144 +++++++++++++++--- 3 files changed, 201 insertions(+), 48 deletions(-) diff --git a/ui/src/components/common/WatchlistWidget.vue b/ui/src/components/common/WatchlistWidget.vue index eafc65d..76f7b02 100644 --- a/ui/src/components/common/WatchlistWidget.vue +++ b/ui/src/components/common/WatchlistWidget.vue @@ -198,33 +198,11 @@ const getAddButtonTitle = () => { const isCurrentUrl = (url: string) => { const currentUrl = currentPageUrl.value; - // 直接比较完整URL - if (currentUrl === url) { - return true; - } - - // 比较路径部分 - try { - const currentUrlObj = new URL(currentUrl); - const currentPath = currentUrlObj.pathname + currentUrlObj.search; - - // 如果是完整URL,提取路径部分比较 - if (url.startsWith('http://') || url.startsWith('https://')) { - const urlObj = new URL(url); - const urlPath = urlObj.pathname + urlObj.search; - return currentPath === urlPath; - } - - // 如果是相对路径,直接比较 - let relativePath = url; - if (!relativePath.startsWith('/')) { - relativePath = '/' + relativePath; - } - - return currentPath === relativePath; - } catch { - return false; - } + // 使用store中的路径提取方法进行比较 + const currentPath = watchlistStore.extractUrlPath(currentUrl); + const itemPath = watchlistStore.extractUrlPath(url); + + return currentPath === itemPath; }; // 解析批量URL diff --git a/ui/src/components/common/watchlist/WatchlistPanel.vue b/ui/src/components/common/watchlist/WatchlistPanel.vue index f0dc7a2..42a255b 100644 --- a/ui/src/components/common/watchlist/WatchlistPanel.vue +++ b/ui/src/components/common/watchlist/WatchlistPanel.vue @@ -4,6 +4,19 @@

待看名单

{{ itemCount }} 项 + + + @@ -27,6 +40,8 @@