mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +08:00
support oneclick update for windows
This commit is contained in:
parent
76bc24a6cd
commit
e79e3dcd1b
|
@ -5,6 +5,7 @@
|
|||
### Features
|
||||
|
||||
- 支持托盘菜单切换订阅
|
||||
- Windows 支持一键更新
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ nsis:
|
|||
artifactName: ${name}-windows-${version}-${arch}-setup.${ext}
|
||||
shortcutName: Mihomo Party
|
||||
uninstallDisplayName: ${productName}
|
||||
deleteAppDataOnUninstall: true
|
||||
allowToChangeInstallationDirectory: true
|
||||
oneClick: false
|
||||
perMachine: true
|
||||
|
|
|
@ -271,6 +271,11 @@ const resolveRunner = () =>
|
|||
file: 'mihomo-party-run.exe',
|
||||
downloadURL: `https://github.com/mihomo-party-org/mihomo-party-run/releases/download/${arch}/mihomo-party-run.exe`
|
||||
})
|
||||
const resolve7zip = () =>
|
||||
resolveResource({
|
||||
file: '7za.exe',
|
||||
downloadURL: `https://github.com/develar/7zip-bin/raw/master/win/${arch}/7za.exe`
|
||||
})
|
||||
const resolveSubstore = () =>
|
||||
resolveResource({
|
||||
file: 'sub-store.bundle.js',
|
||||
|
@ -359,6 +364,12 @@ const tasks = [
|
|||
name: 'substorefrontend',
|
||||
func: resolveSubstoreFrontend,
|
||||
retry: 5
|
||||
},
|
||||
{
|
||||
name: '7zip',
|
||||
func: resolve7zip,
|
||||
retry: 5,
|
||||
winOnly: true
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ import axios from 'axios'
|
|||
import yaml from 'yaml'
|
||||
import { app, shell } from 'electron'
|
||||
import { getControledMihomoConfig } from '../config'
|
||||
import { dataDir, isPortable } from '../utils/dirs'
|
||||
import { dataDir, exeDir, isPortable, resourcesFilesDir } from '../utils/dirs'
|
||||
import { rm, writeFile } from 'fs/promises'
|
||||
import path from 'path'
|
||||
import { existsSync } from 'fs'
|
||||
import os from 'os'
|
||||
import { spawn } from 'child_process'
|
||||
|
||||
export async function checkUpdate(): Promise<IAppVersion | undefined> {
|
||||
const { 'mixed-port': mixedPort = 7890 } = await getControledMihomoConfig()
|
||||
|
@ -65,8 +66,25 @@ export async function downloadAndInstallUpdate(version: string): Promise<void> {
|
|||
})
|
||||
await writeFile(path.join(dataDir(), file), res.data)
|
||||
}
|
||||
if (file.endsWith('.exe')) {
|
||||
spawn(path.join(dataDir(), file), ['/S', '--force-run'], {
|
||||
detached: true,
|
||||
stdio: 'ignore'
|
||||
}).unref()
|
||||
} else if (file.endsWith('.7z')) {
|
||||
spawn(
|
||||
path.join(resourcesFilesDir(), '7za.exe'),
|
||||
['x', `-o"${exeDir()}"`, '-y', path.join(dataDir(), file)],
|
||||
{
|
||||
shell: true,
|
||||
detached: true
|
||||
}
|
||||
).unref()
|
||||
app.quit()
|
||||
} else {
|
||||
await shell.openPath(path.join(dataDir(), file))
|
||||
app.quit()
|
||||
}
|
||||
} catch (e) {
|
||||
rm(path.join(dataDir(), file))
|
||||
throw e
|
||||
|
|
Loading…
Reference in New Issue
Block a user