From d21a4dce929fb260cdb0f34c7bd982a5ca81c3a4 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Wed, 24 Jul 2024 19:17:58 +0800 Subject: [PATCH] feat(ui): optimize messages ui styles --- package.json | 1 - src/renderer/src/App.tsx | 1 - src/renderer/src/assets/styles/index.scss | 16 +++------------- src/renderer/src/assets/styles/markdown.scss | 2 +- src/renderer/src/assets/styles/scrollbar.scss | 4 ++-- src/renderer/src/hooks/useAppInit.ts | 5 ----- .../src/pages/home/components/Message.tsx | 12 ++++++------ .../src/pages/home/components/RightSidebar.tsx | 4 ++-- .../src/pages/home/components/SettingsTab.tsx | 14 +++++++++----- yarn.lock | 8 -------- 10 files changed, 23 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index c811b220c..b23a23934 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "@electron-toolkit/eslint-config-prettier": "^2.0.0", "@electron-toolkit/eslint-config-ts": "^1.0.1", "@electron-toolkit/tsconfig": "^1.0.1", - "@fontsource/inter": "^5.0.18", "@hello-pangea/dnd": "^16.6.0", "@kangfenmao/keyv-storage": "^0.1.0", "@reduxjs/toolkit": "^2.2.5", diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index a886947d4..515ea5087 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -1,4 +1,3 @@ -import '@fontsource/inter' import store, { persistor } from '@renderer/store' import { ConfigProvider } from 'antd' import { Provider } from 'react-redux' diff --git a/src/renderer/src/assets/styles/index.scss b/src/renderer/src/assets/styles/index.scss index 73984b367..5d1f089ae 100644 --- a/src/renderer/src/assets/styles/index.scss +++ b/src/renderer/src/assets/styles/index.scss @@ -1,5 +1,6 @@ @import 'https://at.alicdn.com/t/c/font_4563475_hrx8c92awui.css'; @import './markdown.scss'; +@import './scrollbar.scss'; // @font-face { // font-family: 'Playwrite'; @@ -67,19 +68,8 @@ body { line-height: 1.6; overflow: hidden; background-size: cover; - font-family: - Inter, - -apple-system, - BlinkMacSystemFont, - 'Segoe UI', - Roboto, - Oxygen, - Ubuntu, - Cantarell, - 'Fira Sans', - 'Droid Sans', - 'Helvetica Neue', - sans-serif; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', + 'Droid Sans', 'Helvetica Neue', sans-serif; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; diff --git a/src/renderer/src/assets/styles/markdown.scss b/src/renderer/src/assets/styles/markdown.scss index 51bfd2dd3..32e074e36 100644 --- a/src/renderer/src/assets/styles/markdown.scss +++ b/src/renderer/src/assets/styles/markdown.scss @@ -1,6 +1,6 @@ .markdown { color: #f1f1f1; - font-size: 16px; + font-size: 15px; line-height: 1.6; user-select: text; diff --git a/src/renderer/src/assets/styles/scrollbar.scss b/src/renderer/src/assets/styles/scrollbar.scss index 2259254c2..29a95c94c 100644 --- a/src/renderer/src/assets/styles/scrollbar.scss +++ b/src/renderer/src/assets/styles/scrollbar.scss @@ -8,8 +8,8 @@ } ::-webkit-scrollbar-thumb { - background: rgba(255, 255, 255, 0.2); + background: rgba(255, 255, 255, 0.15); &:hover { - background: rgba(255, 255, 255, 0.4); + background: rgba(255, 255, 255, 0.3); } } diff --git a/src/renderer/src/hooks/useAppInit.ts b/src/renderer/src/hooks/useAppInit.ts index 12006e4d7..d77aaac83 100644 --- a/src/renderer/src/hooks/useAppInit.ts +++ b/src/renderer/src/hooks/useAppInit.ts @@ -5,7 +5,6 @@ import { setAvatar } from '@renderer/store/runtime' import { runAsyncFunction } from '@renderer/utils' import { useEffect } from 'react' import { useSettings } from './useSettings' -import { isWindows } from '@renderer/config/constant' export function useAppInit() { const dispatch = useAppDispatch() @@ -29,8 +28,4 @@ export function useAppInit() { useEffect(() => { proxyUrl && window.api.setProxy(proxyUrl) }, [proxyUrl]) - - useEffect(() => { - isWindows && import('@renderer/assets/styles/scrollbar.scss') - }, []) } diff --git a/src/renderer/src/pages/home/components/Message.tsx b/src/renderer/src/pages/home/components/Message.tsx index cffd45c18..854d3b1fa 100644 --- a/src/renderer/src/pages/home/components/Message.tsx +++ b/src/renderer/src/pages/home/components/Message.tsx @@ -97,11 +97,6 @@ const MessageItem: FC = ({ message, index, showMenu, onDeleteMessage }) = {dayjs(message.createdAt).format('MM/DD HH:mm')} - {message.usage && ( - - Tokens: {message.usage.total_tokens} | ↑{message.usage.prompt_tokens}↓{message.usage.completion_tokens} - - )} {message.status === 'sending' && ( @@ -114,8 +109,13 @@ const MessageItem: FC = ({ message, index, showMenu, onDeleteMessage }) = {getMessageContent(message)} )} + {message.usage && ( + + Tokens: {message.usage.total_tokens} | ↑{message.usage.prompt_tokens}↓{message.usage.completion_tokens} + + )} {showMenu && ( - + {message.role === 'user' && ( diff --git a/src/renderer/src/pages/home/components/RightSidebar.tsx b/src/renderer/src/pages/home/components/RightSidebar.tsx index 3f94e9e7a..08e15b2ae 100644 --- a/src/renderer/src/pages/home/components/RightSidebar.tsx +++ b/src/renderer/src/pages/home/components/RightSidebar.tsx @@ -77,7 +77,7 @@ const Container = styled.div` const Tabs = styled.div` display: flex; flex-direction: row; - border-bottom: 1px solid var(--color-border); + border-bottom: 0.5px solid var(--color-border); padding: 0 10px; ` @@ -93,7 +93,7 @@ const Tab = styled.div` color: #8a8a8a; border-bottom: 1px solid transparent; &.active { - color: white; + color: #a8a8a8; font-weight: 600; } ` diff --git a/src/renderer/src/pages/home/components/SettingsTab.tsx b/src/renderer/src/pages/home/components/SettingsTab.tsx index 4b9ffb724..1fb41a1fb 100644 --- a/src/renderer/src/pages/home/components/SettingsTab.tsx +++ b/src/renderer/src/pages/home/components/SettingsTab.tsx @@ -119,7 +119,7 @@ const SettingsTab: FC = (props) => { = (props) => { {t('settings.messages.title')} - {t('settings.messages.divider')} + {t('settings.messages.divider')} dispatch(setShowMessageDivider(checked))} /> - {t('settings.messages.use_serif_font')} + {t('settings.messages.use_serif_font')} dispatch(setMessageFont(checked ? 'serif' : 'system'))} @@ -157,7 +157,7 @@ const SettingsTab: FC = (props) => { {t('settings.messages.input.title')} - {t('settings.messages.input.show_estimated_tokens')} + {t('settings.messages.input.show_estimated_tokens')} dispatch(setShowInputEstimatedTokens(checked))} @@ -169,7 +169,7 @@ const SettingsTab: FC = (props) => { } const Container = styled.div` - padding: 0 10px; + padding: 0 15px; ` const InputNumberic = styled(InputNumber)` @@ -195,4 +195,8 @@ const QuestionIcon = styled(QuestionCircleOutlined)` color: var(--color-text-3); ` +const SettingRowTitleSmall = styled(SettingRowTitle)` + font-size: 13px; +` + export default SettingsTab diff --git a/yarn.lock b/yarn.lock index 8b52e3057..8f73f3a91 100644 --- a/yarn.lock +++ b/yarn.lock @@ -961,13 +961,6 @@ __metadata: languageName: node linkType: hard -"@fontsource/inter@npm:^5.0.18": - version: 5.0.18 - resolution: "@fontsource/inter@npm:5.0.18" - checksum: 10c0/87863160b18a3a2b2cc0b2949b41b4072f422efb672f183a8fa2ae19bd803da18ec24a65344c42c1686c73e1b65bb4a7cd64ce5c0f015872c5f5dcba4e64bf92 - languageName: node - linkType: hard - "@hello-pangea/dnd@npm:^16.6.0": version: 16.6.0 resolution: "@hello-pangea/dnd@npm:16.6.0" @@ -3413,7 +3406,6 @@ __metadata: "@electron-toolkit/preload": "npm:^3.0.0" "@electron-toolkit/tsconfig": "npm:^1.0.1" "@electron-toolkit/utils": "npm:^3.0.0" - "@fontsource/inter": "npm:^5.0.18" "@hello-pangea/dnd": "npm:^16.6.0" "@kangfenmao/keyv-storage": "npm:^0.1.0" "@reduxjs/toolkit": "npm:^2.2.5"