Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 「设置」菜单项防重复导航判定对齐 open-settings(pathname+search)
DavidShenb15fdb69da7b
diff --git a/apps/desktop/src/renderer/__tests__/menuButtonSettingsEntry.test.ts b/apps/desktop/src/renderer/__tests__/menuButtonSettingsEntry.test.tsindex 074cde6746..6cd6ab707f 100644--- a/apps/desktop/src/renderer/__tests__/menuButtonSettingsEntry.test.ts+++ b/apps/desktop/src/renderer/__tests__/menuButtonSettingsEntry.test.ts@@ -26,10 +26,11 @@ describe('MenuButton — settings menu item (#1881)', () => {expect(source).toContain("t('titleBar.menuItems.settings')");});- it('navigates to /settings with a same-path guard', () => {- // 与 MainLayout 'open-settings' / UserInfoSection 相同的防重复导航语义+ it('navigates to /settings with the open-settings same-path guard (pathname + search)', () => {+ // 与 MainLayout 'open-settings' 相同判定(currentPathRef = pathname + search):+ // 已在设置默认页不重复导航;在 /settings?tab=xxx 子页回到设置默认页。expect(source).toMatch(- /if \(location\.pathname !== '\/settings'\) \{\s*\n\s*navigate\('\/settings'\);/,+ /if \(`\$\{location\.pathname\}\$\{location\.search\}` !== '\/settings'\) \{\s*\n\s*navigate\('\/settings'\);/,);expect(source).toContain("import { useLocation, useNavigate } from 'react-router-dom';");});diff --git a/apps/desktop/src/renderer/components/title-bar/MenuButton.tsx b/apps/desktop/src/renderer/components/title-bar/MenuButton.tsxindex 00f6043c08..6b9480b1d4 100644--- a/apps/desktop/src/renderer/components/title-bar/MenuButton.tsx+++ b/apps/desktop/src/renderer/components/title-bar/MenuButton.tsx@@ -44,13 +44,15 @@ export function MenuButton() {{/* 设置入口:Windows / Linux 没有原生应用菜单(installApplicationMenu 非darwin 直接置 null),macOS「设置…」菜单项在这些平台不可见;侧栏底部用户卡片虽可进设置但无可见「设置」标识,可发现性不足(#1881)。此处- 常驻应用内左上角菜单,与 MainLayout 'open-settings' 命令同一行为:- 已在设置页时不重复导航,避免堆叠重复 history 记录。 */}+ 常驻应用内左上角菜单,与 MainLayout 'open-settings' 命令同一判定+ (pathname + search,见 MainLayout currentPathRef):已在设置默认页时+ 不重复导航;在 /settings?tab=xxx 子页时回到设置默认页,与 macOS 原生+ 菜单「设置…」行为一致。 */}<DropdownMenuItemclassName="focus:bg-titlebar-button-hover"onSelect={() => {log.info('Settings clicked');- if (location.pathname !== '/settings') {+ if (`${location.pathname}${location.search}` !== '/settings') {navigate('/settings');}}}