mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
fix gist
This commit is contained in:
parent
256fffae0b
commit
59203d3855
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
- 为了修复macOS应用内更新问题,此版本需要手动下载dmg进行安装
|
- 为了修复macOS应用内更新问题,此版本需要手动下载dmg进行安装
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- 支持自定义延迟测试并发数量
|
||||||
|
- 完善Sub-Store环境变量
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- 修复macOS应用内更新后权限丢失的问题
|
- 修复macOS应用内更新后权限丢失的问题
|
||||||
|
|||||||
@ -80,7 +80,13 @@ export async function getGistUrl(): Promise<string> {
|
|||||||
if (gist) {
|
if (gist) {
|
||||||
return gist.html_url
|
return gist.html_url
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Gist not found')
|
await uploadRuntimeConfig()
|
||||||
|
const gists = await listGists(githubToken)
|
||||||
|
const gist = gists.find(
|
||||||
|
(gist) => gist.description === 'Auto Synced Mihomo Party Runtime Config'
|
||||||
|
)
|
||||||
|
if (!gist) throw new Error('Gist not found')
|
||||||
|
return gist.html_url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +94,6 @@ export async function uploadRuntimeConfig(): Promise<void> {
|
|||||||
const { githubToken } = await getAppConfig()
|
const { githubToken } = await getAppConfig()
|
||||||
if (!githubToken) return
|
if (!githubToken) return
|
||||||
const gists = await listGists(githubToken)
|
const gists = await listGists(githubToken)
|
||||||
console.log(gists)
|
|
||||||
const gist = gists.find((gist) => gist.description === 'Auto Synced Mihomo Party Runtime Config')
|
const gist = gists.find((gist) => gist.description === 'Auto Synced Mihomo Party Runtime Config')
|
||||||
const config = await getRuntimeConfigStr()
|
const config = await getRuntimeConfigStr()
|
||||||
if (gist) {
|
if (gist) {
|
||||||
|
|||||||
@ -7,50 +7,26 @@ 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> {
|
||||||
const execPromise = promisify(exec)
|
|
||||||
try {
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
const { stdout } = await execPromise('netsh wlan show interfaces')
|
try {
|
||||||
for (const line of stdout.split('\n')) {
|
return await getSSIDByNetsh()
|
||||||
if (line.trim().startsWith('SSID')) {
|
} catch {
|
||||||
return line.split(': ')[1].trim()
|
return undefined
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
const { stdout } = await execPromise(
|
try {
|
||||||
`iwconfig 2>/dev/null | grep 'ESSID' | awk -F'"' '{print $2}'`
|
return await getSSIDByIwconfig()
|
||||||
)
|
} catch {
|
||||||
if (stdout.trim() !== '') {
|
return undefined
|
||||||
return stdout.trim()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
const { stdout } = await execPromise(
|
try {
|
||||||
'/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I'
|
return await getSSIDByAirport()
|
||||||
)
|
|
||||||
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')) {
|
|
||||||
if (line.trim().startsWith('SSID')) {
|
|
||||||
return line.split(': ')[1].trim()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
// ignore
|
return await getSSIDByNetworksetup()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
@ -83,3 +59,57 @@ export async function startSSIDCheck(): Promise<void> {
|
|||||||
await checkSSID()
|
await checkSSID()
|
||||||
setInterval(checkSSID, 30000)
|
setInterval(checkSSID, 30000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getSSIDByAirport(): Promise<string | undefined> {
|
||||||
|
const execPromise = promisify(exec)
|
||||||
|
const { stdout } = await execPromise(
|
||||||
|
'/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I'
|
||||||
|
)
|
||||||
|
if (stdout.trim().startsWith('WARNING')) {
|
||||||
|
throw new Error('airport cannot be used')
|
||||||
|
}
|
||||||
|
for (const line of stdout.split('\n')) {
|
||||||
|
if (line.trim().startsWith('SSID')) {
|
||||||
|
return line.split(': ')[1].trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getSSIDByNetworksetup(): Promise<string | undefined> {
|
||||||
|
const execPromise = promisify(exec)
|
||||||
|
if (net.isOnline()) {
|
||||||
|
const service = await getDefaultService()
|
||||||
|
const { stdout } = await execPromise(`networksetup -listpreferredwirelessnetworks ${service}`)
|
||||||
|
console.log(stdout)
|
||||||
|
if (stdout.trim().startsWith('Preferred networks on')) {
|
||||||
|
console.log(stdout.split('\n'))
|
||||||
|
if (stdout.split('\n').length > 1) {
|
||||||
|
return stdout.split('\n')[1].trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getSSIDByNetsh(): Promise<string | undefined> {
|
||||||
|
const execPromise = promisify(exec)
|
||||||
|
const { stdout } = await execPromise('netsh wlan show interfaces')
|
||||||
|
for (const line of stdout.split('\n')) {
|
||||||
|
if (line.trim().startsWith('SSID')) {
|
||||||
|
return line.split(': ')[1].trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getSSIDByIwconfig(): Promise<string | undefined> {
|
||||||
|
const execPromise = promisify(exec)
|
||||||
|
const { stdout } = await execPromise(
|
||||||
|
`iwconfig 2>/dev/null | grep 'ESSID' | awk -F'"' '{print $2}'`
|
||||||
|
)
|
||||||
|
if (stdout.trim() !== '') {
|
||||||
|
return stdout.trim()
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user