mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 13:59:28 +08:00
feat: add app version
This commit is contained in:
parent
c7332636b2
commit
43ceb4bcf3
@ -76,8 +76,10 @@ app.whenReady().then(() => {
|
|||||||
optimizer.watchWindowShortcuts(window)
|
optimizer.watchWindowShortcuts(window)
|
||||||
})
|
})
|
||||||
|
|
||||||
// IPC test
|
// IPC
|
||||||
ipcMain.on('ping', () => console.log('pong'))
|
ipcMain.handle('get-app-info', () => ({
|
||||||
|
version: app.getVersion()
|
||||||
|
}))
|
||||||
|
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
||||||
|
|||||||
6
src/preload/index.d.ts
vendored
6
src/preload/index.d.ts
vendored
@ -3,6 +3,10 @@ import { ElectronAPI } from '@electron-toolkit/preload'
|
|||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
electron: ElectronAPI
|
electron: ElectronAPI
|
||||||
api: any
|
api: {
|
||||||
|
getAppInfo: () => Promise<{
|
||||||
|
version: string
|
||||||
|
}>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import { contextBridge } from 'electron'
|
import { contextBridge, ipcRenderer } from 'electron'
|
||||||
import { electronAPI } from '@electron-toolkit/preload'
|
import { electronAPI } from '@electron-toolkit/preload'
|
||||||
|
|
||||||
// Custom APIs for renderer
|
// Custom APIs for renderer
|
||||||
const api = {}
|
const api = {
|
||||||
|
getAppInfo: () => ipcRenderer.invoke('get-app-info')
|
||||||
|
}
|
||||||
|
|
||||||
// Use `contextBridge` APIs to expose Electron APIs to
|
// Use `contextBridge` APIs to expose Electron APIs to
|
||||||
// renderer only if context isolation is enabled, otherwise
|
// renderer only if context isolation is enabled, otherwise
|
||||||
|
|||||||
@ -11,7 +11,7 @@ const MessageItem: FC<{ message: Message }> = ({ message }) => {
|
|||||||
<AvatarWrapper>
|
<AvatarWrapper>
|
||||||
{message.role === 'assistant' ? <Avatar src={Logo} /> : <Avatar alt="Alice Swift">Y</Avatar>}
|
{message.role === 'assistant' ? <Avatar src={Logo} /> : <Avatar alt="Alice Swift">Y</Avatar>}
|
||||||
</AvatarWrapper>
|
</AvatarWrapper>
|
||||||
<div className="markdown" dangerouslySetInnerHTML={{ __html: marked(message.content) }}></div>
|
<div className="markdown" dangerouslySetInnerHTML={{ __html: marked(message.content) }} />
|
||||||
</MessageContainer>
|
</MessageContainer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,66 @@
|
|||||||
import { FC } from 'react'
|
import { Avatar } from 'antd'
|
||||||
|
import { FC, useEffect, useState } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
import Logo from '@renderer/assets/images/logo.png'
|
||||||
|
import { runAsyncFunction } from '@renderer/utils'
|
||||||
|
import { marked } from 'marked'
|
||||||
|
|
||||||
|
const changeLog = ``
|
||||||
|
|
||||||
const AboutSettings: FC = () => {
|
const AboutSettings: FC = () => {
|
||||||
return <Container>About</Container>
|
const [version, setVersion] = useState('')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
runAsyncFunction(async () => {
|
||||||
|
const appInfo = await window.api.getAppInfo()
|
||||||
|
setVersion(appInfo.version)
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Avatar src={Logo} size={100} style={{ marginTop: 50 }} />
|
||||||
|
<Title>
|
||||||
|
Cherry Studio <Version>(v{version})</Version>
|
||||||
|
</Title>
|
||||||
|
<Description>A powerful AI assistant for producer.</Description>
|
||||||
|
<div
|
||||||
|
className="markdown"
|
||||||
|
style={{ width: '80%' }}
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: marked(changeLog)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
`
|
||||||
|
|
||||||
|
const Title = styled.div`
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--color-text-1);
|
||||||
|
margin: 10px 0;
|
||||||
|
`
|
||||||
|
|
||||||
|
const Version = styled.span`
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--color-text-2);
|
||||||
|
margin: 10px 0;
|
||||||
|
text-align: center;
|
||||||
|
`
|
||||||
|
|
||||||
|
const Description = styled.div`
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--color-text-2);
|
||||||
|
text-align: center;
|
||||||
`
|
`
|
||||||
|
|
||||||
export default AboutSettings
|
export default AboutSettings
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user