feat: hide window title

This commit is contained in:
kangfenmao 2024-07-23 16:40:06 +08:00
parent c43be11d20
commit 93505a4bc6
8 changed files with 31 additions and 19 deletions

View File

@ -24,7 +24,12 @@ function createWindow() {
minHeight: 500, minHeight: 500,
show: true, show: true,
autoHideMenuBar: true, autoHideMenuBar: true,
titleBarStyle: 'hiddenInset', titleBarStyle: 'hidden',
titleBarOverlay: {
height: 41,
color: '#1f1f1f',
symbolColor: '#eee'
},
trafficLightPosition: { x: 8, y: 12 }, trafficLightPosition: { x: 8, y: 12 },
...(process.platform === 'linux' ? { icon } : {}), ...(process.platform === 'linux' ? { icon } : {}),
webPreferences: { webPreferences: {

View File

@ -30,7 +30,6 @@ const NavbarContainer = styled.div`
margin-left: calc(var(--sidebar-width) * -1); margin-left: calc(var(--sidebar-width) * -1);
padding-left: var(--sidebar-width); padding-left: var(--sidebar-width);
border-bottom: 0.5px solid var(--color-border); border-bottom: 0.5px solid var(--color-border);
border-top: 0.5px solid var(--color-border);
` `
const NavbarLeftContainer = styled.div` const NavbarLeftContainer = styled.div`

View File

@ -13,7 +13,7 @@ const Sidebar: FC = () => {
return ( return (
<Container style={isWindows ? { paddingTop: 0 } : {}}> <Container style={isWindows ? { paddingTop: 0 } : {}}>
{isMac && <PlaceholderBorder />} {isMac ? <PlaceholderBorderMac /> : <PlaceholderBorderWin />}
<StyledLink to="/"> <StyledLink to="/">
<AvatarImg src={avatar || Logo} draggable={false} /> <AvatarImg src={avatar || Logo} draggable={false} />
</StyledLink> </StyledLink>
@ -52,7 +52,6 @@ const Container = styled.div`
-webkit-app-region: drag !important; -webkit-app-region: drag !important;
background-color: #1f1f1f; background-color: #1f1f1f;
border-right: 0.5px solid var(--color-border); border-right: 0.5px solid var(--color-border);
border-top: 0.5px solid var(--color-border);
padding-top: var(--navbar-height); padding-top: var(--navbar-height);
position: relative; position: relative;
` `
@ -115,7 +114,7 @@ const StyledLink = styled(Link)`
} }
` `
const PlaceholderBorder = styled.div` const PlaceholderBorderMac = styled.div`
width: var(--sidebar-width); width: var(--sidebar-width);
height: var(--navbar-height); height: var(--navbar-height);
border-right: 1px solid #1f1f1f; border-right: 1px solid #1f1f1f;
@ -125,4 +124,13 @@ const PlaceholderBorder = styled.div`
left: 0.5px; left: 0.5px;
` `
const PlaceholderBorderWin = styled.div`
width: var(--sidebar-width);
height: var(--navbar-height);
position: absolute;
border-right: 1px solid #1f1f1f;
top: 0;
right: -1px;
`
export default Sidebar export default Sidebar

View File

@ -9,8 +9,7 @@ import { useShowAssistants, useShowRightSidebar } from '@renderer/hooks/useStore
import { Tooltip } from 'antd' import { Tooltip } from 'antd'
import Navigation from './components/NavigationCenter' import Navigation from './components/NavigationCenter'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { PlusCircleOutlined } from '@ant-design/icons' import { isMac, isWindows } from '@renderer/config/constant'
import { isMac } from '@renderer/config/constant'
const HomePage: FC = () => { const HomePage: FC = () => {
const { assistants, addAssistant } = useAssistants() const { assistants, addAssistant } = useAssistants()
@ -35,12 +34,12 @@ const HomePage: FC = () => {
<i className="iconfont icon-hidesidebarhoriz" /> <i className="iconfont icon-hidesidebarhoriz" />
</NewButton> </NewButton>
<NewButton onClick={onCreateAssistant}> <NewButton onClick={onCreateAssistant}>
<PlusCircleOutlined /> <i className="iconfont icon-a-addchat"></i>
</NewButton> </NewButton>
</NavbarLeft> </NavbarLeft>
)} )}
<Navigation activeAssistant={activeAssistant} /> <Navigation activeAssistant={activeAssistant} />
<NavbarRight style={{ justifyContent: 'flex-end', padding: '0 7px' }}> <NavbarRight style={{ justifyContent: 'flex-end', paddingRight: isWindows ? 140 : 8 }}>
<Tooltip <Tooltip
placement="left" placement="left"
title={showRightSidebar ? t('assistant.topics.hide_topics') : t('assistant.topics.show_topics')} title={showRightSidebar ? t('assistant.topics.hide_topics') : t('assistant.topics.show_topics')}
@ -88,6 +87,9 @@ export const NewButton = styled.div`
align-items: center; align-items: center;
transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out;
color: var(--color-icon); color: var(--color-icon);
.icon-a-addchat {
font-size: 20px;
}
.anticon { .anticon {
font-size: 19px; font-size: 19px;
} }

View File

@ -147,7 +147,7 @@ const AssistantItem = styled.div`
const AssistantName = styled.div` const AssistantName = styled.div`
font-size: 14px; font-size: 14px;
color: var(--color-text-1); color: var(--color-text-1);
font-weight: bold; font-weight: 600;
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 1; -webkit-line-clamp: 1;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;

View File

@ -4,9 +4,9 @@ import {
FullscreenExitOutlined, FullscreenExitOutlined,
FullscreenOutlined, FullscreenOutlined,
HistoryOutlined, HistoryOutlined,
MessageOutlined,
MoreOutlined, MoreOutlined,
PauseCircleOutlined PauseCircleOutlined,
PlusCircleOutlined
} from '@ant-design/icons' } from '@ant-design/icons'
import { useAssistant } from '@renderer/hooks/useAssistant' import { useAssistant } from '@renderer/hooks/useAssistant'
import { useSettings } from '@renderer/hooks/useSettings' import { useSettings } from '@renderer/hooks/useSettings'
@ -134,7 +134,7 @@ const Inputbar: FC<Props> = ({ assistant, setActiveTopic }) => {
<ToolbarMenu> <ToolbarMenu>
<Tooltip placement="top" title={t('assistant.input.new_chat')} arrow> <Tooltip placement="top" title={t('assistant.input.new_chat')} arrow>
<ToolbarButton type="text" onClick={addNewTopic}> <ToolbarButton type="text" onClick={addNewTopic}>
<MessageOutlined /> <PlusCircleOutlined />
</ToolbarButton> </ToolbarButton>
</Tooltip> </Tooltip>
<Tooltip placement="top" title={t('assistant.input.topics')} arrow> <Tooltip placement="top" title={t('assistant.input.topics')} arrow>

View File

@ -14,7 +14,6 @@ import { firstLetter } from '@renderer/utils'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { isEmpty, upperFirst } from 'lodash' import { isEmpty, upperFirst } from 'lodash'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { useAppSelector } from '@renderer/store'
import { useAssistant } from '@renderer/hooks/useAssistant' import { useAssistant } from '@renderer/hooks/useAssistant'
import { useSettings } from '@renderer/hooks/useSettings' import { useSettings } from '@renderer/hooks/useSettings'
@ -29,12 +28,10 @@ interface Props {
const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) => { const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) => {
const avatar = useAvatar() const avatar = useAvatar()
const { t } = useTranslation() const { t } = useTranslation()
const generating = useAppSelector((state) => state.runtime.generating)
const { assistant } = useAssistant(message.assistantId) const { assistant } = useAssistant(message.assistantId)
const { userName, showMessageDivider } = useSettings() const { userName, showMessageDivider } = useSettings()
const isLastMessage = index === 0 const isLastMessage = index === 0
const isUserMessage = message.role === 'user'
const canRegenerate = isLastMessage && message.role === 'assistant' const canRegenerate = isLastMessage && message.role === 'assistant'
const onCopy = () => { const onCopy = () => {
@ -81,10 +78,8 @@ const MessageItem: FC<Props> = ({ message, index, showMenu, onDeleteMessage }) =
return userName || t('common.you') return userName || t('common.you')
} }
const borderBottom = (isLastMessage && !isUserMessage) || generating || !showMessageDivider ? 'none' : undefined
return ( return (
<MessageContainer key={message.id} style={{ borderBottom }}> <MessageContainer key={message.id} className="message" style={{ border: showMessageDivider ? undefined : 'none' }}>
<MessageHeader> <MessageHeader>
<AvatarWrapper> <AvatarWrapper>
{message.role === 'assistant' ? ( {message.role === 'assistant' ? (

View File

@ -120,6 +120,9 @@ const Container = styled.div`
max-height: calc(100vh - var(--input-bar-height) - var(--navbar-height)); max-height: calc(100vh - var(--input-bar-height) - var(--navbar-height));
padding-top: 10px; padding-top: 10px;
padding-bottom: 20px; padding-bottom: 20px;
.message:first-child {
border: none;
}
` `
export default Messages export default Messages