disable auto update in portable exe

This commit is contained in:
beyondkmp 2025-04-21 19:09:52 +08:00 committed by 亢奋猫
parent 234a5e085f
commit ef9c8fd037
3 changed files with 27 additions and 17 deletions

View File

@ -48,7 +48,8 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
appDataPath: app.getPath('userData'), appDataPath: app.getPath('userData'),
resourcesPath: getResourcePath(), resourcesPath: getResourcePath(),
logsPath: log.transports.file.getFile().path, logsPath: log.transports.file.getFile().path,
arch: arch() arch: arch(),
isPortable: isWin && 'PORTABLE_EXECUTABLE_DIR' in process.env
})) }))
ipcMain.handle(IpcChannel.App_Proxy, async (_, proxy: string) => { ipcMain.handle(IpcChannel.App_Proxy, async (_, proxy: string) => {
@ -176,7 +177,7 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
// check for update // check for update
ipcMain.handle(IpcChannel.App_CheckForUpdate, async () => { ipcMain.handle(IpcChannel.App_CheckForUpdate, async () => {
// 在 Windows 上,如果架构是 arm64则不检查更新 // 在 Windows 上,如果架构是 arm64则不检查更新
if (isWin && arch().includes('arm')) { if (isWin && (arch().includes('arm') || 'PORTABLE_EXECUTABLE_DIR' in process.env)) {
return { return {
currentVersion: app.getVersion(), currentVersion: app.getVersion(),
updateInfo: null updateInfo: null

View File

@ -24,6 +24,7 @@ import { SettingContainer, SettingDivider, SettingGroup, SettingRow, SettingTitl
const AboutSettings: FC = () => { const AboutSettings: FC = () => {
const [version, setVersion] = useState('') const [version, setVersion] = useState('')
const [isPortable, setIsPortable] = useState(false)
const { t } = useTranslation() const { t } = useTranslation()
const { autoCheckUpdate, setAutoCheckUpdate } = useSettings() const { autoCheckUpdate, setAutoCheckUpdate } = useSettings()
const { theme } = useTheme() const { theme } = useTheme()
@ -102,6 +103,7 @@ const AboutSettings: FC = () => {
runAsyncFunction(async () => { runAsyncFunction(async () => {
const appInfo = await window.api.getAppInfo() const appInfo = await window.api.getAppInfo()
setVersion(appInfo.version) setVersion(appInfo.version)
setIsPortable(appInfo.isPortable)
}) })
}, []) }, [])
@ -143,22 +145,28 @@ const AboutSettings: FC = () => {
</Tag> </Tag>
</VersionWrapper> </VersionWrapper>
</Row> </Row>
<CheckUpdateButton {!isPortable && (
onClick={onCheckUpdate} <CheckUpdateButton
loading={update.checking} onClick={onCheckUpdate}
disabled={update.downloading || update.checking}> loading={update.checking}
{update.downloading disabled={update.downloading || update.checking}>
? t('settings.about.downloading') {update.downloading
: update.available ? t('settings.about.downloading')
? t('settings.about.checkUpdate.available') : update.available
: t('settings.about.checkUpdate')} ? t('settings.about.checkUpdate.available')
</CheckUpdateButton> : t('settings.about.checkUpdate')}
</CheckUpdateButton>
)}
</AboutHeader> </AboutHeader>
<SettingDivider /> {!isPortable && (
<SettingRow> <>
<SettingRowTitle>{t('settings.general.auto_check_update.title')}</SettingRowTitle> <SettingDivider />
<Switch value={autoCheckUpdate} onChange={(v) => setAutoCheckUpdate(v)} /> <SettingRow>
</SettingRow> <SettingRowTitle>{t('settings.general.auto_check_update.title')}</SettingRowTitle>
<Switch value={autoCheckUpdate} onChange={(v) => setAutoCheckUpdate(v)} />
</SettingRow>
</>
)}
</SettingGroup> </SettingGroup>
{hasNewVersion && update.info && ( {hasNewVersion && update.info && (
<SettingGroup theme={theme}> <SettingGroup theme={theme}>

View File

@ -246,6 +246,7 @@ export type AppInfo = {
filesPath: string filesPath: string
logsPath: string logsPath: string
arch: string arch: string
isPortable: boolean
} }
export interface Shortcut { export interface Shortcut {