Skip to content

Commit aaf0d7e

Browse files
author
pompurin404
committed
add uwp tool for windows
1 parent 899f0c2 commit aaf0d7e

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/main/utils/ipc.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ import {
3737
import { isEncryptionAvailable, startCore } from '../core/manager'
3838
import { triggerSysProxy } from '../resolve/sysproxy'
3939
import { checkUpdate } from '../resolve/autoUpdater'
40-
import { exePath, mihomoCorePath, mihomoWorkConfigPath } from './dirs'
41-
import { execSync } from 'child_process'
40+
import { exePath, mihomoCorePath, mihomoWorkConfigPath, resourcesDir } from './dirs'
41+
import { execFile, execSync } from 'child_process'
4242
import yaml from 'yaml'
4343
import fs from 'fs'
44+
import path from 'path'
4445

4546
export function registerIpcMainHandlers(): void {
4647
ipcMain.handle('mihomoVersion', mihomoVersion)
@@ -87,6 +88,7 @@ export function registerIpcMainHandlers(): void {
8788
ipcMain.handle('checkUpdate', () => checkUpdate())
8889
ipcMain.handle('getVersion', () => app.getVersion())
8990
ipcMain.handle('platform', () => process.platform)
91+
ipcMain.handle('openUWPTool', openUWPTool)
9092
ipcMain.handle('setupFirewall', setupFirewall)
9193
ipcMain.handle('quitApp', () => app.quit())
9294
}
@@ -111,6 +113,12 @@ function getRuntimeConfig(): Record<string, unknown> {
111113
return yaml.parse(getRuntimeConfigStr())
112114
}
113115

116+
function openUWPTool(): void {
117+
const uwpToolPath = path.join(resourcesDir(), 'files', 'enableLoopback.exe')
118+
const child = execFile(uwpToolPath)
119+
child.unref()
120+
}
121+
114122
async function setupFirewall(): Promise<void> {
115123
return new Promise((resolve, reject) => {
116124
const removeCommand = `

src/renderer/src/pages/syspeoxy.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ const Sysproxy: React.FC = () => {
138138
<Tab className="select-none" key="auto" title="PAC" />
139139
</Tabs>
140140
</SettingItem>
141+
{platform === 'win32' && (
142+
<SettingItem title="UWP 工具" divider>
143+
<Button
144+
size="sm"
145+
onPress={() => {
146+
window.electron.ipcRenderer.invoke('openUWPTool')
147+
}}
148+
>
149+
打开 UWP 工具
150+
</Button>
151+
</SettingItem>
152+
)}
141153

142154
{values.mode === 'auto' && (
143155
<SettingItem title="代理模式">

0 commit comments

Comments
 (0)