From 537c44df2e990f25aabc264f0ff3e3fe50b57e9b Mon Sep 17 00:00:00 2001 From: Renji Yuusei <166010224+RenjiYuusei@users.noreply.github.com> Date: Fri, 31 Oct 2025 00:06:41 +0700 Subject: [PATCH 1/7] Treat zero menu limit as unlimited in popup --- src/pages/components/ScriptMenuList/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/components/ScriptMenuList/index.tsx b/src/pages/components/ScriptMenuList/index.tsx index b40ed8708..a460cda99 100644 --- a/src/pages/components/ScriptMenuList/index.tsx +++ b/src/pages/components/ScriptMenuList/index.tsx @@ -184,14 +184,17 @@ const ListMenuItem = React.memo( setIsExpand((e) => !e); }; + const hasExpandLimit = menuExpandNum > 0; + const visibleMenus = useMemo(() => { const m = scriptMenus?.group || []; + if (!hasExpandLimit) return m; return m.length > menuExpandNum && !isExpand ? m.slice(0, menuExpandNum) : m; - }, [scriptMenus?.group, isExpand, menuExpandNum]); + }, [scriptMenus?.group, hasExpandLimit, isExpand, menuExpandNum]); const shouldShowMore = useMemo( - () => scriptMenus?.group?.length > menuExpandNum, - [scriptMenus?.group, menuExpandNum] + () => hasExpandLimit && scriptMenus?.group?.length > menuExpandNum, + [hasExpandLimit, scriptMenus?.group, menuExpandNum] ); const handleExcludeUrl = (uuid: string, excludePattern: string, isExclude: boolean) => { From 91fc82889c4dee659aa74eb760eae7a6917effee Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 26 Dec 2025 03:17:51 +0000 Subject: [PATCH 2/7] Update layout to be responsive for mobile devices - Refactored sidebar menu into `SiderMenu` component - Updated `Sider` to use a Drawer on mobile (<768px) - Added hamburger button for mobile navigation - Adjusted content padding and layout for mobile view --- src/pages/components/layout/Sider.tsx | 203 ++++++++-------------- src/pages/components/layout/SiderMenu.tsx | 170 ++++++++++++++++++ 2 files changed, 240 insertions(+), 133 deletions(-) create mode 100644 src/pages/components/layout/SiderMenu.tsx diff --git a/src/pages/components/layout/Sider.tsx b/src/pages/components/layout/Sider.tsx index e225aa444..d3766c142 100644 --- a/src/pages/components/layout/Sider.tsx +++ b/src/pages/components/layout/Sider.tsx @@ -4,29 +4,13 @@ import ScriptList from "@App/pages/options/routes/ScriptList"; import Setting from "@App/pages/options/routes/Setting"; import SubscribeList from "@App/pages/options/routes/SubscribeList"; import Tools from "@App/pages/options/routes/Tools"; -import { Layout, Menu } from "@arco-design/web-react"; -import { - IconCode, - IconFile, - IconGithub, - IconLeft, - IconLink, - IconQuestion, - IconRight, - IconSettings, - IconSubscribe, - IconTool, -} from "@arco-design/web-react/icon"; -import React, { useRef, useState } from "react"; +import { Layout, Drawer, Button } from "@arco-design/web-react"; +import { IconMenu } from "@arco-design/web-react/icon"; +import React, { useRef, useState, useEffect } from "react"; import { HashRouter, Route, Routes } from "react-router-dom"; -import { useTranslation } from "react-i18next"; -import { RiFileCodeLine, RiGuideLine, RiLinkM } from "react-icons/ri"; import SiderGuide from "./SiderGuide"; -import CustomLink from "../CustomLink"; -import { localePath } from "@App/locales/locales"; -import { DocumentationSite } from "@App/app/const"; +import SiderMenu from "./SiderMenu"; -const MenuItem = Menu.Item; let { hash } = window.location; if (!hash.length) { hash = "/"; @@ -37,135 +21,88 @@ if (!hash.length) { const Sider: React.FC = () => { const [menuSelect, setMenuSelect] = useState(hash); const [collapsed, setCollapsed] = useState(localStorage.collapsed === "true"); - const { t } = useTranslation(); + const [isMobile, setIsMobile] = useState(window.innerWidth < 768); + const [drawerVisible, setDrawerVisible] = useState(false); const guideRef = useRef<{ open: () => void }>(null); - const { handleMenuClick } = { - handleMenuClick: (key: string) => { - setMenuSelect(key); - }, + useEffect(() => { + const handleResize = () => { + setIsMobile(window.innerWidth < 768); + }; + + window.addEventListener("resize", handleResize); + return () => window.removeEventListener("resize", handleResize); + }, []); + + const handleMenuClick = (key: string) => { + setMenuSelect(key); + if (isMobile) { + setDrawerVisible(false); + } }; return ( - -
- - - - {t("installed_scripts")} - - - - - {t("subscribe")} - - - - - {t("logs")} - - - - - {t("tools")} - - - - - {t("settings")} - - - - + setDrawerVisible(false)} + onCancel={() => setDrawerVisible(false)} + footer={null} + title={null} + closable={false} > - - {t("helpcenter")} - - } - triggerProps={{ - trigger: "hover", - }} - > - - {t("external_links")} - - } - > - - - {t("api_docs")} - - - - - {t("development_guide")} - - - - - {t("script_gallery")} - - - - - {t("community_forum")} - - - - - {"GitHub"} - - - - { - guideRef.current?.open(); - }} - > - {t("guide")} - - - - {t("user_guide")} - - - - { - localStorage.collapsed = !collapsed; - setCollapsed(!collapsed); - }} - > - {collapsed ? : } {t("hide_sidebar")} - - -
-
+ + + + ) : ( + + + + )} + + {isMobile && ( + + + ); + } return ( <> @@ -65,7 +96,7 @@ const FileSystemParams: React.FC<{ ))} - {actionButton.map((item) => item)} + {actionButtons.map((item) => item)} Date: Wed, 21 Jan 2026 13:49:54 +0800 Subject: [PATCH 6/7] Revert "Treat zero menu limit as unlimited in popup" --- src/pages/components/ScriptMenuList/index.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pages/components/ScriptMenuList/index.tsx b/src/pages/components/ScriptMenuList/index.tsx index a460cda99..b40ed8708 100644 --- a/src/pages/components/ScriptMenuList/index.tsx +++ b/src/pages/components/ScriptMenuList/index.tsx @@ -184,17 +184,14 @@ const ListMenuItem = React.memo( setIsExpand((e) => !e); }; - const hasExpandLimit = menuExpandNum > 0; - const visibleMenus = useMemo(() => { const m = scriptMenus?.group || []; - if (!hasExpandLimit) return m; return m.length > menuExpandNum && !isExpand ? m.slice(0, menuExpandNum) : m; - }, [scriptMenus?.group, hasExpandLimit, isExpand, menuExpandNum]); + }, [scriptMenus?.group, isExpand, menuExpandNum]); const shouldShowMore = useMemo( - () => hasExpandLimit && scriptMenus?.group?.length > menuExpandNum, - [hasExpandLimit, scriptMenus?.group, menuExpandNum] + () => scriptMenus?.group?.length > menuExpandNum, + [scriptMenus?.group, menuExpandNum] ); const handleExcludeUrl = (uuid: string, excludePattern: string, isExclude: boolean) => { From f256b5dde20a93304c3ea95e5647e88e13af9be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=80=E4=B9=8B?= Date: Wed, 21 Jan 2026 14:22:42 +0800 Subject: [PATCH 7/7] Clean code --- packages/filesystem/auth.ts | 11 ++++++++++- src/pages/components/FileSystemParams/index.tsx | 12 ++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/filesystem/auth.ts b/packages/filesystem/auth.ts index 59de88a87..328308457 100644 --- a/packages/filesystem/auth.ts +++ b/packages/filesystem/auth.ts @@ -2,6 +2,7 @@ import { ExtServer, ExtServerApi } from "@App/app/const"; import { WarpTokenError } from "./error"; import { LocalStorageDAO } from "@App/app/repo/localStorage"; import { sleep } from "@App/pkg/utils/utils"; +import type { FileSystemType } from "./factory"; export type NetDiskType = "baidu" | "onedrive" | "googledrive" | "dropbox"; @@ -128,12 +129,20 @@ export async function AuthVerify(netDiskType: NetDiskType, invalid?: boolean) { return token.accessToken; } +export const netDiskTypeMap: Partial> = { + "baidu-netdsik": "baidu", + onedrive: "onedrive", + googledrive: "googledrive", + dropbox: "dropbox", +}; + export async function ClearNetDiskToken(netDiskType: NetDiskType) { const localStorageDAO = new LocalStorageDAO(); const key = `netdisk:token:${netDiskType}`; try { await localStorageDAO.delete(key); - } catch (_) { + } catch (error) { // ignore + console.error("ClearNetDiskToken error:", error); } } diff --git a/src/pages/components/FileSystemParams/index.tsx b/src/pages/components/FileSystemParams/index.tsx index 683aa65b0..c806d08b5 100644 --- a/src/pages/components/FileSystemParams/index.tsx +++ b/src/pages/components/FileSystemParams/index.tsx @@ -3,7 +3,7 @@ import { Button, Input, Message, Popconfirm, Select, Space } from "@arco-design/ import type { FileSystemType } from "@Packages/filesystem/factory"; import FileSystemFactory from "@Packages/filesystem/factory"; import { useTranslation } from "react-i18next"; -import { ClearNetDiskToken, type NetDiskType } from "@Packages/filesystem/auth"; +import { ClearNetDiskToken, netDiskTypeMap } from "@Packages/filesystem/auth"; const FileSystemParams: React.FC<{ preNode: React.ReactNode | string; @@ -49,16 +49,12 @@ const FileSystemParams: React.FC<{ name: "Dropbox", }, ]; - const netDiskTypeMap: Partial> = { - "baidu-netdsik": "baidu", - onedrive: "onedrive", - googledrive: "googledrive", - dropbox: "dropbox", - }; + const netDiskType = netDiskTypeMap[fileSystemType]; - const netDiskName = fileSystemList.find((item) => item.key === fileSystemType)?.name; if (netDiskType) { + const netDiskName = fileSystemList.find((item) => item.key === fileSystemType)?.name; + actionButtons.push(