feat: 更新自动检查更新功能易读性

将手动检查更新的设置更改为自动检查更新,更新相关的状态管理和界面文本,以提升用户体验。
This commit is contained in:
wangxiaolong 2025-03-25 12:49:29 +08:00 committed by 亢奋猫
parent 8d48824981
commit e2d8b89ffd
5 changed files with 18 additions and 18 deletions

View File

@ -18,7 +18,7 @@ import useUpdateHandler from './useUpdateHandler'
export function useAppInit() {
const dispatch = useAppDispatch()
const { proxyUrl, language, windowStyle, manualUpdateCheck, proxyMode, customCss } = useSettings()
const { proxyUrl, language, windowStyle, autoCheckUpdate, proxyMode, customCss } = useSettings()
const { minappShow } = useRuntime()
const { setDefaultModel, setTopicNamingModel, setTranslateModel } = useDefaultModel()
const avatar = useLiveQuery(() => db.settings.get('image://avatar'))
@ -36,13 +36,13 @@ export function useAppInit() {
document.getElementById('spinner')?.remove()
runAsyncFunction(async () => {
const { isPackaged } = await window.api.getAppInfo()
if (isPackaged && !manualUpdateCheck) {
if (isPackaged && autoCheckUpdate) {
await delay(2)
const { updateInfo } = await window.api.checkForUpdate()
dispatch(setUpdateState({ info: updateInfo }))
}
})
}, [dispatch, manualUpdateCheck])
}, [dispatch, autoCheckUpdate])
useEffect(() => {
if (proxyMode === 'system') {

View File

@ -921,7 +921,7 @@
"general.display.title": "Display Settings",
"general.emoji_picker": "Emoji Picker",
"general.image_upload": "Image Upload",
"general.manually_check_update.title": "Turn off update checking",
"general.auto_check_update.title": "Auto update checking",
"general.reset.button": "Reset",
"general.reset.title": "Data Reset",
"general.restore.button": "Restore",
@ -1234,4 +1234,4 @@
"visualization": "Visualization"
}
}
}
}

View File

@ -921,7 +921,7 @@
"general.display.title": "显示设置",
"general.emoji_picker": "表情选择器",
"general.image_upload": "图片上传",
"general.manually_check_update.title": "关闭更新检测",
"general.auto_check_update.title": "自动检测更新",
"general.reset.button": "重置",
"general.reset.title": "重置数据",
"general.restore.button": "恢复",
@ -1234,4 +1234,4 @@
"visualization": "可视化"
}
}
}
}

View File

@ -9,7 +9,7 @@ import { useRuntime } from '@renderer/hooks/useRuntime'
import { useSettings } from '@renderer/hooks/useSettings'
import { useAppDispatch } from '@renderer/store'
import { setUpdateState } from '@renderer/store/runtime'
import { setManualUpdateCheck } from '@renderer/store/settings'
import { setAutoCheckUpdate } from '@renderer/store/settings'
import { ThemeMode } from '@renderer/types'
import { compareVersions, runAsyncFunction } from '@renderer/utils'
import { Avatar, Button, Progress, Row, Switch, Tag } from 'antd'
@ -25,7 +25,7 @@ import { SettingContainer, SettingDivider, SettingGroup, SettingRow, SettingTitl
const AboutSettings: FC = () => {
const [version, setVersion] = useState('')
const { t } = useTranslation()
const { manualUpdateCheck } = useSettings()
const { autoCheckUpdate } = useSettings()
const { theme } = useTheme()
const dispatch = useAppDispatch()
const { update } = useRuntime()
@ -146,8 +146,8 @@ const AboutSettings: FC = () => {
</AboutHeader>
<SettingDivider />
<SettingRow>
<SettingRowTitle>{t('settings.general.manually_check_update.title')}</SettingRowTitle>
<Switch value={manualUpdateCheck} onChange={(v) => dispatch(setManualUpdateCheck(v))} />
<SettingRowTitle>{t('settings.general.auto_check_update.title')}</SettingRowTitle>
<Switch value={autoCheckUpdate} onChange={(v) => dispatch(setAutoCheckUpdate(v))} />
</SettingRow>
</SettingGroup>
{hasNewVersion && update.info && (
@ -161,7 +161,7 @@ const AboutSettings: FC = () => {
<UpdateNotesWrapper>
<Markdown>
{typeof update.info.releaseNotes === 'string'
? update.info.releaseNotes.replaceAll('\n', '\n\n')
? update.info.releaseNotes.replace(/\n/g, '\n\n')
: update.info.releaseNotes?.map((note) => note.note).join('\n')}
</Markdown>
</UpdateNotesWrapper>

View File

@ -45,7 +45,7 @@ export interface SettingsState {
pasteLongTextAsFile: boolean
pasteLongTextThreshold: number
clickAssistantToShowTopic: boolean
manualUpdateCheck: boolean
autoCheckUpdate: boolean
renderInputMessageAsMarkdown: boolean
codeShowLineNumbers: boolean
codeCollapsible: boolean
@ -130,7 +130,7 @@ const initialState: SettingsState = {
pasteLongTextAsFile: false,
pasteLongTextThreshold: 1500,
clickAssistantToShowTopic: false,
manualUpdateCheck: false,
autoCheckUpdate: true,
renderInputMessageAsMarkdown: false,
codeShowLineNumbers: false,
codeCollapsible: false,
@ -261,15 +261,15 @@ const settingsSlice = createSlice({
setPasteLongTextAsFile: (state, action: PayloadAction<boolean>) => {
state.pasteLongTextAsFile = action.payload
},
setAutoCheckUpdate: (state, action: PayloadAction<boolean>) => {
state.autoCheckUpdate = action.payload
},
setRenderInputMessageAsMarkdown: (state, action: PayloadAction<boolean>) => {
state.renderInputMessageAsMarkdown = action.payload
},
setClickAssistantToShowTopic: (state, action: PayloadAction<boolean>) => {
state.clickAssistantToShowTopic = action.payload
},
setManualUpdateCheck: (state, action: PayloadAction<boolean>) => {
state.manualUpdateCheck = action.payload
},
setWebdavHost: (state, action: PayloadAction<string>) => {
state.webdavHost = action.payload
},
@ -444,9 +444,9 @@ export const {
setShowTopicTime,
setShowAssistantIcon,
setPasteLongTextAsFile,
setAutoCheckUpdate,
setRenderInputMessageAsMarkdown,
setClickAssistantToShowTopic,
setManualUpdateCheck,
setWebdavHost,
setWebdavUser,
setWebdavPass,