From 22b0bd54b47fac1d27bffc2df7fb1a8950ac8f89 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?George=C2=B7Dong?=
<98630204+GeorgeDong32@users.noreply.github.com>
Date: Sun, 30 Mar 2025 08:48:23 +0800
Subject: [PATCH] =?UTF-8?q?refactor(settings):=20=E9=87=8D=E6=9E=84?=
=?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=AE=BE=E7=BD=AE=20(#4092)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/renderer/src/components/app/Sidebar.tsx | 6 +-
src/renderer/src/hooks/useMinappPopup.ts | 19 +-
src/renderer/src/i18n/locales/en-us.json | 18 +-
src/renderer/src/i18n/locales/ja-jp.json | 18 +-
src/renderer/src/i18n/locales/ru-ru.json | 18 +-
src/renderer/src/i18n/locales/zh-cn.json | 18 +-
src/renderer/src/i18n/locales/zh-tw.json | 18 +-
.../DisplaySettings/DisplaySettings.tsx | 30 ---
.../MiniAppIconsManager.tsx | 4 +-
.../MiniappSettings/MiniAppSettings.tsx | 226 ++++++++++++++++++
.../src/pages/settings/SettingsPage.tsx | 19 +-
src/renderer/src/store/settings.ts | 16 +-
12 files changed, 342 insertions(+), 68 deletions(-)
rename src/renderer/src/pages/settings/{DisplaySettings => MiniappSettings}/MiniAppIconsManager.tsx (97%)
create mode 100644 src/renderer/src/pages/settings/MiniappSettings/MiniAppSettings.tsx
diff --git a/src/renderer/src/components/app/Sidebar.tsx b/src/renderer/src/components/app/Sidebar.tsx
index a7f7e324..08542156 100644
--- a/src/renderer/src/components/app/Sidebar.tsx
+++ b/src/renderer/src/components/app/Sidebar.tsx
@@ -173,6 +173,7 @@ const MainMenus: FC = () => {
const SidebarOpenedMinappTabs: FC = () => {
const { minappShow, openedKeepAliveMinapps, currentMinappId } = useRuntime()
const { openMinappKeepAlive, hideMinappPopup, closeMinapp, closeAllMinapps } = useMinappPopup()
+ const { showOpenedMinappsInSidebar } = useSettings() // 获取控制显示的设置
const { theme } = useTheme()
const { t } = useTranslation()
@@ -208,7 +209,10 @@ const SidebarOpenedMinappTabs: FC = () => {
container.style.setProperty('--indicator-right', `${indicatorRight}px`)
}, [currentMinappId, openedKeepAliveMinapps, minappShow])
- const isShowOpened = openedKeepAliveMinapps.length > 0
+ // 检查是否需要显示已打开小程序组件
+ const isShowOpened = showOpenedMinappsInSidebar && openedKeepAliveMinapps.length > 0
+
+ // 如果不需要显示,返回空容器保持动画效果但不显示内容
if (!isShowOpened) return
return (
diff --git a/src/renderer/src/hooks/useMinappPopup.ts b/src/renderer/src/hooks/useMinappPopup.ts
index 8c7bf2f3..e5c5adf4 100644
--- a/src/renderer/src/hooks/useMinappPopup.ts
+++ b/src/renderer/src/hooks/useMinappPopup.ts
@@ -1,4 +1,5 @@
import { useRuntime } from '@renderer/hooks/useRuntime'
+import { useSettings } from '@renderer/hooks/useSettings' // 使用设置中的值
import { useAppDispatch } from '@renderer/store'
import {
setCurrentMinappId,
@@ -8,9 +9,6 @@ import {
} from '@renderer/store/runtime'
import { MinAppType } from '@renderer/types'
-/** The max number of keep alive minapps */
-const MINAPP_MAX_KEEPALIVE = 3
-
/**
* Usage:
*
@@ -26,27 +24,26 @@ const MINAPP_MAX_KEEPALIVE = 3
* const { openedKeepAliveMinapps, openedOneOffMinapp, minappShow } = useRuntime()
*/
export const useMinappPopup = () => {
- const { openedKeepAliveMinapps, openedOneOffMinapp, minappShow } = useRuntime()
const dispatch = useAppDispatch()
+ const { openedKeepAliveMinapps, openedOneOffMinapp, minappShow } = useRuntime()
+ const { maxKeepAliveMinapps } = useSettings() // 使用设置中的值
/** Open a minapp (popup shows and minapp loaded) */
const openMinapp = (app: MinAppType, keepAlive: boolean = false) => {
if (keepAlive) {
- //if the minapp is already opened, do nothing
+ // 如果小程序已经打开,只切换显示
if (openedKeepAliveMinapps.some((item) => item.id === app.id)) {
dispatch(setCurrentMinappId(app.id))
dispatch(setMinappShow(true))
return
}
- //if the minapp is not opened, open it
- //check if the keep alive minapps meet the max limit
- if (openedKeepAliveMinapps.length < MINAPP_MAX_KEEPALIVE) {
- //always put new minapp at the first
+ // 如果缓存数量未达上限,添加到缓存列表
+ if (openedKeepAliveMinapps.length < maxKeepAliveMinapps) {
dispatch(setOpenedKeepAliveMinapps([app, ...openedKeepAliveMinapps]))
} else {
- //pop the last one
- dispatch(setOpenedKeepAliveMinapps([app, ...openedKeepAliveMinapps.slice(0, MINAPP_MAX_KEEPALIVE - 1)]))
+ // 缓存数量达到上限,移除最后一个,添加新的
+ dispatch(setOpenedKeepAliveMinapps([app, ...openedKeepAliveMinapps.slice(0, maxKeepAliveMinapps - 1)]))
}
dispatch(setOpenedOneOffMinapp(null))
diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json
index fcb5d9a4..cbdb6787 100644
--- a/src/renderer/src/i18n/locales/en-us.json
+++ b/src/renderer/src/i18n/locales/en-us.json
@@ -919,10 +919,6 @@
"display.custom.css": "Custom CSS",
"display.custom.css.cherrycss": "Get from cherrycss.com",
"display.custom.css.placeholder": "/* Put custom CSS here */",
- "display.minApp.disabled": "Hidden MinApp",
- "display.minApp.empty": "Drag minApp from the left to hide them here",
- "display.minApp.title": "MinApp Settings",
- "display.minApp.visible": "Visible MinApp",
"display.sidebar.chat.hiddenMessage": "Assistants are basic functions, not supported for hiding",
"display.sidebar.disabled": "Hide icons",
"display.sidebar.empty": "Drag the hidden feature from the left side here",
@@ -935,6 +931,20 @@
"display.sidebar.visible": "Show icons",
"display.title": "Display Settings",
"display.topic.title": "Topic Settings",
+ "miniapps": {
+ "title": "Mini Apps Settings",
+ "disabled": "Hidden Mini Apps",
+ "empty": "Drag mini apps from the left to hide them",
+ "visible": "Visible Mini Apps",
+ "cache_settings": "Cache Settings",
+ "cache_title": "Mini App Cache Limit",
+ "cache_description": "Set the maximum number of active mini apps to keep in memory",
+ "reset_tooltip": "Reset to default",
+ "display_title": "Mini App Display Settings",
+ "sidebar_title": "Sidebar Active Mini Apps Display",
+ "sidebar_description": "Show active mini apps in the sidebar",
+ "cache_change_notice": "Changes will take effect when the number of open mini apps reaches the set value"
+ },
"font_size.title": "Message font size",
"general": "General Settings",
"general.avatar.reset": "Reset Avatar",
diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json
index 6d752f08..0c7c5a9b 100644
--- a/src/renderer/src/i18n/locales/ja-jp.json
+++ b/src/renderer/src/i18n/locales/ja-jp.json
@@ -919,10 +919,6 @@
"display.custom.css": "カスタムCSS",
"display.custom.css.cherrycss": "cherrycss.comから取得",
"display.custom.css.placeholder": "/* ここにカスタムCSSを入力 */",
- "display.minApp.disabled": "非表示ミニプログラム",
- "display.minApp.empty": "非表示にしたいアプレットを左からここまでドラッグします",
- "display.minApp.title": "ミニプログラム表示設定",
- "display.minApp.visible": "表示中ミニプログラム",
"display.sidebar.chat.hiddenMessage": "アシスタントは基本的な機能であり、非表示はサポートされていません",
"display.sidebar.disabled": "アイコンを非表示",
"display.sidebar.empty": "非表示にする機能を左側からここにドラッグ",
@@ -935,6 +931,20 @@
"display.sidebar.visible": "アイコンを表示",
"display.title": "表示設定",
"display.topic.title": "トピック設定",
+ "miniapps": {
+ "title": "ミニアプリ設定",
+ "disabled": "非表示のミニアプリ",
+ "empty": "非表示にするミニアプリを左側からここにドラッグしてください",
+ "visible": "表示するミニアプリ",
+ "cache_settings": "キャッシュ設定",
+ "cache_title": "ミニアプリのキャッシュ数",
+ "cache_description": "メモリに保持するアクティブなミニアプリの最大数を設定します",
+ "reset_tooltip": "デフォルト値にリセット",
+ "display_title": "ミニアプリ表示設定",
+ "sidebar_title": "サイドバーのアクティブなミニアプリ表示",
+ "sidebar_description": "サイドバーにアクティブなミニアプリを表示するかどうかを設定します",
+ "cache_change_notice": "設定値に達するまでミニアプリの開閉が行われた後に変更が適用されます"
+ },
"font_size.title": "メッセージのフォントサイズ",
"general": "一般設定",
"general.avatar.reset": "アバターをリセット",
diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json
index de6d5d82..70cdbbe0 100644
--- a/src/renderer/src/i18n/locales/ru-ru.json
+++ b/src/renderer/src/i18n/locales/ru-ru.json
@@ -919,10 +919,6 @@
"display.custom.css": "Пользовательский CSS",
"display.custom.css.cherrycss": "Получить из cherrycss.com",
"display.custom.css.placeholder": "/* Здесь введите пользовательский CSS */",
- "display.minApp.disabled": "скрытый апплет",
- "display.minApp.empty": "Перетащите апплет, который хотите скрыть, слева сюда",
- "display.minApp.title": "Настройки отображения мини программы",
- "display.minApp.visible": "Отображаемый апплет",
"display.sidebar.chat.hiddenMessage": "Помощник является базовой функцией и не поддерживает скрытие",
"display.sidebar.disabled": "Скрыть иконки",
"display.sidebar.empty": "Перетащите скрываемую функцию с левой стороны сюда",
@@ -935,6 +931,20 @@
"display.sidebar.visible": "Показывать иконки",
"display.title": "Настройки отображения",
"display.topic.title": "Настройки топиков",
+ "miniapps": {
+ "title": "Настройки мини-приложений",
+ "disabled": "Скрытые мини-приложения",
+ "empty": "Перетащите мини-приложения слева, чтобы скрыть их",
+ "visible": "Отображаемые мини-приложения",
+ "cache_settings": "Настройки кэша",
+ "cache_title": "Количество кэшируемых мини-приложений",
+ "cache_description": "Установить максимальное количество активных мини-приложений в памяти",
+ "reset_tooltip": "Сбросить до значения по умолчанию",
+ "display_title": "Настройки отображения мини-приложений",
+ "sidebar_title": "Отображение активных мини-приложений в боковой панели",
+ "sidebar_description": "Настройка отображения активных мини-приложений в боковой панели",
+ "cache_change_notice": "Изменения вступят в силу, когда количество открытых мини-приложений достигнет установленного значения"
+ },
"font_size.title": "Размер шрифта сообщений",
"general": "Общие настройки",
"general.avatar.reset": "Сброс аватара",
diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json
index cd7d6815..9b8197d1 100644
--- a/src/renderer/src/i18n/locales/zh-cn.json
+++ b/src/renderer/src/i18n/locales/zh-cn.json
@@ -919,10 +919,6 @@
"display.custom.css": "自定义 CSS",
"display.custom.css.cherrycss": "从 cherrycss.com 获取",
"display.custom.css.placeholder": "/* 这里写自定义CSS */",
- "display.minApp.disabled": "隐藏的小程序",
- "display.minApp.empty": "把要隐藏的小程序从左侧拖拽到这里",
- "display.minApp.title": "小程序显示设置",
- "display.minApp.visible": "显示的小程序",
"display.sidebar.chat.hiddenMessage": "助手是基础功能,不支持隐藏",
"display.sidebar.disabled": "隐藏的图标",
"display.sidebar.empty": "把要隐藏的功能从左侧拖拽到这里",
@@ -935,6 +931,20 @@
"display.sidebar.visible": "显示的图标",
"display.title": "显示设置",
"display.topic.title": "话题设置",
+ "miniapps": {
+ "title": "小程序设置",
+ "disabled": "隐藏的小程序",
+ "empty": "把要隐藏的小程序从左侧拖拽到这里",
+ "visible": "显示的小程序",
+ "cache_settings": "缓存设置",
+ "cache_title": "小程序缓存数量",
+ "cache_description": "设置同时保持活跃状态的小程序最大数量",
+ "reset_tooltip": "重置为默认值",
+ "display_title": "小程序显示设置",
+ "sidebar_title": "侧边栏活跃小程序显示设置",
+ "sidebar_description": "设置侧边栏是否显示活跃的小程序",
+ "cache_change_notice": "更改将在打开的小程序增减至设定值后生效"
+ },
"font_size.title": "消息字体大小",
"general": "常规设置",
"general.avatar.reset": "重置头像",
diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json
index 54b4f546..96946816 100644
--- a/src/renderer/src/i18n/locales/zh-tw.json
+++ b/src/renderer/src/i18n/locales/zh-tw.json
@@ -919,10 +919,6 @@
"display.custom.css": "自訂 CSS",
"display.custom.css.cherrycss": "從 cherrycss.com 取得",
"display.custom.css.placeholder": "/* 這裡寫自訂 CSS */",
- "display.minApp.disabled": "隱藏的小工具",
- "display.minApp.empty": "把要隱藏的小工具從左側拖拽到這裡",
- "display.minApp.title": "小工具顯示設定",
- "display.minApp.visible": "顯示的小工具",
"display.sidebar.chat.hiddenMessage": "助手是基礎功能,不支援隱藏",
"display.sidebar.disabled": "隱藏的圖示",
"display.sidebar.empty": "把要隱藏的功能從左側拖拽到這裡",
@@ -935,6 +931,20 @@
"display.sidebar.visible": "顯示的圖示",
"display.title": "顯示設定",
"display.topic.title": "話題設定",
+ "miniapps": {
+ "title": "小程式設置",
+ "disabled": "隱藏的小程式",
+ "empty": "把要隱藏的小程式從左側拖拽到這裡",
+ "visible": "顯示的小程式",
+ "cache_settings": "緩存設置",
+ "cache_title": "小程式緩存數量",
+ "cache_description": "設置同時保持活躍狀態的小程式最大數量",
+ "reset_tooltip": "重置為預設值",
+ "display_title": "小程式顯示設置",
+ "sidebar_title": "側邊欄活躍小程式顯示設置",
+ "sidebar_description": "設置側邊欄是否顯示活躍的小程式",
+ "cache_change_notice": "更改將在打開的小程式增減至設定值後生效"
+ },
"font_size.title": "訊息字型大小",
"general": "一般設定",
"general.avatar.reset": "重設頭像",
diff --git a/src/renderer/src/pages/settings/DisplaySettings/DisplaySettings.tsx b/src/renderer/src/pages/settings/DisplaySettings/DisplaySettings.tsx
index 4e329721..2e29e298 100644
--- a/src/renderer/src/pages/settings/DisplaySettings/DisplaySettings.tsx
+++ b/src/renderer/src/pages/settings/DisplaySettings/DisplaySettings.tsx
@@ -1,8 +1,6 @@
import { SyncOutlined } from '@ant-design/icons'
import { isMac } from '@renderer/config/constant'
-import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
import { useTheme } from '@renderer/context/ThemeProvider'
-import { useMinapps } from '@renderer/hooks/useMinapps'
import { useSettings } from '@renderer/hooks/useSettings'
import { useAppDispatch } from '@renderer/store'
import {
@@ -19,7 +17,6 @@ import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
import { SettingContainer, SettingDivider, SettingGroup, SettingRow, SettingRowTitle, SettingTitle } from '..'
-import MiniAppIconsManager from './MiniAppIconsManager'
import SidebarIconsManager from './SidebarIconsManager'
const DisplaySettings: FC = () => {
@@ -37,17 +34,13 @@ const DisplaySettings: FC = () => {
showAssistantIcon,
setShowAssistantIcon
} = useSettings()
- const { minapps, disabled, updateMinapps, updateDisabledMinapps } = useMinapps()
const { theme: themeMode } = useTheme()
const { t } = useTranslation()
const dispatch = useAppDispatch()
const [visibleIcons, setVisibleIcons] = useState(sidebarIcons?.visible || DEFAULT_SIDEBAR_ICONS)
const [disabledIcons, setDisabledIcons] = useState(sidebarIcons?.disabled || [])
- const [visibleMiniApps, setVisibleMiniApps] = useState(minapps)
- const [disabledMiniApps, setDisabledMiniApps] = useState(disabled || [])
- // 使用useCallback优化回调函数
const handleWindowStyleChange = useCallback(
(checked: boolean) => {
setWindowStyle(checked ? 'transparent' : 'opaque')
@@ -61,13 +54,6 @@ const DisplaySettings: FC = () => {
dispatch(setSidebarIcons({ visible: DEFAULT_SIDEBAR_ICONS, disabled: [] }))
}, [dispatch])
- const handleResetMinApps = useCallback(() => {
- setVisibleMiniApps(DEFAULT_MIN_APPS)
- setDisabledMiniApps([])
- updateMinapps(DEFAULT_MIN_APPS)
- updateDisabledMinapps([])
- }, [updateDisabledMinapps, updateMinapps])
-
const themeOptions = useMemo(
() => [
{
@@ -177,22 +163,6 @@ const DisplaySettings: FC = () => {
setDisabledIcons={setDisabledIcons}
/>
-
-
- {t('settings.display.minApp.title')}
-
-
-
-
-
-
-
{t('settings.display.custom.css')}
diff --git a/src/renderer/src/pages/settings/DisplaySettings/MiniAppIconsManager.tsx b/src/renderer/src/pages/settings/MiniappSettings/MiniAppIconsManager.tsx
similarity index 97%
rename from src/renderer/src/pages/settings/DisplaySettings/MiniAppIconsManager.tsx
rename to src/renderer/src/pages/settings/MiniappSettings/MiniAppIconsManager.tsx
index 1fad12fb..1755e00d 100644
--- a/src/renderer/src/pages/settings/DisplaySettings/MiniAppIconsManager.tsx
+++ b/src/renderer/src/pages/settings/MiniappSettings/MiniAppIconsManager.tsx
@@ -115,7 +115,7 @@ const MiniAppIconsManager: FC = ({
{(['visible', 'disabled'] as const).map((listType) => (
- {t(`settings.display.minApp.${listType}`)}
+ {t(`settings.miniapps.${listType}`)}
{(provided: DroppableProvided) => (
@@ -125,7 +125,7 @@ const MiniAppIconsManager: FC = ({
))}
{disabledMiniApps.length === 0 && listType === 'disabled' && (
- {t('settings.display.minApp.empty')}
+ {t('settings.miniapps.empty')}
)}
{provided.placeholder}
diff --git a/src/renderer/src/pages/settings/MiniappSettings/MiniAppSettings.tsx b/src/renderer/src/pages/settings/MiniappSettings/MiniAppSettings.tsx
new file mode 100644
index 00000000..61441e7d
--- /dev/null
+++ b/src/renderer/src/pages/settings/MiniappSettings/MiniAppSettings.tsx
@@ -0,0 +1,226 @@
+import { UndoOutlined } from '@ant-design/icons' // 导入重置图标
+import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
+import { useTheme } from '@renderer/context/ThemeProvider'
+import { useMinapps } from '@renderer/hooks/useMinapps'
+import { useSettings } from '@renderer/hooks/useSettings'
+import { useAppDispatch } from '@renderer/store'
+import { setMaxKeepAliveMinapps, setShowOpenedMinappsInSidebar } from '@renderer/store/settings'
+import { Button, message, Slider, Switch, Tooltip } from 'antd'
+import { FC, useCallback, useEffect, useRef, useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import styled from 'styled-components'
+
+import { SettingContainer, SettingDescription, SettingDivider, SettingGroup, SettingRowTitle, SettingTitle } from '..'
+import MiniAppIconsManager from './MiniAppIconsManager'
+
+// 默认小程序缓存数量
+const DEFAULT_MAX_KEEPALIVE = 3
+
+const MiniAppSettings: FC = () => {
+ const { t } = useTranslation()
+ const { theme } = useTheme()
+ const dispatch = useAppDispatch()
+ const { maxKeepAliveMinapps, showOpenedMinappsInSidebar } = useSettings()
+ const { minapps, disabled, updateMinapps, updateDisabledMinapps } = useMinapps()
+
+ const [visibleMiniApps, setVisibleMiniApps] = useState(minapps)
+ const [disabledMiniApps, setDisabledMiniApps] = useState(disabled || [])
+ const [messageApi, contextHolder] = message.useMessage()
+ const debounceTimerRef = useRef(null)
+
+ const handleResetMinApps = useCallback(() => {
+ setVisibleMiniApps(DEFAULT_MIN_APPS)
+ setDisabledMiniApps([])
+ updateMinapps(DEFAULT_MIN_APPS)
+ updateDisabledMinapps([])
+ }, [updateDisabledMinapps, updateMinapps])
+
+ // 恢复默认缓存数量
+ const handleResetCacheLimit = useCallback(() => {
+ dispatch(setMaxKeepAliveMinapps(DEFAULT_MAX_KEEPALIVE))
+ messageApi.info(t('settings.miniapps.cache_change_notice'))
+ }, [dispatch, messageApi, t])
+
+ // 处理缓存数量变更
+ const handleCacheChange = useCallback(
+ (value: number) => {
+ dispatch(setMaxKeepAliveMinapps(value))
+
+ if (debounceTimerRef.current) {
+ clearTimeout(debounceTimerRef.current)
+ }
+
+ debounceTimerRef.current = setTimeout(() => {
+ messageApi.info(t('settings.miniapps.cache_change_notice'))
+ debounceTimerRef.current = null
+ }, 500)
+ },
+ [dispatch, messageApi, t]
+ )
+
+ // 组件卸载时清除定时器
+ useEffect(() => {
+ return () => {
+ if (debounceTimerRef.current) {
+ clearTimeout(debounceTimerRef.current)
+ }
+ }
+ }, [])
+
+ return (
+
+ {contextHolder} {/* 添加消息上下文 */}
+
+ {t('settings.miniapps.title')}
+
+
+ {t('settings.miniapps.display_title')}
+
+
+
+
+
+
+
+
+
+ {/* 缓存小程序数量设置 */}
+
+
+ {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 CacheSettingRow = styled.div`
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ margin: 0;
+ gap: 20px;
+`
+
+const SettingLabelGroup = styled.div`
+ flex: 1;
+`
+
+// 新增控件容器,包含滑块和恢复默认按钮
+const CacheSettingControls = styled.div`
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ width: 240px;
+`
+
+const SliderWithResetContainer = styled.div`
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ width: 100%;
+
+ .ant-slider {
+ flex: 1;
+ }
+
+ .ant-slider-track {
+ background-color: var(--color-primary);
+ }
+
+ .ant-slider-handle {
+ border-color: var(--color-primary);
+ }
+`
+
+// 重置按钮样式
+const ResetButton = styled.button`
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 28px;
+ height: 28px;
+ min-width: 28px; /* 确保不会被压缩 */
+ border-radius: 4px;
+ border: 1px solid var(--color-border);
+ background-color: var(--color-bg-1);
+ cursor: pointer;
+ transition: all 0.2s;
+ padding: 0;
+ color: var(--color-text);
+
+ &:hover {
+ border-color: var(--color-primary);
+ color: var(--color-primary);
+ }
+
+ &:active {
+ background-color: var(--color-bg-2);
+ }
+`
+
+const ResetButtonWrapper = styled.div`
+ display: flex;
+ align-items: center;
+ justify-content: center;
+`
+
+// 新增侧边栏设置行样式
+const SidebarSettingRow = styled.div`
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 20px;
+`
+
+// 新增: 带边框的容器组件
+const BorderedContainer = styled.div`
+ border: 1px solid var(--color-border);
+ border-radius: 8px;
+ padding: 8px;
+ margin: 8px 0 8px;
+ background-color: var(--color-bg-1);
+`
+
+export default MiniAppSettings
diff --git a/src/renderer/src/pages/settings/SettingsPage.tsx b/src/renderer/src/pages/settings/SettingsPage.tsx
index e661cf14..6145c778 100644
--- a/src/renderer/src/pages/settings/SettingsPage.tsx
+++ b/src/renderer/src/pages/settings/SettingsPage.tsx
@@ -1,4 +1,5 @@
import {
+ AppstoreOutlined,
CloudOutlined,
CodeOutlined,
GlobalOutlined,
@@ -11,7 +12,9 @@ import {
} from '@ant-design/icons'
import { Navbar, NavbarCenter } from '@renderer/components/app/Navbar'
import { isLocalAi } from '@renderer/config/env'
+import { useSidebarIconShow } from '@renderer/hooks/useSidebarIcon'
import ModelSettings from '@renderer/pages/settings/ModelSettings/ModelSettings'
+// 导入useAppSelector
import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { Link, Route, Routes, useLocation } from 'react-router-dom'
@@ -23,6 +26,7 @@ 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 ShortcutSettings from './ShortcutSettings'
@@ -32,6 +36,8 @@ const SettingsPage: FC = () => {
const { pathname } = useLocation()
const { t } = useTranslation()
+ const showMiniAppSettings = useSidebarIconShow('minapp')
+
const isRoute = (path: string): string => (pathname.startsWith(path) ? 'active' : '')
return (
@@ -82,6 +88,14 @@ const SettingsPage: FC = () => {
{t('settings.display.title')}
+ {showMiniAppSettings && (
+
+
+
+ )}