mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 14:59:27 +08:00
feat(DisplaySettings, MainSidebar, useSettings): implement transparent window feature and update styles
- Added functionality to manage transparent window settings in DisplaySettings and MainSidebar components. - Updated useSettings hook to include transparent window state management. - Modified MainSidebar and its styles to support transparency based on user settings. - Removed obsolete opaque window translations from localization files across multiple languages for consistency.
This commit is contained in:
parent
3544c40d9a
commit
3775562956
@ -14,6 +14,7 @@ import {
|
|||||||
setTheme,
|
setTheme,
|
||||||
SettingsState,
|
SettingsState,
|
||||||
setTopicPosition,
|
setTopicPosition,
|
||||||
|
setTransparentWindow,
|
||||||
setTray as _setTray,
|
setTray as _setTray,
|
||||||
setTrayOnClose
|
setTrayOnClose
|
||||||
} from '@renderer/store/settings'
|
} from '@renderer/store/settings'
|
||||||
@ -86,6 +87,9 @@ export function useSettings() {
|
|||||||
},
|
},
|
||||||
setAssistantIconType(assistantIconType: AssistantIconType) {
|
setAssistantIconType(assistantIconType: AssistantIconType) {
|
||||||
dispatch(setAssistantIconType(assistantIconType))
|
dispatch(setAssistantIconType(assistantIconType))
|
||||||
|
},
|
||||||
|
setTransparentWindow(transparentWindow: boolean) {
|
||||||
|
dispatch(setTransparentWindow(transparentWindow))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1730,7 +1730,6 @@
|
|||||||
"theme.light": "Light",
|
"theme.light": "Light",
|
||||||
"theme.title": "Theme",
|
"theme.title": "Theme",
|
||||||
"theme.color_primary": "Primary Color",
|
"theme.color_primary": "Primary Color",
|
||||||
"theme.window.style.opaque": "Opaque Window",
|
|
||||||
"theme.window.style.title": "Window Style",
|
"theme.window.style.title": "Window Style",
|
||||||
"theme.window.style.transparent": "Transparent Window",
|
"theme.window.style.transparent": "Transparent Window",
|
||||||
"title": "Settings",
|
"title": "Settings",
|
||||||
|
|||||||
@ -1718,7 +1718,6 @@
|
|||||||
"theme.light": "ライト",
|
"theme.light": "ライト",
|
||||||
"theme.title": "テーマ",
|
"theme.title": "テーマ",
|
||||||
"theme.color_primary": "テーマ色",
|
"theme.color_primary": "テーマ色",
|
||||||
"theme.window.style.opaque": "不透明ウィンドウ",
|
|
||||||
"theme.window.style.title": "ウィンドウスタイル",
|
"theme.window.style.title": "ウィンドウスタイル",
|
||||||
"theme.window.style.transparent": "透明ウィンドウ",
|
"theme.window.style.transparent": "透明ウィンドウ",
|
||||||
"title": "設定",
|
"title": "設定",
|
||||||
|
|||||||
@ -1718,7 +1718,6 @@
|
|||||||
"theme.light": "Светлая",
|
"theme.light": "Светлая",
|
||||||
"theme.title": "Тема",
|
"theme.title": "Тема",
|
||||||
"theme.color_primary": "Цвет темы",
|
"theme.color_primary": "Цвет темы",
|
||||||
"theme.window.style.opaque": "Непрозрачное окно",
|
|
||||||
"theme.window.style.title": "Стиль окна",
|
"theme.window.style.title": "Стиль окна",
|
||||||
"theme.window.style.transparent": "Прозрачное окно",
|
"theme.window.style.transparent": "Прозрачное окно",
|
||||||
"title": "Настройки",
|
"title": "Настройки",
|
||||||
|
|||||||
@ -1730,7 +1730,6 @@
|
|||||||
"theme.light": "浅色",
|
"theme.light": "浅色",
|
||||||
"theme.title": "主题",
|
"theme.title": "主题",
|
||||||
"theme.color_primary": "主题颜色",
|
"theme.color_primary": "主题颜色",
|
||||||
"theme.window.style.opaque": "不透明窗口",
|
|
||||||
"theme.window.style.title": "窗口样式",
|
"theme.window.style.title": "窗口样式",
|
||||||
"theme.window.style.transparent": "透明窗口",
|
"theme.window.style.transparent": "透明窗口",
|
||||||
"title": "设置",
|
"title": "设置",
|
||||||
|
|||||||
@ -1721,7 +1721,6 @@
|
|||||||
"theme.light": "淺色",
|
"theme.light": "淺色",
|
||||||
"theme.title": "主題",
|
"theme.title": "主題",
|
||||||
"theme.color_primary": "主題顏色",
|
"theme.color_primary": "主題顏色",
|
||||||
"theme.window.style.opaque": "不透明視窗",
|
|
||||||
"theme.window.style.title": "視窗樣式",
|
"theme.window.style.title": "視窗樣式",
|
||||||
"theme.window.style.transparent": "透明視窗",
|
"theme.window.style.transparent": "透明視窗",
|
||||||
"title": "設定",
|
"title": "設定",
|
||||||
|
|||||||
@ -1483,7 +1483,6 @@
|
|||||||
"theme.dark": "Σκοτεινό",
|
"theme.dark": "Σκοτεινό",
|
||||||
"theme.light": "Φωτεινό",
|
"theme.light": "Φωτεινό",
|
||||||
"theme.title": "Θέμα",
|
"theme.title": "Θέμα",
|
||||||
"theme.window.style.opaque": "Μη διαφανή παράθυρα",
|
|
||||||
"theme.window.style.title": "Στυλ παραθύρων",
|
"theme.window.style.title": "Στυλ παραθύρων",
|
||||||
"theme.window.style.transparent": "Διαφανή παράθυρα",
|
"theme.window.style.transparent": "Διαφανή παράθυρα",
|
||||||
"title": "Ρυθμίσεις",
|
"title": "Ρυθμίσεις",
|
||||||
|
|||||||
@ -1482,7 +1482,6 @@
|
|||||||
"theme.dark": "Oscuro",
|
"theme.dark": "Oscuro",
|
||||||
"theme.light": "Claro",
|
"theme.light": "Claro",
|
||||||
"theme.title": "Tema",
|
"theme.title": "Tema",
|
||||||
"theme.window.style.opaque": "Ventana opaca",
|
|
||||||
"theme.window.style.title": "Estilo de ventana",
|
"theme.window.style.title": "Estilo de ventana",
|
||||||
"theme.window.style.transparent": "Ventana transparente",
|
"theme.window.style.transparent": "Ventana transparente",
|
||||||
"title": "Configuración",
|
"title": "Configuración",
|
||||||
|
|||||||
@ -1483,7 +1483,6 @@
|
|||||||
"theme.dark": "Sombre",
|
"theme.dark": "Sombre",
|
||||||
"theme.light": "Clair",
|
"theme.light": "Clair",
|
||||||
"theme.title": "Thème",
|
"theme.title": "Thème",
|
||||||
"theme.window.style.opaque": "Fenêtre opaque",
|
|
||||||
"theme.window.style.title": "Style de fenêtre",
|
"theme.window.style.title": "Style de fenêtre",
|
||||||
"theme.window.style.transparent": "Fenêtre transparente",
|
"theme.window.style.transparent": "Fenêtre transparente",
|
||||||
"title": "Paramètres",
|
"title": "Paramètres",
|
||||||
|
|||||||
@ -1484,7 +1484,6 @@
|
|||||||
"theme.dark": "Escuro",
|
"theme.dark": "Escuro",
|
||||||
"theme.light": "Claro",
|
"theme.light": "Claro",
|
||||||
"theme.title": "Tema",
|
"theme.title": "Tema",
|
||||||
"theme.window.style.opaque": "Janela opaca",
|
|
||||||
"theme.window.style.title": "Estilo de janela",
|
"theme.window.style.title": "Estilo de janela",
|
||||||
"theme.window.style.transparent": "Janela transparente",
|
"theme.window.style.transparent": "Janela transparente",
|
||||||
"title": "Configurações",
|
"title": "Configurações",
|
||||||
|
|||||||
@ -59,7 +59,7 @@ const MainSidebar: FC = () => {
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [tab, setTab] = useState<Tab>('assistants')
|
const [tab, setTab] = useState<Tab>('assistants')
|
||||||
const avatar = useAvatar()
|
const avatar = useAvatar()
|
||||||
const { userName, defaultPaintingProvider } = useSettings()
|
const { userName, defaultPaintingProvider, transparentWindow } = useSettings()
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { theme, settedTheme, toggleTheme } = useTheme()
|
const { theme, settedTheme, toggleTheme } = useTheme()
|
||||||
const [isAppMenuExpanded, setIsAppMenuExpanded] = useState(false)
|
const [isAppMenuExpanded, setIsAppMenuExpanded] = useState(false)
|
||||||
@ -167,6 +167,7 @@ const MainSidebar: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<Container
|
<Container
|
||||||
id="main-sidebar"
|
id="main-sidebar"
|
||||||
|
transparent={transparentWindow}
|
||||||
style={{
|
style={{
|
||||||
width: showAssistants ? 'var(--assistants-width)' : '0px',
|
width: showAssistants ? 'var(--assistants-width)' : '0px',
|
||||||
opacity: showAssistants ? 1 : 0,
|
opacity: showAssistants ? 1 : 0,
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export const MainMenuItemText = styled.div`
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
`
|
`
|
||||||
|
|
||||||
export const Container = styled.div`
|
export const Container = styled.div<{ transparent?: boolean }>`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -53,6 +53,7 @@ export const Container = styled.div`
|
|||||||
max-width: var(--assistants-width);
|
max-width: var(--assistants-width);
|
||||||
border-right: 0.5px solid var(--color-border);
|
border-right: 0.5px solid var(--color-border);
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
background-color: ${({ transparent }) => (transparent ? 'transparent' : 'var(--color-background)')};
|
||||||
`
|
`
|
||||||
|
|
||||||
export const MainMenu = styled.div`
|
export const MainMenu = styled.div`
|
||||||
|
|||||||
@ -55,8 +55,8 @@ const ColorCircle = styled.div<{ color: string; isActive?: boolean }>`
|
|||||||
|
|
||||||
const DisplaySettings: FC = () => {
|
const DisplaySettings: FC = () => {
|
||||||
const {
|
const {
|
||||||
windowStyle,
|
transparentWindow,
|
||||||
setWindowStyle,
|
setTransparentWindow,
|
||||||
topicPosition,
|
topicPosition,
|
||||||
setTopicPosition,
|
setTopicPosition,
|
||||||
clickAssistantToShowTopic,
|
clickAssistantToShowTopic,
|
||||||
@ -77,13 +77,6 @@ const DisplaySettings: FC = () => {
|
|||||||
const [visibleIcons, setVisibleIcons] = useState(sidebarIcons?.visible || DEFAULT_SIDEBAR_ICONS)
|
const [visibleIcons, setVisibleIcons] = useState(sidebarIcons?.visible || DEFAULT_SIDEBAR_ICONS)
|
||||||
const [disabledIcons, setDisabledIcons] = useState(sidebarIcons?.disabled || [])
|
const [disabledIcons, setDisabledIcons] = useState(sidebarIcons?.disabled || [])
|
||||||
|
|
||||||
const handleWindowStyleChange = useCallback(
|
|
||||||
(checked: boolean) => {
|
|
||||||
setWindowStyle(checked ? 'transparent' : 'opaque')
|
|
||||||
},
|
|
||||||
[setWindowStyle]
|
|
||||||
)
|
|
||||||
|
|
||||||
const handleColorPrimaryChange = useCallback(
|
const handleColorPrimaryChange = useCallback(
|
||||||
(colorHex: string) => {
|
(colorHex: string) => {
|
||||||
setUserTheme({
|
setUserTheme({
|
||||||
@ -211,7 +204,7 @@ const DisplaySettings: FC = () => {
|
|||||||
<SettingDivider />
|
<SettingDivider />
|
||||||
<SettingRow>
|
<SettingRow>
|
||||||
<SettingRowTitle>{t('settings.theme.window.style.transparent')}</SettingRowTitle>
|
<SettingRowTitle>{t('settings.theme.window.style.transparent')}</SettingRowTitle>
|
||||||
<Switch checked={windowStyle === 'transparent'} onChange={handleWindowStyleChange} />
|
<Switch checked={transparentWindow} onChange={setTransparentWindow} />
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -178,6 +178,7 @@ export interface SettingsState {
|
|||||||
knowledgeEmbed: boolean
|
knowledgeEmbed: boolean
|
||||||
}
|
}
|
||||||
defaultPaintingProvider: PaintingProvider
|
defaultPaintingProvider: PaintingProvider
|
||||||
|
transparentWindow: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
||||||
@ -316,7 +317,8 @@ export const initialState: SettingsState = {
|
|||||||
backup: false,
|
backup: false,
|
||||||
knowledgeEmbed: false
|
knowledgeEmbed: false
|
||||||
},
|
},
|
||||||
defaultPaintingProvider: 'aihubmix'
|
defaultPaintingProvider: 'aihubmix',
|
||||||
|
transparentWindow: true
|
||||||
}
|
}
|
||||||
|
|
||||||
const settingsSlice = createSlice({
|
const settingsSlice = createSlice({
|
||||||
@ -665,6 +667,9 @@ const settingsSlice = createSlice({
|
|||||||
},
|
},
|
||||||
setDefaultPaintingProvider: (state, action: PayloadAction<PaintingProvider>) => {
|
setDefaultPaintingProvider: (state, action: PayloadAction<PaintingProvider>) => {
|
||||||
state.defaultPaintingProvider = action.payload
|
state.defaultPaintingProvider = action.payload
|
||||||
|
},
|
||||||
|
setTransparentWindow: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.transparentWindow = action.payload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -768,7 +773,8 @@ export const {
|
|||||||
setOpenAISummaryText,
|
setOpenAISummaryText,
|
||||||
setOpenAIServiceTier,
|
setOpenAIServiceTier,
|
||||||
setNotificationSettings,
|
setNotificationSettings,
|
||||||
setDefaultPaintingProvider
|
setDefaultPaintingProvider,
|
||||||
|
setTransparentWindow
|
||||||
} = settingsSlice.actions
|
} = settingsSlice.actions
|
||||||
|
|
||||||
export default settingsSlice.reducer
|
export default settingsSlice.reducer
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user