Compare commits

..

No commits in common. "2ebb5db0550f1f585b21efa96f683fc0a4a5883a" and "71f7b7b3c0408b980b5118c09a7042507d77966d" have entirely different histories.

7 changed files with 21 additions and 71 deletions

View File

@ -1,20 +1,3 @@
## 1.8.5
### 新功能 (Feat)
- 支持 cron 表达式以自定义订阅更新频率(#766)
- 修复权限检查并优化TUN与自启联动(#977)
### 修复 (Fix)
- Windows 下当前运行内核权限检测(之前没有正确检测管理员权限运行的内核)
- Windows 下 开机自启 按钮卡顿问题 隐藏运行黑框 现在申请权限会弹通知
- 修复 部分情况下 yaml 文件解析错误 (#889)
- 修复 系统中已经运行的内核名称检测
- 修复 订阅信息中的因格式问题导致的信息缺失(#951)
- 修复 轻量模式延迟启动延时输入数值问题(#962)
- 修复 轻量模式下轻量模式下规则失效的问题(#963)
- 修复 MacOS 下默认虚拟网卡名称没有生效的问题
### 样式调整 (Sytle)
- 部分样式微调
## 1.8.4
### 新功能 (Feat)

View File

@ -1,6 +1,6 @@
{
"name": "mihomo-party",
"version": "1.8.5-dev",
"version": "1.8.4",
"description": "Mihomo Party",
"main": "./out/main/index.js",
"author": "mihomo-party-org",

View File

@ -38,6 +38,10 @@ export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>):
controledMihomoConfig.sniffer = defaultControledMihomoConfig.sniffer
}
if (process.platform === 'darwin') {
delete controledMihomoConfig?.tun?.device
}
await generateProfile()
await writeFile(controledMihomoConfigPath(), yaml.stringify(controledMihomoConfig), 'utf-8')
}

View File

@ -290,7 +290,13 @@ export async function checkTunPermissions(): Promise<boolean> {
try {
if (process.platform === 'win32') {
return await checkAdminPrivileges()
const execPromise = promisify(exec)
try {
await execPromise('net session')
return true
} catch {
return false
}
}
if (process.platform === 'darwin' || process.platform === 'linux') {
@ -335,27 +341,14 @@ export async function checkAdminPrivileges(): Promise<boolean> {
return true
}
try {
const execPromise = promisify(exec)
try {
// 首先尝试 fltmc 命令检测管理员权限
await execPromise('fltmc')
await managerLogger.info('Admin privileges confirmed via fltmc')
return true
} catch (fltmcError) {
await managerLogger.info('fltmc failed, trying net session as fallback', fltmcError)
try {
// 如果 fltmc 失败,尝试 net session 命令作为备用检测方法
await execPromise('net session')
await managerLogger.info('Admin privileges confirmed via net session')
return true
} catch (netSessionError) {
await managerLogger.info('Both fltmc and net session failed, no admin privileges', netSessionError)
} catch {
return false
}
}
}
// TUN 权限确认框
export async function showTunPermissionDialog(): Promise<boolean> {
@ -611,13 +604,6 @@ export async function checkAdminRestartForTun(): Promise<void> {
const hasAdminPrivileges = await checkAdminPrivileges()
if (hasAdminPrivileges) {
await patchControledMihomoConfig({ tun: { enable: true }, dns: { enable: true } })
const { checkAutoRun, enableAutoRun } = await import('../sys/autoRun')
const autoRunEnabled = await checkAutoRun()
if (autoRunEnabled) {
await enableAutoRun()
}
await restartCore()
await managerLogger.info('TUN mode auto-enabled after admin restart')
@ -649,16 +635,8 @@ export async function validateTunPermissionsOnStartup(): Promise<void> {
const hasPermissions = await checkMihomoCorePermissions()
if (!hasPermissions) {
await managerLogger.warn(
'TUN is enabled but insufficient permissions detected, prompting user...'
)
const confirmed = await showTunPermissionDialog()
if (confirmed) {
await restartAsAdmin()
return
}
await managerLogger.warn('TUN is enabled but insufficient permissions detected, auto-disabling TUN...')
await managerLogger.warn('User declined admin restart, auto-disabling TUN...')
await patchControledMihomoConfig({ tun: { enable: false } })
const { mainWindow } = await import('../index')

View File

@ -9,8 +9,7 @@ import { managerLogger } from '../utils/logger'
const appName = 'mihomo-party'
function getTaskXml(asAdmin: boolean): string {
const runLevel = asAdmin ? 'HighestAvailable' : 'LeastPrivilege'
function getTaskXml(): string {
return `<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<Triggers>
@ -22,7 +21,7 @@ function getTaskXml(asAdmin: boolean): string {
<Principals>
<Principal id="Author">
<LogonType>InteractiveToken</LogonType>
<RunLevel>${runLevel}</RunLevel>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
@ -84,9 +83,9 @@ export async function enableAutoRun(): Promise<void> {
if (process.platform === 'win32') {
const execPromise = promisify(exec)
const taskFilePath = path.join(tmpdir(), `${appName}.xml`)
await writeFile(taskFilePath, Buffer.from(`\ufeff${getTaskXml()}`, 'utf-16le'))
const { checkAdminPrivileges } = await import('../core/manager')
const isAdmin = await checkAdminPrivileges()
await writeFile(taskFilePath, Buffer.from(`\ufeff${getTaskXml(isAdmin)}`, 'utf-16le'))
if (isAdmin) {
await execPromise(`%SystemRoot%\\System32\\schtasks.exe /create /tn "${appName}" /xml "${taskFilePath}" /f`)
} else {

View File

@ -250,8 +250,7 @@ async function migration(): Promise<void> {
authentication,
'bind-address': bindAddress,
'lan-allowed-ips': lanAllowedIps,
'lan-disallowed-ips': lanDisallowedIps,
tun
'lan-disallowed-ips': lanDisallowedIps
} = await getControledMihomoConfig()
// add substore sider card
if (useSubStore && !siderOrder.includes('substore')) {
@ -277,16 +276,6 @@ async function migration(): Promise<void> {
if (!lanDisallowedIps) {
await patchControledMihomoConfig({ 'lan-disallowed-ips': [] })
}
// default tun device
if (!tun?.device || (process.platform === 'darwin' && tun.device === 'Mihomo')) {
const defaultDevice = process.platform === 'darwin' ? 'utun1500' : 'Mihomo'
await patchControledMihomoConfig({
tun: {
...tun,
device: defaultDevice
}
})
}
// remove custom app theme
if (!['system', 'light', 'dark'].includes(appTheme)) {
await patchAppConfig({ appTheme: 'system' })

View File

@ -75,9 +75,6 @@ const TunSwitcher: React.FC<Props> = (props) => {
}
await patchControledMihomoConfig({ tun: { enable }, dns: { enable: true } })
if (enable && appConfig?.silentStart) {
await window.electron.ipcRenderer.invoke('enableAutoRun')
}
} else {
await patchControledMihomoConfig({ tun: { enable } })
}