From a049b2ab7f88a5e78c1348e951976330292b1d10 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Thu, 29 Aug 2024 11:12:05 +0800 Subject: [PATCH] 1.1.1 --- changelog.md | 9 ++------- package.json | 2 +- src/main/index.ts | 6 +++--- src/main/sys/autoRun.ts | 4 ++-- src/main/sys/misc.ts | 8 ++++---- src/main/utils/dirs.ts | 9 ++++++++- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/changelog.md b/changelog.md index 058f53b..d4d1655 100644 --- a/changelog.md +++ b/changelog.md @@ -1,9 +1,4 @@ -### New Features - -- 调整MacOS托盘尺寸 - ### Bug Fixes -- 修复MacOS系统代理修改失败的问题 -- 修复Windows URL Scheme失效的问题 -- 修复DNS策略无法删除的问题 +- 修复便携模式无法启动的问题 +- 尝试修复Windows系统代理无法打开的问题 diff --git a/package.json b/package.json index e3f1c61..804b064 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main/index.ts b/src/main/index.ts index ee2b969..897dd72 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -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) { diff --git a/src/main/sys/autoRun.ts b/src/main/sys/autoRun.ts index a50842b..5236dda 100644 --- a/src/main/sys/autoRun.ts +++ b/src/main/sys/autoRun.ts @@ -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 { export async function enableAutoRun(): Promise { 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`) } diff --git a/src/main/sys/misc.ts b/src/main/sys/misc.ts index 4537780..70b76c8 100644 --- a/src/main/sys/misc.ts +++ b/src/main/sys/misc.ts @@ -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 = ` wscript.exe - "${path.join(exeDir(), `mihomo-party-run.vbs`)}" + "${path.join(taskDir(), `mihomo-party-run.vbs`)}" @@ -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`) } diff --git a/src/main/utils/dirs.ts b/src/main/utils/dirs.ts index 97ff255..9bad78e 100644 --- a/src/main/utils/dirs.ts +++ b/src/main/utils/dirs.ts @@ -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()) }