mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
add uwp tool for windows
This commit is contained in:
parent
899f0c2b59
commit
aaf0d7e5be
@ -37,10 +37,11 @@ import {
|
|||||||
import { isEncryptionAvailable, startCore } from '../core/manager'
|
import { isEncryptionAvailable, startCore } from '../core/manager'
|
||||||
import { triggerSysProxy } from '../resolve/sysproxy'
|
import { triggerSysProxy } from '../resolve/sysproxy'
|
||||||
import { checkUpdate } from '../resolve/autoUpdater'
|
import { checkUpdate } from '../resolve/autoUpdater'
|
||||||
import { exePath, mihomoCorePath, mihomoWorkConfigPath } from './dirs'
|
import { exePath, mihomoCorePath, mihomoWorkConfigPath, resourcesDir } from './dirs'
|
||||||
import { execSync } from 'child_process'
|
import { execFile, execSync } from 'child_process'
|
||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
export function registerIpcMainHandlers(): void {
|
export function registerIpcMainHandlers(): void {
|
||||||
ipcMain.handle('mihomoVersion', mihomoVersion)
|
ipcMain.handle('mihomoVersion', mihomoVersion)
|
||||||
@ -87,6 +88,7 @@ export function registerIpcMainHandlers(): void {
|
|||||||
ipcMain.handle('checkUpdate', () => checkUpdate())
|
ipcMain.handle('checkUpdate', () => checkUpdate())
|
||||||
ipcMain.handle('getVersion', () => app.getVersion())
|
ipcMain.handle('getVersion', () => app.getVersion())
|
||||||
ipcMain.handle('platform', () => process.platform)
|
ipcMain.handle('platform', () => process.platform)
|
||||||
|
ipcMain.handle('openUWPTool', openUWPTool)
|
||||||
ipcMain.handle('setupFirewall', setupFirewall)
|
ipcMain.handle('setupFirewall', setupFirewall)
|
||||||
ipcMain.handle('quitApp', () => app.quit())
|
ipcMain.handle('quitApp', () => app.quit())
|
||||||
}
|
}
|
||||||
@ -111,6 +113,12 @@ function getRuntimeConfig(): Record<string, unknown> {
|
|||||||
return yaml.parse(getRuntimeConfigStr())
|
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> {
|
async function setupFirewall(): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const removeCommand = `
|
const removeCommand = `
|
||||||
|
|||||||
@ -138,6 +138,18 @@ const Sysproxy: React.FC = () => {
|
|||||||
<Tab className="select-none" key="auto" title="PAC" />
|
<Tab className="select-none" key="auto" title="PAC" />
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
{platform === 'win32' && (
|
||||||
|
<SettingItem title="UWP 工具" divider>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
onPress={() => {
|
||||||
|
window.electron.ipcRenderer.invoke('openUWPTool')
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
打开 UWP 工具
|
||||||
|
</Button>
|
||||||
|
</SettingItem>
|
||||||
|
)}
|
||||||
|
|
||||||
{values.mode === 'auto' && (
|
{values.mode === 'auto' && (
|
||||||
<SettingItem title="代理模式">
|
<SettingItem title="代理模式">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user