From c3ad3c0ce1f2496e2d51f500264ffdc9634e2803 Mon Sep 17 00:00:00 2001 From: pany <939630029@qq.com> Date: Fri, 30 Jun 2023 18:05:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BC=93=E5=AD=98=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=A0=8F=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E5=B1=9E=E6=80=A7=EF=BC=8C?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=20JSON.stringify=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=88=B0=E5=BE=AA=E7=8E=AF=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/cache/local-storage.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/cache/local-storage.ts b/src/utils/cache/local-storage.ts index 2f4cade..847a695 100644 --- a/src/utils/cache/local-storage.ts +++ b/src/utils/cache/local-storage.ts @@ -43,6 +43,11 @@ export const getVisitedViews = () => { return JSON.parse(json ?? "[]") as TagView[] } export const setVisitedViews = (views: TagView[]) => { + views.forEach((view) => { + // 删除不必要的属性,防止 JSON.stringify 处理到循环引用 + delete view.matched + delete view.redirectedFrom + }) localStorage.setItem(CacheKey.VISITED_VIEWS, JSON.stringify(views)) } export const getCachedViews = () => {