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'),
resourcesPath: getResourcePath(),
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) => {
@ -176,7 +177,7 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
// check for update
ipcMain.handle(IpcChannel.App_CheckForUpdate, async () => {
// 在 Windows 上,如果架构是 arm64则不检查更新
if (isWin && arch().includes('arm')) {
if (isWin && (arch().includes('arm') || 'PORTABLE_EXECUTABLE_DIR' in process.env)) {
return {
currentVersion: app.getVersion(),
updateInfo: null

View File

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

View File

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