From d009e4c9582820e5a88196ff93f3dccf58927434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Mon, 22 Dec 2025 17:35:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20=E5=88=A0=E9=99=A4=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=9B=BE=E6=A0=87=E7=9A=84=E8=83=8C=E6=99=AF=E8=89=B2?= =?UTF-8?q?=E5=92=8C=E8=BE=B9=E6=A1=86=20#1052?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/install/App.tsx | 8 ++------ src/pages/options/routes/ScriptList/components.tsx | 2 +- src/pages/options/routes/utils.tsx | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/pages/install/App.tsx b/src/pages/install/App.tsx index 94e9fe840..5770bf2b8 100644 --- a/src/pages/install/App.tsx +++ b/src/pages/install/App.tsx @@ -1,5 +1,4 @@ import { - Avatar, Button, Dropdown, Message, @@ -33,6 +32,7 @@ import { useSearchParams } from "react-router-dom"; import { CACHE_KEY_SCRIPT_INFO } from "@App/app/cache_key"; import { cacheInstance } from "@App/app/cache"; import { formatBytes, prettyUrl } from "@App/pkg/utils/utils"; +import { ScriptIcons } from "../options/routes/utils"; const backgroundPromptShownKey = "background_prompt_shown"; @@ -766,11 +766,7 @@ function App() {
- {upsertScript?.metadata.icon && ( - - {upsertScript.name} - - )} + {upsertScript?.metadata.icon && } {upsertScript && ( diff --git a/src/pages/options/routes/ScriptList/components.tsx b/src/pages/options/routes/ScriptList/components.tsx index 44e085884..a60fc8c23 100644 --- a/src/pages/options/routes/ScriptList/components.tsx +++ b/src/pages/options/routes/ScriptList/components.tsx @@ -39,7 +39,7 @@ export const MemoizedAvatar = React.memo( shape="square" style={{ backgroundColor: "unset", - borderWidth: 1, + borderWidth: 0, }} className={website ? "tw-cursor-pointer" : "tw-cursor-default"} {...rest} diff --git a/src/pages/options/routes/utils.tsx b/src/pages/options/routes/utils.tsx index 66ea66c11..2c34fca17 100644 --- a/src/pages/options/routes/utils.tsx +++ b/src/pages/options/routes/utils.tsx @@ -169,6 +169,7 @@ export function ScriptIcons({ script, size = 32, style }: ScriptIconsProps) { style = style || {}; style.display = style.display || "inline-block"; style.marginRight = style.marginRight || "8px"; + style.backgroundColor = style.backgroundColor || "unset"; const m = script.metadata; const [icon] = m.icon || m.iconurl || m.icon64 || m.icon64url || []; if (icon) { From b4e7ad5444c59fe72476c614ecbade4a834b75a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Mon, 22 Dec 2025 17:43:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=9B=9E=E9=80=80=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../options/routes/ScriptList/components.tsx | 36 +++++++++++-------- src/pages/options/routes/utils.tsx | 5 +-- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/pages/options/routes/ScriptList/components.tsx b/src/pages/options/routes/ScriptList/components.tsx index a60fc8c23..42496f243 100644 --- a/src/pages/options/routes/ScriptList/components.tsx +++ b/src/pages/options/routes/ScriptList/components.tsx @@ -2,7 +2,7 @@ import type { SCRIPT_STATUS } from "@App/app/repo/scripts"; import { SCRIPT_STATUS_ENABLE } from "@App/app/repo/scripts"; import { scriptClient, type ScriptLoading } from "@App/pages/store/features/script"; import { Avatar, Input, Message, Select, Space, Switch, Tag, Tooltip, Typography } from "@arco-design/web-react"; -import React from "react"; +import React, { useState } from "react"; import { TbWorldWww } from "react-icons/tb"; import { semTime } from "@App/pkg/utils/dayjs"; import { useTranslation } from "react-i18next"; @@ -34,19 +34,27 @@ EnableSwitch.displayName = "EnableSwitch"; // Memoized Avatar component to prevent unnecessary re-renders export const MemoizedAvatar = React.memo( - ({ match, icon, website, ...rest }: { match: string; icon?: string; website?: string; [key: string]: any }) => ( - - {icon ? : } - - ), + ({ match, icon, website, ...rest }: { match: string; icon?: string; website?: string; [key: string]: any }) => { + const [imageError, setImageError] = useState(false); + + return ( + + {icon && !imageError ? ( + setImageError(true)} /> + ) : ( + + )} + + ); + }, (prevProps, nextProps) => { return ( prevProps.match === nextProps.match && diff --git a/src/pages/options/routes/utils.tsx b/src/pages/options/routes/utils.tsx index 2c34fca17..9ce52dd42 100644 --- a/src/pages/options/routes/utils.tsx +++ b/src/pages/options/routes/utils.tsx @@ -166,16 +166,17 @@ export type ScriptIconsProps = { }; export function ScriptIcons({ script, size = 32, style }: ScriptIconsProps) { + const [imageError, setImageError] = useState(false); style = style || {}; style.display = style.display || "inline-block"; style.marginRight = style.marginRight || "8px"; style.backgroundColor = style.backgroundColor || "unset"; const m = script.metadata; const [icon] = m.icon || m.iconurl || m.icon64 || m.icon64url || []; - if (icon) { + if (icon && !imageError) { return ( - {script?.name} + {script?.name} setImageError(true)} /> ); } From 653d1947e4dab5380d0f36d567870da6b99b3e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Wed, 24 Dec 2025 16:11:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=8C=E6=AC=A1?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=97=B6=E5=9B=BE=E6=A0=87=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/options/routes/ScriptList/components.tsx | 10 ++-------- src/pages/store/favicons.ts | 9 --------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/pages/options/routes/ScriptList/components.tsx b/src/pages/options/routes/ScriptList/components.tsx index 42496f243..b3085d71d 100644 --- a/src/pages/options/routes/ScriptList/components.tsx +++ b/src/pages/options/routes/ScriptList/components.tsx @@ -2,7 +2,7 @@ import type { SCRIPT_STATUS } from "@App/app/repo/scripts"; import { SCRIPT_STATUS_ENABLE } from "@App/app/repo/scripts"; import { scriptClient, type ScriptLoading } from "@App/pages/store/features/script"; import { Avatar, Input, Message, Select, Space, Switch, Tag, Tooltip, Typography } from "@arco-design/web-react"; -import React, { useState } from "react"; +import React from "react"; import { TbWorldWww } from "react-icons/tb"; import { semTime } from "@App/pkg/utils/dayjs"; import { useTranslation } from "react-i18next"; @@ -35,8 +35,6 @@ EnableSwitch.displayName = "EnableSwitch"; // Memoized Avatar component to prevent unnecessary re-renders export const MemoizedAvatar = React.memo( ({ match, icon, website, ...rest }: { match: string; icon?: string; website?: string; [key: string]: any }) => { - const [imageError, setImageError] = useState(false); - return ( - {icon && !imageError ? ( - setImageError(true)} /> - ) : ( - - )} + {icon ? : } ); }, diff --git a/src/pages/store/favicons.ts b/src/pages/store/favicons.ts index 7297be50a..45802b0a5 100644 --- a/src/pages/store/favicons.ts +++ b/src/pages/store/favicons.ts @@ -1,6 +1,4 @@ import { type Script, ScriptDAO } from "@App/app/repo/scripts"; -import { cacheInstance } from "@App/app/cache"; -import { CACHE_KEY_FAVICON } from "@App/app/cache_key"; import { FaviconDAO, type FaviconFile, type FaviconRecord } from "@App/app/repo/favicon"; import { v5 as uuidv5 } from "uuid"; import { getFaviconRootFolder } from "@App/app/service/service_worker/utils"; @@ -225,12 +223,6 @@ export const loadFavicon = async (iconUrl: string): Promise => { const directoryHandle = await getFaviconRootFolder(); // 使用url的uuid作为文件名 const filename = `icon_${uuidv5(iconUrl, uuidv5.URL)}.dat`; - try { - const sessionBlobUrl = await cacheInstance.get(`${CACHE_KEY_FAVICON}${filename}`); - if (sessionBlobUrl) return sessionBlobUrl; - } catch { - // 即使报错也不影响 - } // 检查文件是否存在 let fileHandle: FileSystemFileHandle | undefined; try { @@ -251,7 +243,6 @@ export const loadFavicon = async (iconUrl: string): Promise => { const opfsRet = { dirs: ["cached_favicons"], filename: filename }; const file = await getFileFromOPFS(opfsRet); const blobUrl = URL.createObjectURL(file); - cacheInstance.set(`${CACHE_KEY_FAVICON}${filename}`, blobUrl); // 不用等待。针对SW重启 - blobURL 的生命周期依附于页面 return blobUrl; };