This commit is contained in:
pompurin404 2024-08-29 11:12:05 +08:00
parent 2429a5f189
commit a049b2ab7f
No known key found for this signature in database
6 changed files with 20 additions and 18 deletions

View File

@ -1,9 +1,4 @@
### New Features
- 调整MacOS托盘尺寸
### Bug Fixes
- 修复MacOS系统代理修改失败的问题
- 修复Windows URL Scheme失效的问题
- 修复DNS策略无法删除的问题
- 修复便携模式无法启动的问题
- 尝试修复Windows系统代理无法打开的问题

View File

@ -1,6 +1,6 @@
{
"name": "mihomo-party",
"version": "1.1.0",
"version": "1.1.1",
"description": "Mihomo Party",
"main": "./out/main/index.js",
"author": "mihomo-party",

View File

@ -15,7 +15,7 @@ import { execSync } from 'child_process'
import { createElevateTask } from './sys/misc'
import { initProfileUpdater } from './core/profileUpdater'
import { writeFileSync } from 'fs'
import { exeDir } from './utils/dirs'
import { taskDir } from './utils/dirs'
import path from 'path'
export let mainWindow: BrowserWindow | null = null
@ -25,9 +25,9 @@ if (process.platform === 'win32' && !is.dev) {
} catch (e) {
try {
if (process.argv.slice(1).length > 0) {
writeFileSync(path.join(exeDir(), 'param.txt'), process.argv.slice(1).join(' '))
writeFileSync(path.join(taskDir(), 'param.txt'), process.argv.slice(1).join(' '))
} else {
writeFileSync(path.join(exeDir(), 'param.txt'), 'empty')
writeFileSync(path.join(taskDir(), 'param.txt'), 'empty')
}
execSync('schtasks /run /tn mihomo-party-run')
} catch (e) {

View File

@ -1,4 +1,4 @@
import { dataDir, exePath, homeDir } from '../utils/dirs'
import { taskDir, exePath, homeDir } from '../utils/dirs'
import { mkdir, readFile, rm, writeFile } from 'fs/promises'
import { exec } from 'child_process'
import { existsSync } from 'fs'
@ -76,7 +76,7 @@ export async function checkAutoRun(): Promise<boolean> {
export async function enableAutoRun(): Promise<void> {
if (process.platform === 'win32') {
const execPromise = promisify(exec)
const taskFilePath = path.join(dataDir(), `${appName}.xml`)
const taskFilePath = path.join(taskDir(), `${appName}.xml`)
await writeFile(taskFilePath, Buffer.from(`\ufeff${taskXml}`, 'utf-16le'))
await execPromise(`schtasks /create /tn "${appName}" /xml "${taskFilePath}" /f`)
}

View File

@ -3,7 +3,7 @@ import { dialog, nativeTheme } from 'electron'
import { readFile } from 'fs/promises'
import path from 'path'
import { promisify } from 'util'
import { exeDir, exePath, mihomoCorePath, resourcesDir } from '../utils/dirs'
import { exePath, mihomoCorePath, resourcesDir, taskDir } from '../utils/dirs'
import { writeFileSync } from 'fs'
export function getFilePath(ext: string[]): string[] | undefined {
@ -82,7 +82,7 @@ const elevateTaskXml = `<?xml version="1.0" encoding="UTF-16"?>
<Actions Context="Author">
<Exec>
<Command>wscript.exe</Command>
<Arguments>"${path.join(exeDir(), `mihomo-party-run.vbs`)}"</Arguments>
<Arguments>"${path.join(taskDir(), `mihomo-party-run.vbs`)}"</Arguments>
</Exec>
</Actions>
</Task>
@ -100,8 +100,8 @@ shell.Run commandLine, 0, false
`
export function createElevateTask(): void {
const taskFilePath = path.join(exeDir(), `mihomo-party-run.xml`)
writeFileSync(path.join(exeDir(), `mihomo-party-run.vbs`), startScript)
const taskFilePath = path.join(taskDir(), `mihomo-party-run.xml`)
writeFileSync(path.join(taskDir(), `mihomo-party-run.vbs`), startScript)
writeFileSync(taskFilePath, Buffer.from(`\ufeff${elevateTaskXml}`, 'utf-16le'))
execSync(`schtasks /create /tn "mihomo-party-run" /xml "${taskFilePath}" /f`)
}

View File

@ -1,6 +1,6 @@
import { is } from '@electron-toolkit/utils'
import { app } from 'electron'
import { existsSync } from 'fs'
import { existsSync, mkdirSync } from 'fs'
import { rm, writeFile } from 'fs/promises'
import path from 'path'
@ -28,6 +28,13 @@ export function dataDir(): string {
}
}
export function taskDir(): string {
if (!existsSync(app.getPath('userData'))) {
mkdirSync(app.getPath('userData'))
}
return app.getPath('userData')
}
export function exeDir(): string {
return path.dirname(exePath())
}