mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-05 04:19:02 +08:00
feat: update system tray icon functionality and ui
This commit is contained in:
parent
7b6d38e349
commit
348fc365fa
@ -332,7 +332,7 @@
|
|||||||
"about.license.button": "License",
|
"about.license.button": "License",
|
||||||
"about.contact.button": "Email",
|
"about.contact.button": "Email",
|
||||||
"proxy.title": "Proxy Address",
|
"proxy.title": "Proxy Address",
|
||||||
"tray.title": "Tray Icon",
|
"tray.title": "Enable System Tray Icon",
|
||||||
"theme.title": "Theme",
|
"theme.title": "Theme",
|
||||||
"theme.dark": "Dark",
|
"theme.dark": "Dark",
|
||||||
"theme.light": "Light",
|
"theme.light": "Light",
|
||||||
|
|||||||
@ -320,7 +320,7 @@
|
|||||||
"about.license.button": "查看",
|
"about.license.button": "查看",
|
||||||
"about.contact.button": "邮件",
|
"about.contact.button": "邮件",
|
||||||
"proxy.title": "代理地址",
|
"proxy.title": "代理地址",
|
||||||
"tray.title": "任务栏图标",
|
"tray.title": "启用系统托盘图标",
|
||||||
"theme.title": "主题",
|
"theme.title": "主题",
|
||||||
"theme.dark": "深色主题",
|
"theme.dark": "深色主题",
|
||||||
"theme.light": "浅色主题",
|
"theme.light": "浅色主题",
|
||||||
|
|||||||
@ -320,7 +320,7 @@
|
|||||||
"about.license.button": "查看",
|
"about.license.button": "查看",
|
||||||
"about.contact.button": "郵件",
|
"about.contact.button": "郵件",
|
||||||
"proxy.title": "代理地址",
|
"proxy.title": "代理地址",
|
||||||
"tray.title": "工作列圖示",
|
"tray.title": "啟用系統托盤圖標",
|
||||||
"theme.title": "主題",
|
"theme.title": "主題",
|
||||||
"theme.dark": "深色主題",
|
"theme.dark": "深色主題",
|
||||||
"theme.light": "淺色主題",
|
"theme.light": "淺色主題",
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
import { QuestionCircleOutlined } from '@ant-design/icons'
|
import { QuestionCircleOutlined } from '@ant-design/icons'
|
||||||
import { HStack } from '@renderer/components/Layout'
|
import { HStack } from '@renderer/components/Layout'
|
||||||
|
import { TopView } from '@renderer/components/TopView'
|
||||||
import { DEFAULT_CONTEXTCOUNT, DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE } from '@renderer/config/constant'
|
import { DEFAULT_CONTEXTCOUNT, DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE } from '@renderer/config/constant'
|
||||||
import { useDefaultAssistant } from '@renderer/hooks/useAssistant'
|
import { useDefaultAssistant } from '@renderer/hooks/useAssistant'
|
||||||
import { AssistantSettings as AssistantSettingsType } from '@renderer/types'
|
import { AssistantSettings as AssistantSettingsType } from '@renderer/types'
|
||||||
import { Button, Col, Input, InputNumber, Row, Slider, Switch, Tooltip } from 'antd'
|
import { Button, Col, Input, InputNumber, Modal, Row, Slider, Switch, Tooltip } from 'antd'
|
||||||
import TextArea from 'antd/es/input/TextArea'
|
import TextArea from 'antd/es/input/TextArea'
|
||||||
import { Dispatch, FC, SetStateAction, useState } from 'react'
|
import { Dispatch, FC, SetStateAction, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
import { SettingContainer, SettingDivider, SettingSubtitle, SettingTitle } from '.'
|
import { SettingContainer, SettingSubtitle } from '.'
|
||||||
|
|
||||||
const AssistantSettings: FC = () => {
|
const AssistantSettings: FC = () => {
|
||||||
const { defaultAssistant, updateDefaultAssistant } = useDefaultAssistant()
|
const { defaultAssistant, updateDefaultAssistant } = useDefaultAssistant()
|
||||||
@ -66,9 +67,7 @@ const AssistantSettings: FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingContainer>
|
<SettingContainer style={{ height: 'auto' }}>
|
||||||
<SettingTitle>{t('settings.assistant.title')}</SettingTitle>
|
|
||||||
<SettingDivider />
|
|
||||||
<SettingSubtitle style={{ marginTop: 0 }}>{t('common.name')}</SettingSubtitle>
|
<SettingSubtitle style={{ marginTop: 0 }}>{t('common.name')}</SettingSubtitle>
|
||||||
<Input
|
<Input
|
||||||
placeholder={t('common.assistant') + t('common.name')}
|
placeholder={t('common.assistant') + t('common.name')}
|
||||||
@ -202,6 +201,61 @@ const AssistantSettings: FC = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
resolve: (data: any) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const PopupContainer: React.FC<Props> = ({ resolve }) => {
|
||||||
|
const [open, setOpen] = useState(true)
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
const onOk = () => {
|
||||||
|
setOpen(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onCancel = () => {
|
||||||
|
setOpen(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onClose = () => {
|
||||||
|
resolve({})
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title={t('settings.assistant.title')}
|
||||||
|
open={open}
|
||||||
|
onOk={onOk}
|
||||||
|
onCancel={onCancel}
|
||||||
|
afterClose={onClose}
|
||||||
|
centered
|
||||||
|
width={800}
|
||||||
|
footer={null}>
|
||||||
|
<AssistantSettings />
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class AssistantSettingsPopup {
|
||||||
|
static topviewId = 0
|
||||||
|
static hide() {
|
||||||
|
TopView.hide('AssistantSettingsPopup')
|
||||||
|
}
|
||||||
|
static show() {
|
||||||
|
return new Promise<any>((resolve) => {
|
||||||
|
TopView.show(
|
||||||
|
<PopupContainer
|
||||||
|
resolve={(v) => {
|
||||||
|
resolve(v)
|
||||||
|
this.hide()
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
'AssistantSettingsPopup'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Label = styled.p`
|
const Label = styled.p`
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@ -213,5 +267,3 @@ const QuestionIcon = styled(QuestionCircleOutlined)`
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--color-text-3);
|
color: var(--color-text-3);
|
||||||
`
|
`
|
||||||
|
|
||||||
export default AssistantSettings
|
|
||||||
|
|||||||
@ -1,14 +1,16 @@
|
|||||||
import { EditOutlined, MessageOutlined, TranslationOutlined } from '@ant-design/icons'
|
import { EditOutlined, MessageOutlined, SettingOutlined, TranslationOutlined } from '@ant-design/icons'
|
||||||
|
import { HStack } from '@renderer/components/Layout'
|
||||||
import { useDefaultModel } from '@renderer/hooks/useAssistant'
|
import { useDefaultModel } from '@renderer/hooks/useAssistant'
|
||||||
import { useProviders } from '@renderer/hooks/useProvider'
|
import { useProviders } from '@renderer/hooks/useProvider'
|
||||||
import { getModelUniqId, hasModel } from '@renderer/services/ModelService'
|
import { getModelUniqId, hasModel } from '@renderer/services/ModelService'
|
||||||
import { Model } from '@renderer/types'
|
import { Model } from '@renderer/types'
|
||||||
import { Select } from 'antd'
|
import { Button, Select } from 'antd'
|
||||||
import { find, sortBy } from 'lodash'
|
import { find, sortBy } from 'lodash'
|
||||||
import { FC, useMemo } from 'react'
|
import { FC, useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
import { SettingContainer, SettingDivider, SettingTitle } from '.'
|
import { SettingContainer, SettingDivider, SettingTitle } from '.'
|
||||||
|
import AssistantSettingsPopup from './AssistantSettings'
|
||||||
|
|
||||||
const ModelSettings: FC = () => {
|
const ModelSettings: FC = () => {
|
||||||
const { defaultModel, topicNamingModel, translateModel, setDefaultModel, setTopicNamingModel, setTranslateModel } =
|
const { defaultModel, topicNamingModel, translateModel, setDefaultModel, setTopicNamingModel, setTranslateModel } =
|
||||||
@ -52,14 +54,17 @@ const ModelSettings: FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</SettingTitle>
|
</SettingTitle>
|
||||||
<SettingDivider />
|
<SettingDivider />
|
||||||
<Select
|
<HStack alignItems="center">
|
||||||
value={defaultModelValue}
|
<Select
|
||||||
defaultValue={defaultModelValue}
|
value={defaultModelValue}
|
||||||
style={{ width: 360 }}
|
defaultValue={defaultModelValue}
|
||||||
onChange={(value) => setDefaultModel(find(allModels, JSON.parse(value)) as Model)}
|
style={{ width: 360 }}
|
||||||
options={selectOptions}
|
onChange={(value) => setDefaultModel(find(allModels, JSON.parse(value)) as Model)}
|
||||||
placeholder={t('settings.models.empty')}
|
options={selectOptions}
|
||||||
/>
|
placeholder={t('settings.models.empty')}
|
||||||
|
/>
|
||||||
|
<Button icon={<SettingOutlined />} style={{ marginLeft: 8 }} onClick={() => AssistantSettingsPopup.show()} />
|
||||||
|
</HStack>
|
||||||
<div style={{ height: 30 }} />
|
<div style={{ height: 30 }} />
|
||||||
<SettingTitle>
|
<SettingTitle>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@ -1,11 +1,4 @@
|
|||||||
import {
|
import { CloudOutlined, InfoCircleOutlined, MacCommandOutlined, SaveOutlined, SettingOutlined } from '@ant-design/icons'
|
||||||
CloudOutlined,
|
|
||||||
InfoCircleOutlined,
|
|
||||||
MacCommandOutlined,
|
|
||||||
MessageOutlined,
|
|
||||||
SaveOutlined,
|
|
||||||
SettingOutlined
|
|
||||||
} from '@ant-design/icons'
|
|
||||||
import { Navbar, NavbarCenter } from '@renderer/components/app/Navbar'
|
import { Navbar, NavbarCenter } from '@renderer/components/app/Navbar'
|
||||||
import { isLocalAi } from '@renderer/config/env'
|
import { isLocalAi } from '@renderer/config/env'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
@ -14,7 +7,6 @@ import { Link, Route, Routes, useLocation } from 'react-router-dom'
|
|||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
import AboutSettings from './AboutSettings'
|
import AboutSettings from './AboutSettings'
|
||||||
import AssistantSettings from './AssistantSettings'
|
|
||||||
import DataSettings from './DataSettings/DataSettings'
|
import DataSettings from './DataSettings/DataSettings'
|
||||||
import GeneralSettings from './GeneralSettings'
|
import GeneralSettings from './GeneralSettings'
|
||||||
import ModelSettings from './ModelSettings'
|
import ModelSettings from './ModelSettings'
|
||||||
@ -50,12 +42,6 @@ const SettingsPage: FC = () => {
|
|||||||
</MenuItemLink>
|
</MenuItemLink>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<MenuItemLink to="/settings/assistant">
|
|
||||||
<MenuItem className={isRoute('/settings/assistant')}>
|
|
||||||
<MessageOutlined />
|
|
||||||
{t('settings.assistant')}
|
|
||||||
</MenuItem>
|
|
||||||
</MenuItemLink>
|
|
||||||
<MenuItemLink to="/settings/general">
|
<MenuItemLink to="/settings/general">
|
||||||
<MenuItem className={isRoute('/settings/general')}>
|
<MenuItem className={isRoute('/settings/general')}>
|
||||||
<SettingOutlined />
|
<SettingOutlined />
|
||||||
@ -85,7 +71,6 @@ const SettingsPage: FC = () => {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route path="provider" element={<ProvidersList />} />
|
<Route path="provider" element={<ProvidersList />} />
|
||||||
<Route path="model" element={<ModelSettings />} />
|
<Route path="model" element={<ModelSettings />} />
|
||||||
<Route path="assistant" element={<AssistantSettings />} />
|
|
||||||
<Route path="general/*" element={<GeneralSettings />} />
|
<Route path="general/*" element={<GeneralSettings />} />
|
||||||
<Route path="data/*" element={<DataSettings />} />
|
<Route path="data/*" element={<DataSettings />} />
|
||||||
<Route path="shortcut" element={<ShortcutSettings />} />
|
<Route path="shortcut" element={<ShortcutSettings />} />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user