mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
✨ feat(desktop): add manual update check entry in About page (#11854)
* ✨ feat(desktop): add manual update check entry in About page Add a 'Check for Updates' button to the About page that appears only on desktop and when no new version is available. This allows users to manually trigger update checks without relying on the automatic check schedule. - Add checkForUpdates i18n key and translations (en-US, zh-CN) - Modify UpdaterCtr to pass manual: true flag - Add check update button to Version component - Button hidden when new version is detected * Update Version.tsx * 💄 style: format onClick handler * fix: correct onClick handler syntax in Version component
This commit is contained in:
@@ -12,7 +12,7 @@ export default class UpdaterCtr extends ControllerModule {
|
||||
@IpcMethod()
|
||||
async checkForUpdates() {
|
||||
logger.info('Check for updates requested');
|
||||
await this.app.updaterManager.checkForUpdates();
|
||||
await this.app.updaterManager.checkForUpdates({ manual: true });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
"branchingRequiresSavedTopic": "Current topic is not saved, please save it first to use subtopic feature",
|
||||
"cancel": "Cancel",
|
||||
"changelog": "Changelog",
|
||||
"checkForUpdates": "Check for Updates",
|
||||
"clientDB.autoInit.title": "Initializing PGlite Database",
|
||||
"clientDB.error.desc": "PGlite failed to initialize. Retry first. If it helps, open Self-serve fixes and follow the steps. Still stuck after a few tries? Use Report issue to send us the error details.",
|
||||
"clientDB.error.detail": "Error reason: [{{type}}] {{message}}. Details are as follows:",
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
"branchingRequiresSavedTopic": "当前话题未保存。保存后即可使用子话题",
|
||||
"cancel": "取消",
|
||||
"changelog": "更新日志",
|
||||
"checkForUpdates": "检查更新",
|
||||
"clientDB.autoInit.title": "初始化 PGlite 数据库",
|
||||
"clientDB.error.desc": "PGlite 数据库初始化遇到了问题。你可以先点右侧「重试」;如果方便,也可以打开「自助解决」按提示处理。多次重试仍不行:欢迎通过「反馈问题」把错误信息发给我们,我们会尽快排查。",
|
||||
"clientDB.error.detail": "原因:[{{type}}] {{message}},明细如下:",
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { BRANDING_NAME } from '@lobechat/business-const';
|
||||
import { getElectronIpc } from '@lobechat/electron-client-ipc';
|
||||
import { Block, Button, Flexbox, Tag } from '@lobehub/ui';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { memo } from 'react';
|
||||
import { memo, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { ProductLogo } from '@/components/Branding';
|
||||
import { CHANGELOG_URL, MANUAL_UPGRADE_URL, OFFICIAL_SITE } from '@/const/url';
|
||||
import { CURRENT_VERSION } from '@/const/version';
|
||||
import { useNewVersion } from '@/features/User/UserPanel/useNewVersion';
|
||||
import { autoUpdateService } from '@/services/electron/autoUpdate';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
@@ -28,6 +30,7 @@ const Version = memo<{ mobile?: boolean }>(({ mobile }) => {
|
||||
useCheckServerVersion();
|
||||
|
||||
const showServerVersion = serverVersion && serverVersion !== CURRENT_VERSION;
|
||||
const isDesktop = useMemo(() => !!getElectronIpc(), []);
|
||||
|
||||
return (
|
||||
<Flexbox
|
||||
@@ -69,7 +72,12 @@ const Version = memo<{ mobile?: boolean }>(({ mobile }) => {
|
||||
<a href={CHANGELOG_URL} rel="noreferrer" style={{ flex: 1 }} target="_blank">
|
||||
<Button block={mobile}>{t('changelog')}</Button>
|
||||
</a>
|
||||
{hasNewVersion && (
|
||||
{isDesktop && !hasNewVersion && (
|
||||
<Button block={mobile} onClick={() => void autoUpdateService.checkUpdate()}>
|
||||
{t('checkForUpdates')}
|
||||
</Button>
|
||||
)}
|
||||
{hasNewVersion && !isDesktop && (
|
||||
<a href={MANUAL_UPGRADE_URL} rel="noreferrer" style={{ flex: 1 }} target="_blank">
|
||||
<Button block={mobile} type={'primary'}>
|
||||
{t('upgradeVersion.action')}
|
||||
|
||||
@@ -34,6 +34,7 @@ export default {
|
||||
'Current topic is not saved, please save it first to use subtopic feature',
|
||||
'cancel': 'Cancel',
|
||||
'changelog': 'Changelog',
|
||||
'checkForUpdates': 'Check for Updates',
|
||||
'clientDB.autoInit.title': 'Initializing PGlite Database',
|
||||
'clientDB.error.desc':
|
||||
'PGlite failed to initialize. Retry first. If it helps, open Self-serve fixes and follow the steps. Still stuck after a few tries? Use Report issue to send us the error details.',
|
||||
|
||||
Reference in New Issue
Block a user