mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
fix ssid on new system
This commit is contained in:
parent
5217aa8c73
commit
85c7dded6b
@ -1,3 +1,8 @@
|
|||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- 为了修复macOS应用内更新问题,此版本需要手动下载dmg进行安装
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- 修复macOS应用内更新后权限丢失的问题
|
- 修复macOS应用内更新后权限丢失的问题
|
||||||
|
- 修复高版本macOS SSID获取失败的问题
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
import { app } from 'electron'
|
import { app, shell } from 'electron'
|
||||||
import { getControledMihomoConfig } from '../config'
|
import { getControledMihomoConfig } from '../config'
|
||||||
import { dataDir, exeDir, exePath, 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'
|
||||||
@ -85,23 +85,27 @@ export async function downloadAndInstallUpdate(version: string): Promise<void> {
|
|||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
if (file.endsWith('.dmg')) {
|
if (file.endsWith('.dmg')) {
|
||||||
const execPromise = promisify(exec)
|
|
||||||
const name = exePath().split('.app')[0].replace('/Applications/', '')
|
|
||||||
await execPromise(
|
|
||||||
`hdiutil attach "${path.join(dataDir(), file)}" -mountpoint "/Volumes/mihomo-party" -nobrowse`
|
|
||||||
)
|
|
||||||
try {
|
try {
|
||||||
await execPromise(`mv /Applications/${name}.app /tmp`)
|
const execPromise = promisify(exec)
|
||||||
await execPromise('cp -R "/Volumes/mihomo-party/mihomo-party.app" /Applications/')
|
const name = exePath().split('.app')[0].replace('/Applications/', '')
|
||||||
await execPromise(`rm -rf /tmp/${name}.app`)
|
await execPromise(
|
||||||
} catch (e) {
|
`hdiutil attach "${path.join(dataDir(), file)}" -mountpoint "/Volumes/mihomo-party" -nobrowse`
|
||||||
await execPromise(`mv /tmp/${name}.app /Applications`)
|
)
|
||||||
throw e
|
try {
|
||||||
} finally {
|
await execPromise(`mv /Applications/${name}.app /tmp`)
|
||||||
await execPromise('hdiutil detach "/Volumes/mihomo-party"')
|
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.quit()
|
||||||
|
} catch {
|
||||||
|
shell.openPath(path.join(dataDir(), file))
|
||||||
}
|
}
|
||||||
app.relaunch()
|
|
||||||
app.quit()
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rm(path.join(dataDir(), file))
|
rm(path.join(dataDir(), file))
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { promisify } from 'util'
|
|||||||
import { getAppConfig, patchControledMihomoConfig } from '../config'
|
import { getAppConfig, patchControledMihomoConfig } from '../config'
|
||||||
import { patchMihomoConfig } from '../core/mihomoApi'
|
import { patchMihomoConfig } from '../core/mihomoApi'
|
||||||
import { mainWindow } from '..'
|
import { mainWindow } from '..'
|
||||||
import { ipcMain } from 'electron'
|
import { ipcMain, net } from 'electron'
|
||||||
import { getDefaultService } from '../core/manager'
|
import { getDefaultService } from '../core/manager'
|
||||||
|
|
||||||
export async function getCurrentSSID(): Promise<string | undefined> {
|
export async function getCurrentSSID(): Promise<string | undefined> {
|
||||||
@ -26,21 +26,27 @@ export async function getCurrentSSID(): Promise<string | undefined> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
try {
|
const { stdout } = await execPromise(
|
||||||
const { stdout } = await execPromise(
|
'/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I'
|
||||||
'/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I'
|
)
|
||||||
)
|
if (stdout.trim().startsWith('WARNING')) {
|
||||||
|
if (net.isOnline()) {
|
||||||
|
const service = await getDefaultService()
|
||||||
|
const { stdout } = await execPromise(
|
||||||
|
`networksetup -listpreferredwirelessnetworks ${service}`
|
||||||
|
)
|
||||||
|
if (stdout.trim().startsWith('Preferred networks on')) {
|
||||||
|
if (stdout.split('\n').length > 1) {
|
||||||
|
return stdout.split('\n')[1].trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (const line of stdout.split('\n')) {
|
for (const line of stdout.split('\n')) {
|
||||||
if (line.trim().startsWith('SSID')) {
|
if (line.trim().startsWith('SSID')) {
|
||||||
return line.split(': ')[1].trim()
|
return line.split(': ')[1].trim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
const service = await getDefaultService()
|
|
||||||
const { stdout } = await execPromise(`networksetup -getairportnetwork ${service}`)
|
|
||||||
if (stdout.split(': ').length > 1) {
|
|
||||||
return stdout.split(': ')[1].trim()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user