mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
fix macOS updater
This commit is contained in:
parent
eecd591504
commit
5217aa8c73
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -198,7 +198,7 @@ jobs:
|
|||||||
npm_config_target_arch: ${{ matrix.arch }}
|
npm_config_target_arch: ${{ matrix.arch }}
|
||||||
run: pnpm build:mac --${{ matrix.arch }}
|
run: pnpm build:mac --${{ matrix.arch }}
|
||||||
- name: Generate checksums
|
- name: Generate checksums
|
||||||
run: pnpm checksum .dmg .zip
|
run: pnpm checksum .dmg
|
||||||
- name: Upload Artifacts
|
- name: Upload Artifacts
|
||||||
if: startsWith(github.ref, 'refs/heads/')
|
if: startsWith(github.ref, 'refs/heads/')
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@ -207,7 +207,6 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
dist/*.sha256
|
dist/*.sha256
|
||||||
dist/*.dmg
|
dist/*.dmg
|
||||||
dist/*.zip
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
- name: Publish Release
|
- name: Publish Release
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
@ -216,7 +215,6 @@ jobs:
|
|||||||
files: |
|
files: |
|
||||||
dist/*.sha256
|
dist/*.sha256
|
||||||
dist/*.dmg
|
dist/*.dmg
|
||||||
dist/*.zip
|
|
||||||
body_path: changelog.md
|
body_path: changelog.md
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,3 @@
|
|||||||
### Features
|
|
||||||
|
|
||||||
- 支持在特定WiFi SSID下直连
|
|
||||||
- 支持同步运行时配置到GitHub Gist
|
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- 修复某些mac无法开启开机启动的问题
|
- 修复macOS应用内更新后权限丢失的问题
|
||||||
|
|||||||
@ -40,7 +40,6 @@ nsis:
|
|||||||
mac:
|
mac:
|
||||||
target:
|
target:
|
||||||
- dmg
|
- dmg
|
||||||
- zip
|
|
||||||
entitlementsInherit: build/entitlements.mac.plist
|
entitlementsInherit: build/entitlements.mac.plist
|
||||||
extendInfo:
|
extendInfo:
|
||||||
- NSCameraUsageDescription: Application requests access to the device's camera.
|
- NSCameraUsageDescription: Application requests access to the device's camera.
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import axios from 'axios'
|
|||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
import { app } from 'electron'
|
import { app } from 'electron'
|
||||||
import { getControledMihomoConfig } from '../config'
|
import { getControledMihomoConfig } from '../config'
|
||||||
import { dataDir, exeDir, isPortable, resourcesFilesDir } from '../utils/dirs'
|
import { dataDir, exeDir, exePath, isPortable, resourcesFilesDir } from '../utils/dirs'
|
||||||
import { rm, writeFile } from 'fs/promises'
|
import { rm, writeFile } from 'fs/promises'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { existsSync } from 'fs'
|
import { existsSync } from 'fs'
|
||||||
@ -39,8 +39,8 @@ export async function downloadAndInstallUpdate(version: string): Promise<void> {
|
|||||||
'win32-x64': `mihomo-party-windows-${version}-x64-setup.exe`,
|
'win32-x64': `mihomo-party-windows-${version}-x64-setup.exe`,
|
||||||
'win32-ia32': `mihomo-party-windows-${version}-ia32-setup.exe`,
|
'win32-ia32': `mihomo-party-windows-${version}-ia32-setup.exe`,
|
||||||
'win32-arm64': `mihomo-party-windows-${version}-arm64-setup.exe`,
|
'win32-arm64': `mihomo-party-windows-${version}-arm64-setup.exe`,
|
||||||
'darwin-x64': `mihomo-party-macos-${version}-x64.zip`,
|
'darwin-x64': `mihomo-party-macos-${version}-x64.dmg`,
|
||||||
'darwin-arm64': `mihomo-party-macos-${version}-arm64.zip`
|
'darwin-arm64': `mihomo-party-macos-${version}-arm64.dmg`
|
||||||
}
|
}
|
||||||
let file = fileMap[`${process.platform}-${process.arch}`]
|
let file = fileMap[`${process.platform}-${process.arch}`]
|
||||||
if (isPortable()) {
|
if (isPortable()) {
|
||||||
@ -84,9 +84,22 @@ export async function downloadAndInstallUpdate(version: string): Promise<void> {
|
|||||||
).unref()
|
).unref()
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
if (file.endsWith('.zip')) {
|
if (file.endsWith('.dmg')) {
|
||||||
const execPromise = promisify(exec)
|
const execPromise = promisify(exec)
|
||||||
await execPromise(`unzip -o -K '${path.join(dataDir(), file)}' -d /Applications`)
|
const name = exePath().split('.app')[0].replace('/Applications/', '')
|
||||||
|
await execPromise(
|
||||||
|
`hdiutil attach "${path.join(dataDir(), file)}" -mountpoint "/Volumes/mihomo-party" -nobrowse`
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
await execPromise(`mv /Applications/${name}.app /tmp`)
|
||||||
|
await execPromise('cp -R "/Volumes/mihomo-party/mihomo-party.app" /Applications/')
|
||||||
|
await execPromise(`rm -rf /tmp/${name}.app`)
|
||||||
|
} catch (e) {
|
||||||
|
await execPromise(`mv /tmp/${name}.app /Applications`)
|
||||||
|
throw e
|
||||||
|
} finally {
|
||||||
|
await execPromise('hdiutil detach "/Volumes/mihomo-party"')
|
||||||
|
}
|
||||||
app.relaunch()
|
app.relaunch()
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,7 +105,7 @@ async function cleanup(): Promise<void> {
|
|||||||
// update cache
|
// update cache
|
||||||
const files = await readdir(dataDir())
|
const files = await readdir(dataDir())
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
if (file.endsWith('.exe') || file.endsWith('.dmg') || file.endsWith('.zip')) {
|
if (file.endsWith('.exe') || file.endsWith('.dmg')) {
|
||||||
try {
|
try {
|
||||||
await rm(path.join(dataDir(), file))
|
await rm(path.join(dataDir(), file))
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user