Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ need_check=0
while read local_ref local_sha remote_ref remote_sha; do
branch=$(echo "$remote_ref" | sed 's|refs/heads/||')

if [ "$branch" = "main" ] || echo "$branch" | grep -q "^release"; then
if [ "$branch" = "main" ] || echo "$branch" | grep -q "^release/"; then
need_check=1
echo "🔍 Detected push target: $branch"
fi
Expand Down
5 changes: 5 additions & 0 deletions src/locales/de-DE/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@
"maybe_later": "Vielleicht später",
"settings_hint": "Sie können diese Option jederzeit in den Einstellungen ändern."
},
"favicon_service": "Favicon-Dienst",
"favicon_service_desc": "Dienst zum Abrufen von Website-Symbolen auswählen",
"favicon_service_scriptcat": "ScriptCat",
"favicon_service_local": "Lokal abrufen",
"favicon_service_google": "Google",
"editor": {
"show_script_list": "Skriptliste anzeigen",
"hide_script_list": "Skriptliste ausblenden"
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@
"maybe_later": "Maybe Later",
"settings_hint": "You can change this option in settings at any time."
},
"favicon_service": "Favicon Service",
"favicon_service_desc": "Choose the service for fetching website icons",
"favicon_service_scriptcat": "ScriptCat",
"favicon_service_local": "Local Fetch",
"favicon_service_google": "Google",
"editor": {
"show_script_list": "Show Script List",
"hide_script_list": "Hide Script List"
Expand Down
5 changes: 5 additions & 0 deletions src/locales/ja-JP/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@
"maybe_later": "後で",
"settings_hint": "設定ページでいつでも変更できます。"
},
"favicon_service": "Favicon サービス",
"favicon_service_desc": "ウェブサイトアイコンの取得サービスを選択",
"favicon_service_scriptcat": "ScriptCat",
"favicon_service_local": "ローカル取得",
"favicon_service_google": "Google",
"editor": {
"show_script_list": "スクリプトリストを表示",
"hide_script_list": "スクリプトリストを非表示"
Expand Down
5 changes: 5 additions & 0 deletions src/locales/ru-RU/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@
"maybe_later": "Может быть позже",
"settings_hint": "Вы можете изменить эту опцию в настройках в любое время."
},
"favicon_service": "Сервис Favicon",
"favicon_service_desc": "Выберите сервис для получения значков сайтов",
"favicon_service_scriptcat": "ScriptCat",
"favicon_service_local": "Локальное получение",
"favicon_service_google": "Google",
"editor": {
"show_script_list": "Показать список скриптов",
"hide_script_list": "Скрыть список скриптов"
Expand Down
5 changes: 5 additions & 0 deletions src/locales/vi-VN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@
"maybe_later": "Để sau",
"settings_hint": "Bạn có thể thay đổi tùy chọn này trong cài đặt bất kỳ lúc nào."
},
"favicon_service": "Dịch vụ Favicon",
"favicon_service_desc": "Chọn dịch vụ để lấy biểu tượng trang web",
"favicon_service_scriptcat": "ScriptCat",
"favicon_service_local": "Lấy cục bộ",
"favicon_service_google": "Google",
"editor": {
"show_script_list": "Hiển thị danh sách script",
"hide_script_list": "Ẩn danh sách script"
Expand Down
5 changes: 5 additions & 0 deletions src/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@
"maybe_later": "暂不启用",
"settings_hint": "你可以随时在设置中修改此选项。"
},
"favicon_service": "图标服务",
"favicon_service_desc": "选择获取网站图标的服务",
"favicon_service_scriptcat": "ScriptCat",
"favicon_service_local": "本地获取",
"favicon_service_google": "Google",
"editor": {
"show_script_list": "显示脚本列表",
"hide_script_list": "隐藏脚本列表"
Expand Down
5 changes: 5 additions & 0 deletions src/locales/zh-TW/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@
"maybe_later": "暫不啟用",
"settings_hint": "你可以隨時在設定中修改此選項。"
},
"favicon_service": "圖示服務",
"favicon_service_desc": "選擇取得網站圖示的服務",
"favicon_service_scriptcat": "ScriptCat",
"favicon_service_local": "本地取得",
"favicon_service_google": "Google",
"editor": {
"show_script_list": "顯示腳本列表",
"hide_script_list": "隱藏腳本列表"
Expand Down
4 changes: 3 additions & 1 deletion src/pages/options/routes/ScriptList/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "@App/app/repo/scripts";
import { fetchScript, fetchScriptList } from "@App/pages/store/features/script";
import { loadScriptFavicons } from "@App/pages/store/favicons";
import { systemConfig } from "@App/pages/store/global";
import { parseTags } from "@App/app/repo/metadata";
import { getCombinedMeta } from "@App/app/service/service_worker/utils";
import { cacheInstance } from "@App/app/cache";
Expand Down Expand Up @@ -76,7 +77,8 @@ export function useScriptDataManagement() {
setLoadingList(false);
cacheInstance.tx("faviconOPFSControl", async () => {
if (!mounted) return;
for await (const { chunkResults } of loadScriptFavicons(list)) {
const faviconService = await systemConfig.getFaviconService();
for await (const { chunkResults } of loadScriptFavicons(list, faviconService)) {
if (!mounted) return;
setScriptList((prev) => {
const favMap = new Map(chunkResults.map((r) => [r.uuid, r]));
Expand Down
37 changes: 37 additions & 0 deletions src/pages/options/routes/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import CustomTrans from "@App/pages/components/CustomTrans";
import { useSystemConfig } from "./utils";
import { subscribeMessage } from "@App/pages/store/global";
import { SystemConfigChange, type SystemConfigKey } from "@App/pkg/config/config";
import { FaviconDAO } from "@App/app/repo/favicon";
import { clearFaviconMemoryCache } from "@App/pages/store/favicons";
import { type TKeyValue } from "@Packages/message/message_queue";
import { useEffect, useMemo } from "react";
import { systemConfig } from "@App/pages/store/global";
Expand All @@ -41,6 +43,7 @@ function Setting() {
const [badgeTextColor, setBadgeTextColor, submitBadgeTextColor] = useSystemConfig("badge_text_color");
const [scriptMenuDisplayType, setScriptMenuDisplayType, submitScriptMenuDisplayType] =
useSystemConfig("script_menu_display_type");
const [faviconService, setFaviconService, submitFaviconService] = useSystemConfig("favicon_service");

const [editorTypeDefinition, setEditorTypeDefinition, submitEditorTypeDefinition] =
useSystemConfig("editor_type_definition");
Expand Down Expand Up @@ -81,6 +84,7 @@ function Setting() {
badge_background_color: setBadgeBackgroundColor,
badge_text_color: setBadgeTextColor,
script_menu_display_type: setScriptMenuDisplayType,
favicon_service: setFaviconService,
editor_type_definition: setEditorTypeDefinition,
} as const;
const hookMgr = new HookManager();
Expand Down Expand Up @@ -306,6 +310,39 @@ function Setting() {
</div>
</Space>
</div>

{/* Favicon 服务 */}
<div className="tw-flex tw-items-center tw-justify-between tw-min-h-9">
<div className="tw-flex tw-items-center tw-gap-4 tw-flex-1">
<span className="tw-min-w-20">{t("favicon_service")}</span>
<Select
value={faviconService}
className="tw-w-40 tw-max-w-50"
onChange={async (value) => {
submitFaviconService(value);
// 清除 favicon 缓存
try {
const faviconDAO = new FaviconDAO();
const allFavicons = await faviconDAO.find();
await faviconDAO.deletes(allFavicons.map((f) => f.uuid));
// 清除 OPFS 缓存:删除并重建目录
const opfsRoot = await navigator.storage.getDirectory();
await opfsRoot.removeEntry("cached_favicons", { recursive: true }).catch(() => {});
// 清除内存中的 blob URL 缓存
clearFaviconMemoryCache();
} catch {
// 忽略清除缓存的错误
}
Message.success(t("save_success")!);
}}
>
<Select.Option value="scriptcat">{t("favicon_service_scriptcat")}</Select.Option>
<Select.Option value="google">{t("favicon_service_google")}</Select.Option>
<Select.Option value="local">{t("favicon_service_local")}</Select.Option>
</Select>
</div>
<span className="tw-text-xs tw-ml-6 tw-flex-shrink-0">{t("favicon_service_desc")}</span>
</div>
</Space>
</Card>

Expand Down
Loading
Loading