add uwp tool for windows

This commit is contained in:
pompurin404 2024-08-09 20:53:13 +08:00
parent 899f0c2b59
commit aaf0d7e5be
No known key found for this signature in database
2 changed files with 22 additions and 2 deletions

View File

@ -37,10 +37,11 @@ import {
import { isEncryptionAvailable, startCore } from '../core/manager'
import { triggerSysProxy } from '../resolve/sysproxy'
import { checkUpdate } from '../resolve/autoUpdater'
import { exePath, mihomoCorePath, mihomoWorkConfigPath } from './dirs'
import { execSync } from 'child_process'
import { exePath, mihomoCorePath, mihomoWorkConfigPath, resourcesDir } from './dirs'
import { execFile, execSync } from 'child_process'
import yaml from 'yaml'
import fs from 'fs'
import path from 'path'
export function registerIpcMainHandlers(): void {
ipcMain.handle('mihomoVersion', mihomoVersion)
@ -87,6 +88,7 @@ export function registerIpcMainHandlers(): void {
ipcMain.handle('checkUpdate', () => checkUpdate())
ipcMain.handle('getVersion', () => app.getVersion())
ipcMain.handle('platform', () => process.platform)
ipcMain.handle('openUWPTool', openUWPTool)
ipcMain.handle('setupFirewall', setupFirewall)
ipcMain.handle('quitApp', () => app.quit())
}
@ -111,6 +113,12 @@ function getRuntimeConfig(): Record<string, unknown> {
return yaml.parse(getRuntimeConfigStr())
}
function openUWPTool(): void {
const uwpToolPath = path.join(resourcesDir(), 'files', 'enableLoopback.exe')
const child = execFile(uwpToolPath)
child.unref()
}
async function setupFirewall(): Promise<void> {
return new Promise((resolve, reject) => {
const removeCommand = `

View File

@ -138,6 +138,18 @@ const Sysproxy: React.FC = () => {
<Tab className="select-none" key="auto" title="PAC" />
</Tabs>
</SettingItem>
{platform === 'win32' && (
<SettingItem title="UWP 工具" divider>
<Button
size="sm"
onPress={() => {
window.electron.ipcRenderer.invoke('openUWPTool')
}}
>
UWP
</Button>
</SettingItem>
)}
{values.mode === 'auto' && (
<SettingItem title="代理模式">