mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-22 00:13:09 +08:00
* fix: 修复侧边栏重置时 Code 图标消失的问题 (#9307) 问题原因: - types/index.ts 中的 SidebarIcon 类型定义缺少 'code_tools' - 存在重复的类型定义和常量定义导致不一致 修复内容: - 在 types/index.ts 的 SidebarIcon 类型中添加 'code_tools' - 删除 minapps.ts 中重复的 DEFAULT_SIDEBAR_ICONS 常量 - 统一从 @renderer/types 导入 SidebarIcon 类型 - 删除 settings.ts 中重复的 SidebarIcon 类型定义 这确保了在导航栏设置为左侧时,点击侧边栏设置的重置按钮后, Code 图标能够正确显示。 * refactor: 将侧边栏配置移至 config 目录 根据 code review 建议,将侧边栏相关配置从 store/settings.ts 移动到 config/sidebar.ts,使配置管理更加清晰。 改动内容: - 创建 config/sidebar.ts 存放侧边栏配置常量 - 更新相关文件的导入路径 - 在 settings.ts 中重新导出以保持向后兼容 - 添加 REQUIRED_SIDEBAR_ICONS 常量便于未来扩展 这个改动保持了最小化原则,不影响现有功能。
This commit is contained in:
parent
8297546ed7
commit
27eef50b9f
23
src/renderer/src/config/sidebar.ts
Normal file
23
src/renderer/src/config/sidebar.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { SidebarIcon } from '@renderer/types'
|
||||
|
||||
/**
|
||||
* 默认显示的侧边栏图标
|
||||
* 这些图标会在侧边栏中默认显示
|
||||
*/
|
||||
export const DEFAULT_SIDEBAR_ICONS: SidebarIcon[] = [
|
||||
'assistants',
|
||||
'agents',
|
||||
'paintings',
|
||||
'translate',
|
||||
'minapp',
|
||||
'knowledge',
|
||||
'files',
|
||||
'code_tools'
|
||||
]
|
||||
|
||||
/**
|
||||
* 必须显示的侧边栏图标(不能被隐藏)
|
||||
* 这些图标必须始终在侧边栏中可见
|
||||
* 抽取为参数方便未来扩展
|
||||
*/
|
||||
export const REQUIRED_SIDEBAR_ICONS: SidebarIcon[] = ['assistants']
|
||||
@ -3,13 +3,13 @@ import { ResetIcon } from '@renderer/components/Icons'
|
||||
import { HStack } from '@renderer/components/Layout'
|
||||
import TextBadge from '@renderer/components/TextBadge'
|
||||
import { isMac, THEME_COLOR_PRESETS } from '@renderer/config/constant'
|
||||
import { DEFAULT_SIDEBAR_ICONS } from '@renderer/config/sidebar'
|
||||
import { useTheme } from '@renderer/context/ThemeProvider'
|
||||
import { useNavbarPosition, useSettings } from '@renderer/hooks/useSettings'
|
||||
import useUserTheme from '@renderer/hooks/useUserTheme'
|
||||
import { useAppDispatch } from '@renderer/store'
|
||||
import {
|
||||
AssistantIconType,
|
||||
DEFAULT_SIDEBAR_ICONS,
|
||||
setAssistantIconType,
|
||||
setClickAssistantToShowTopic,
|
||||
setCustomCss,
|
||||
|
||||
@ -10,14 +10,13 @@ import {
|
||||
import { getSidebarIconLabel } from '@renderer/i18n/label'
|
||||
import { useAppDispatch } from '@renderer/store'
|
||||
import { setSidebarIcons } from '@renderer/store/settings'
|
||||
import { SidebarIcon } from '@renderer/types'
|
||||
import { message } from 'antd'
|
||||
import { Code, FileSearch, Folder, Languages, LayoutGrid, MessageSquareQuote, Palette, Sparkle } from 'lucide-react'
|
||||
import { FC, useCallback, useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import { SidebarIcon } from '../../../store/settings'
|
||||
|
||||
interface SidebarIconsManagerProps {
|
||||
visibleIcons: SidebarIcon[]
|
||||
disabledIcons: SidebarIcon[]
|
||||
|
||||
@ -4,6 +4,7 @@ import { DEFAULT_CONTEXTCOUNT, DEFAULT_TEMPERATURE, isMac } from '@renderer/conf
|
||||
import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
|
||||
import { isFunctionCallingModel, isNotSupportedTextDelta, SYSTEM_MODELS } from '@renderer/config/models'
|
||||
import { TRANSLATE_PROMPT } from '@renderer/config/prompts'
|
||||
import { DEFAULT_SIDEBAR_ICONS } from '@renderer/config/sidebar'
|
||||
import {
|
||||
isSupportArrayContentProvider,
|
||||
isSupportDeveloperRoleProvider,
|
||||
@ -32,7 +33,7 @@ import { DEFAULT_TOOL_ORDER } from './inputTools'
|
||||
import { initialState as llmInitialState, moveProvider } from './llm'
|
||||
import { mcpSlice } from './mcp'
|
||||
import { defaultActionItems } from './selectionStore'
|
||||
import { DEFAULT_SIDEBAR_ICONS, initialState as settingsInitialState } from './settings'
|
||||
import { initialState as settingsInitialState } from './settings'
|
||||
import { initialState as shortcutsInitialState } from './shortcuts'
|
||||
import { defaultWebSearchProviders } from './websearch'
|
||||
|
||||
|
||||
@ -1,16 +1,6 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
|
||||
import { MinAppType, SidebarIcon } from '@renderer/types'
|
||||
|
||||
export const DEFAULT_SIDEBAR_ICONS: SidebarIcon[] = [
|
||||
'assistants',
|
||||
'agents',
|
||||
'paintings',
|
||||
'translate',
|
||||
'minapp',
|
||||
'knowledge',
|
||||
'files'
|
||||
]
|
||||
import { MinAppType } from '@renderer/types'
|
||||
|
||||
export interface MinAppsState {
|
||||
enabled: MinAppType[]
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
import { TRANSLATE_PROMPT } from '@renderer/config/prompts'
|
||||
import { DEFAULT_SIDEBAR_ICONS } from '@renderer/config/sidebar'
|
||||
import {
|
||||
ApiServerConfig,
|
||||
AssistantsSortType,
|
||||
@ -10,6 +11,7 @@ import {
|
||||
OpenAISummaryText,
|
||||
PaintingProvider,
|
||||
S3Config,
|
||||
SidebarIcon,
|
||||
ThemeMode,
|
||||
TranslateLanguageCode
|
||||
} from '@renderer/types'
|
||||
@ -21,26 +23,8 @@ import { RemoteSyncState } from './backup'
|
||||
|
||||
export type SendMessageShortcut = 'Enter' | 'Shift+Enter' | 'Ctrl+Enter' | 'Command+Enter' | 'Alt+Enter'
|
||||
|
||||
export type SidebarIcon =
|
||||
| 'assistants'
|
||||
| 'agents'
|
||||
| 'paintings'
|
||||
| 'translate'
|
||||
| 'minapp'
|
||||
| 'knowledge'
|
||||
| 'files'
|
||||
| 'code_tools'
|
||||
|
||||
export const DEFAULT_SIDEBAR_ICONS: SidebarIcon[] = [
|
||||
'assistants',
|
||||
'agents',
|
||||
'paintings',
|
||||
'translate',
|
||||
'minapp',
|
||||
'knowledge',
|
||||
'files',
|
||||
'code_tools'
|
||||
]
|
||||
// Re-export for backward compatibility
|
||||
export { DEFAULT_SIDEBAR_ICONS }
|
||||
|
||||
export interface NutstoreSyncRuntime extends RemoteSyncState {}
|
||||
|
||||
|
||||
@ -692,7 +692,7 @@ export const isAutoDetectionMethod = (method: string): method is AutoDetectionMe
|
||||
return Object.hasOwn(AutoDetectionMethods, method)
|
||||
}
|
||||
|
||||
export type SidebarIcon = 'assistants' | 'agents' | 'paintings' | 'translate' | 'minapp' | 'knowledge' | 'files'
|
||||
export type SidebarIcon = 'assistants' | 'agents' | 'paintings' | 'translate' | 'minapp' | 'knowledge' | 'files' | 'code_tools'
|
||||
|
||||
export type ExternalToolResult = {
|
||||
mcpTools?: MCPTool[]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user