mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 11:44:28 +08:00
feat: enhance update dialog functionality and state management
- Added ability to ignore updates in the UpdateDialogPopup, updating the state accordingly. - Updated UpdateAppButton to conditionally render based on the ignore state. - Refactored runtime state to include an ignore flag for better update management. - Minor UI adjustments in UpdateAppButton for improved user experience.
This commit is contained in:
parent
0cc4c96bc0
commit
e6003463ac
@ -78,7 +78,7 @@ export abstract class BaseService {
|
||||
* Get database instance
|
||||
* Automatically waits for initialization to complete
|
||||
*/
|
||||
protected async getDatabase() {
|
||||
public async getDatabase() {
|
||||
const dbManager = await DatabaseManager.getInstance()
|
||||
return dbManager.getDatabase()
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { loggerService } from '@logger'
|
||||
import { TopView } from '@renderer/components/TopView'
|
||||
import { handleSaveData } from '@renderer/store'
|
||||
import { handleSaveData, useAppDispatch } from '@renderer/store'
|
||||
import { setUpdateState } from '@renderer/store/runtime'
|
||||
import { Button, Modal } from 'antd'
|
||||
import type { ReleaseNoteInfo, UpdateInfo } from 'builder-util-runtime'
|
||||
import { useEffect, useState } from 'react'
|
||||
@ -22,6 +23,7 @@ const PopupContainer: React.FC<Props> = ({ releaseInfo, resolve }) => {
|
||||
const { t } = useTranslation()
|
||||
const [open, setOpen] = useState(true)
|
||||
const [isInstalling, setIsInstalling] = useState(false)
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
useEffect(() => {
|
||||
if (releaseInfo) {
|
||||
@ -50,6 +52,11 @@ const PopupContainer: React.FC<Props> = ({ releaseInfo, resolve }) => {
|
||||
resolve({})
|
||||
}
|
||||
|
||||
const onIgnore = () => {
|
||||
dispatch(setUpdateState({ ignore: true }))
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
UpdateDialogPopup.hide = onCancel
|
||||
|
||||
const releaseNotes = releaseInfo?.releaseNotes
|
||||
@ -69,7 +76,7 @@ const PopupContainer: React.FC<Props> = ({ releaseInfo, resolve }) => {
|
||||
centered
|
||||
width={720}
|
||||
footer={[
|
||||
<Button key="later" onClick={onCancel} disabled={isInstalling}>
|
||||
<Button key="later" onClick={onIgnore} disabled={isInstalling}>
|
||||
{t('update.later')}
|
||||
</Button>,
|
||||
<Button key="install" type="primary" onClick={handleInstall} loading={isInstalling}>
|
||||
|
||||
@ -20,6 +20,10 @@ const UpdateAppButton: FC = () => {
|
||||
return null
|
||||
}
|
||||
|
||||
if (update.ignore) {
|
||||
return null
|
||||
}
|
||||
|
||||
const handleOpenUpdateDialog = () => {
|
||||
UpdateDialogPopup.show({ releaseInfo: update.info || null })
|
||||
}
|
||||
@ -30,7 +34,7 @@ const UpdateAppButton: FC = () => {
|
||||
className="nodrag"
|
||||
onClick={handleOpenUpdateDialog}
|
||||
icon={<SyncOutlined />}
|
||||
color="orange"
|
||||
color="primary"
|
||||
variant="outlined"
|
||||
size="small">
|
||||
{t('button.update_available')}
|
||||
|
||||
@ -7,7 +7,6 @@ import {
|
||||
UNLIMITED_CONTEXT_COUNT
|
||||
} from '@renderer/config/constant'
|
||||
import { isQwenMTModel } from '@renderer/config/models/qwen'
|
||||
import { CHERRYAI_PROVIDER } from '@renderer/config/providers'
|
||||
import { UNKNOWN } from '@renderer/config/translate'
|
||||
import { getStoreProviders } from '@renderer/hooks/useStore'
|
||||
import i18n from '@renderer/i18n'
|
||||
@ -142,7 +141,7 @@ export function getProviderByModel(model?: Model): Provider {
|
||||
|
||||
if (!provider) {
|
||||
const defaultProvider = providers.find((p) => p.id === getDefaultModel()?.provider)
|
||||
return defaultProvider || CHERRYAI_PROVIDER || providers[0]
|
||||
return defaultProvider || providers[0]
|
||||
}
|
||||
|
||||
return provider
|
||||
|
||||
@ -34,6 +34,7 @@ export interface UpdateState {
|
||||
downloaded: boolean
|
||||
downloadProgress: number
|
||||
available: boolean
|
||||
ignore: boolean
|
||||
}
|
||||
|
||||
export interface RuntimeState {
|
||||
@ -79,7 +80,8 @@ const initialState: RuntimeState = {
|
||||
downloading: false,
|
||||
downloaded: false,
|
||||
downloadProgress: 0,
|
||||
available: false
|
||||
available: false,
|
||||
ignore: false
|
||||
},
|
||||
export: {
|
||||
isExporting: false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user