From 29e1f53c1eb0aac0c628366ae533ec344094a71b Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Fri, 6 Jun 2025 16:41:10 +0800 Subject: [PATCH] refactor: move minapp settings to minapp page --- src/renderer/src/components/app/Navbar.tsx | 21 +++ src/renderer/src/i18n/locales/zh-cn.json | 2 +- src/renderer/src/i18n/locales/zh-tw.json | 2 +- src/renderer/src/pages/apps/AppsPage.tsx | 52 ++++-- .../MiniappSettings/MiniAppIconsManager.tsx | 0 .../MiniappSettings/MiniAppSettings.tsx | 156 +++++++++--------- .../src/pages/settings/SettingsPage.tsx | 14 -- 7 files changed, 141 insertions(+), 106 deletions(-) rename src/renderer/src/pages/{settings => apps}/MiniappSettings/MiniAppIconsManager.tsx (100%) rename src/renderer/src/pages/{settings => apps}/MiniappSettings/MiniAppSettings.tsx (57%) diff --git a/src/renderer/src/components/app/Navbar.tsx b/src/renderer/src/components/app/Navbar.tsx index e5fe83b98c..e6176c2a00 100644 --- a/src/renderer/src/components/app/Navbar.tsx +++ b/src/renderer/src/components/app/Navbar.tsx @@ -34,6 +34,15 @@ export const NavbarRight: FC = ({ children, ...props }) => { ) } +export const NavbarMain: FC = ({ children, ...props }) => { + const isFullscreen = useFullscreen() + return ( + + {children} + + ) +} + const NavbarContainer = styled.div` min-width: 100%; display: flex; @@ -72,3 +81,15 @@ const NavbarRightContainer = styled.div<{ $isFullscreen: boolean }>` padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWindows ? '140px' : isLinux ? '120px' : '12px')}; justify-content: flex-end; ` + +const NavbarMainContainer = styled.div<{ $isFullscreen: boolean }>` + flex: 1; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + padding: 0 ${isMac ? '20px' : 0}; + font-weight: bold; + color: var(--color-text-1); + padding-right: ${({ $isFullscreen }) => ($isFullscreen ? '12px' : isWindows ? '140px' : isLinux ? '120px' : '12px')}; +` diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 4f9b6c2fae..67f233915f 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -1698,7 +1698,7 @@ "search_message_in_chat": "在当前对话中搜索消息", "show_app": "显示/隐藏应用", "show_settings": "打开设置", - "title": "快捷方式", + "title": "快捷键", "toggle_new_context": "清除上下文", "toggle_show_assistants": "切换助手显示", "toggle_show_topics": "切换话题显示", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 61bd018af2..bb337fa365 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -1688,7 +1688,7 @@ "search_message_in_chat": "在當前對話中搜尋訊息", "show_app": "顯示/隱藏應用程式", "show_settings": "開啟設定", - "title": "快速方式", + "title": "快捷鍵", "toggle_new_context": "清除上下文", "toggle_show_assistants": "切換助手顯示", "toggle_show_topics": "切換話題顯示", diff --git a/src/renderer/src/pages/apps/AppsPage.tsx b/src/renderer/src/pages/apps/AppsPage.tsx index 5348ac4367..31cb3f2392 100644 --- a/src/renderer/src/pages/apps/AppsPage.tsx +++ b/src/renderer/src/pages/apps/AppsPage.tsx @@ -1,18 +1,22 @@ -import { Navbar, NavbarCenter } from '@renderer/components/app/Navbar' +import { Navbar, NavbarMain } from '@renderer/components/app/Navbar' import { useMinapps } from '@renderer/hooks/useMinapps' -import { Input } from 'antd' -import { Search } from 'lucide-react' -import React, { FC, useState } from 'react' +import { Button, Input } from 'antd' +import { Search, SettingsIcon, X } from 'lucide-react' +import React, { FC, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' +import { useLocation } from 'react-router' import styled from 'styled-components' import App from './App' +import MiniAppSettings from './MiniappSettings/MiniAppSettings' import NewAppButton from './NewAppButton' const AppsPage: FC = () => { const { t } = useTranslation() const [search, setSearch] = useState('') const { minapps } = useMinapps() + const [isSettingsOpen, setIsSettingsOpen] = useState(false) + const location = useLocation() const filteredApps = search ? minapps.filter( @@ -31,31 +35,51 @@ const AppsPage: FC = () => { e.preventDefault() } + useEffect(() => { + setIsSettingsOpen(false) + }, [location.key]) + return ( - + {t('minapp.title')} } value={search} onChange={(e) => setSearch(e.target.value)} + disabled={isSettingsOpen} /> -
- + - - - - - - - - - {t('settings.miniapps.open_link_external.title')} - - dispatch(setMinappsOpenLinkExternal(checked))} - /> - - - - {/* 缓存小程序数量设置 */} - - - {t('settings.miniapps.cache_title')} - {t('settings.miniapps.cache_description')} - - - - - - - - - `${value}` }} - /> - - - - - - - {t('settings.miniapps.sidebar_title')} - {t('settings.miniapps.sidebar_description')} - - dispatch(setShowOpenedMinappsInSidebar(checked))} - /> - - - + + {t('settings.miniapps.display_title')} + + + + + + + + + + + {t('settings.miniapps.open_link_external.title')} + + dispatch(setMinappsOpenLinkExternal(checked))} + /> + + + {/* 缓存小程序数量设置 */} + + + {t('settings.miniapps.cache_title')} + {t('settings.miniapps.cache_description')} + + + + + + + + + `${value}` }} + /> + + + + + + + {t('settings.miniapps.sidebar_title')} + {t('settings.miniapps.sidebar_description')} + + dispatch(setShowOpenedMinappsInSidebar(checked))} + /> + + + + + + ) } +const Container = styled.div` + display: flex; + flex-direction: column; + flex: 1; +` + // 修改和新增样式 const SettingRow = styled.div` display: flex; diff --git a/src/renderer/src/pages/settings/SettingsPage.tsx b/src/renderer/src/pages/settings/SettingsPage.tsx index 5048eabf74..7ce087313c 100644 --- a/src/renderer/src/pages/settings/SettingsPage.tsx +++ b/src/renderer/src/pages/settings/SettingsPage.tsx @@ -1,5 +1,4 @@ import { Navbar, NavbarCenter } from '@renderer/components/app/Navbar' -import { useSidebarIconShow } from '@renderer/hooks/useSidebarIcon' import ModelSettings from '@renderer/pages/settings/ModelSettings/ModelSettings' import { Cloud, @@ -7,7 +6,6 @@ import { Globe, HardDrive, Info, - LayoutGrid, MonitorCog, Package, Rocket, @@ -28,7 +26,6 @@ import DisplaySettings from './DisplaySettings/DisplaySettings' import GeneralSettings from './GeneralSettings' import MCPSettings from './MCPSettings' import { McpSettingsNavbar } from './MCPSettings/McpSettingsNavbar' -import MiniAppSettings from './MiniappSettings/MiniAppSettings' import ProvidersList from './ProviderSettings' import QuickAssistantSettings from './QuickAssistantSettings' import QuickPhraseSettings from './QuickPhraseSettings' @@ -40,8 +37,6 @@ const SettingsPage: FC = () => { const { pathname } = useLocation() const { t } = useTranslation() - const showMiniAppSettings = useSidebarIconShow('minapp') - const isRoute = (path: string): string => (pathname.startsWith(path) ? 'active' : '') return ( @@ -88,14 +83,6 @@ const SettingsPage: FC = () => { {t('settings.display.title')} - {showMiniAppSettings && ( - - - - {t('settings.miniapps.title')} - - - )} @@ -141,7 +128,6 @@ const SettingsPage: FC = () => { } /> } /> } /> - {showMiniAppSettings && } />} } /> } /> } />