mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
fix portable
This commit is contained in:
parent
6d3066c522
commit
54306ee64b
@ -15,7 +15,7 @@ import { execSync } from 'child_process'
|
|||||||
import { createElevateTask } from './sys/misc'
|
import { createElevateTask } from './sys/misc'
|
||||||
import { initProfileUpdater } from './core/profileUpdater'
|
import { initProfileUpdater } from './core/profileUpdater'
|
||||||
import { writeFileSync } from 'fs'
|
import { writeFileSync } from 'fs'
|
||||||
import { dataDir } from './utils/dirs'
|
import { exeDir } from './utils/dirs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
export let mainWindow: BrowserWindow | null = null
|
export let mainWindow: BrowserWindow | null = null
|
||||||
@ -25,9 +25,9 @@ if (process.platform === 'win32' && !is.dev) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
if (process.argv.slice(1).length > 0) {
|
if (process.argv.slice(1).length > 0) {
|
||||||
writeFileSync(path.join(dataDir(), 'param.txt'), process.argv.slice(1).join(' '))
|
writeFileSync(path.join(exeDir(), 'param.txt'), process.argv.slice(1).join(' '))
|
||||||
} else {
|
} else {
|
||||||
writeFileSync(path.join(dataDir(), 'param.txt'), 'empty')
|
writeFileSync(path.join(exeDir(), 'param.txt'), 'empty')
|
||||||
}
|
}
|
||||||
execSync('schtasks /run /tn mihomo-party-run')
|
execSync('schtasks /run /tn mihomo-party-run')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { dialog, nativeTheme } from 'electron'
|
|||||||
import { readFile } from 'fs/promises'
|
import { readFile } from 'fs/promises'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import { dataDir, exePath, mihomoCorePath, resourcesDir } from '../utils/dirs'
|
import { exeDir, exePath, mihomoCorePath, resourcesDir } from '../utils/dirs'
|
||||||
import { writeFileSync } from 'fs'
|
import { writeFileSync } from 'fs'
|
||||||
|
|
||||||
export function getFilePath(ext: string[]): string[] | undefined {
|
export function getFilePath(ext: string[]): string[] | undefined {
|
||||||
@ -82,7 +82,7 @@ const elevateTaskXml = `<?xml version="1.0" encoding="UTF-16"?>
|
|||||||
<Actions Context="Author">
|
<Actions Context="Author">
|
||||||
<Exec>
|
<Exec>
|
||||||
<Command>wscript.exe</Command>
|
<Command>wscript.exe</Command>
|
||||||
<Arguments>"${path.join(dataDir(), `mihomo-party-run.vbs`)}"</Arguments>
|
<Arguments>"${path.join(exeDir(), `mihomo-party-run.vbs`)}"</Arguments>
|
||||||
</Exec>
|
</Exec>
|
||||||
</Actions>
|
</Actions>
|
||||||
</Task>
|
</Task>
|
||||||
@ -100,8 +100,8 @@ shell.Run commandLine, 0, false
|
|||||||
`
|
`
|
||||||
|
|
||||||
export function createElevateTask(): void {
|
export function createElevateTask(): void {
|
||||||
const taskFilePath = path.join(dataDir(), `mihomo-party-run.xml`)
|
const taskFilePath = path.join(exeDir(), `mihomo-party-run.xml`)
|
||||||
writeFileSync(path.join(dataDir(), `mihomo-party-run.vbs`), startScript)
|
writeFileSync(path.join(exeDir(), `mihomo-party-run.vbs`), startScript)
|
||||||
writeFileSync(taskFilePath, Buffer.from(`\ufeff${elevateTaskXml}`, 'utf-16le'))
|
writeFileSync(taskFilePath, Buffer.from(`\ufeff${elevateTaskXml}`, 'utf-16le'))
|
||||||
execSync(`schtasks /create /tn "mihomo-party-run" /xml "${taskFilePath}" /f`)
|
execSync(`schtasks /create /tn "mihomo-party-run" /xml "${taskFilePath}" /f`)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user