mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +08:00
deprecated vbs
This commit is contained in:
parent
1c924bcc89
commit
d250b8b948
|
@ -266,7 +266,11 @@ const resolveSysproxy = () =>
|
|||
file: 'sysproxy.exe',
|
||||
downloadURL: `https://github.com/pompurin404/sysproxy/releases/download/${arch}/sysproxy.exe`
|
||||
})
|
||||
|
||||
const resolveRunner = () =>
|
||||
resolveResource({
|
||||
file: 'mihomo-party-run.exe',
|
||||
downloadURL: `https://github.com/pompurin404/mihomo-party-run/releases/download/${arch}/mihomo-party-run.exe`
|
||||
})
|
||||
const resolveFont = async () => {
|
||||
const targetPath = path.join(cwd, 'src', 'renderer', 'src', 'assets', 'NotoColorEmoji.ttf')
|
||||
|
||||
|
@ -312,6 +316,12 @@ const tasks = [
|
|||
func: resolveSysproxy,
|
||||
retry: 5,
|
||||
winOnly: true
|
||||
},
|
||||
{
|
||||
name: 'runner',
|
||||
func: resolveRunner,
|
||||
retry: 5,
|
||||
winOnly: true
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ import { dialog, nativeTheme } from 'electron'
|
|||
import { readFile } from 'fs/promises'
|
||||
import path from 'path'
|
||||
import { promisify } from 'util'
|
||||
import { exePath, mihomoCorePath, resourcesDir, taskDir } from '../utils/dirs'
|
||||
import { writeFileSync } from 'fs'
|
||||
import { exePath, mihomoCorePath, resourcesDir, resourcesFilesDir, taskDir } from '../utils/dirs'
|
||||
import { copyFileSync, writeFileSync } from 'fs'
|
||||
|
||||
export function getFilePath(ext: string[]): string[] | undefined {
|
||||
return dialog.showOpenDialogSync({
|
||||
|
@ -81,27 +81,19 @@ const elevateTaskXml = `<?xml version="1.0" encoding="UTF-16"?>
|
|||
</Settings>
|
||||
<Actions Context="Author">
|
||||
<Exec>
|
||||
<Command>wscript.exe</Command>
|
||||
<Arguments>"${path.join(taskDir(), `mihomo-party-run.vbs`)}"</Arguments>
|
||||
<Command>"${path.join(taskDir(), `mihomo-party-run.exe`)}"</Command>
|
||||
<Arguments>"${exePath()}"</Arguments>
|
||||
</Exec>
|
||||
</Actions>
|
||||
</Task>
|
||||
`
|
||||
|
||||
const startScript = `Dim fso, file, params, shell, currentPath
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
currentPath = fso.GetParentFolderName(WScript.ScriptFullName)
|
||||
Set file = fso.OpenTextFile(currentPath & "\\param.txt", 1)
|
||||
params = file.ReadAll
|
||||
file.Close
|
||||
Set shell = CreateObject("WScript.Shell")
|
||||
commandLine = """" & "${exePath()}"" " & params
|
||||
shell.Run commandLine, 0, false
|
||||
`
|
||||
|
||||
export function createElevateTask(): void {
|
||||
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`)
|
||||
copyFileSync(
|
||||
path.join(resourcesFilesDir(), 'mihomo-party-run.exe'),
|
||||
path.join(taskDir(), 'mihomo-party-run.exe')
|
||||
)
|
||||
}
|
||||
|
|
|
@ -29,10 +29,11 @@ export function dataDir(): string {
|
|||
}
|
||||
|
||||
export function taskDir(): string {
|
||||
if (!existsSync(app.getPath('userData'))) {
|
||||
mkdirSync(app.getPath('userData'))
|
||||
const dir = path.join(app.getPath('userData'), 'tasks')
|
||||
if (!existsSync(dir)) {
|
||||
mkdirSync(dir, { recursive: true })
|
||||
}
|
||||
return app.getPath('userData')
|
||||
return dir
|
||||
}
|
||||
|
||||
export function exeDir(): string {
|
||||
|
|
Loading…
Reference in New Issue
Block a user