mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
deprecated vbs
This commit is contained in:
parent
1c924bcc89
commit
d250b8b948
|
@ -266,7 +266,11 @@ const resolveSysproxy = () =>
|
||||||
file: 'sysproxy.exe',
|
file: 'sysproxy.exe',
|
||||||
downloadURL: `https://github.com/pompurin404/sysproxy/releases/download/${arch}/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 resolveFont = async () => {
|
||||||
const targetPath = path.join(cwd, 'src', 'renderer', 'src', 'assets', 'NotoColorEmoji.ttf')
|
const targetPath = path.join(cwd, 'src', 'renderer', 'src', 'assets', 'NotoColorEmoji.ttf')
|
||||||
|
|
||||||
|
@ -312,6 +316,12 @@ const tasks = [
|
||||||
func: resolveSysproxy,
|
func: resolveSysproxy,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
winOnly: true
|
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 { readFile } from 'fs/promises'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import { exePath, mihomoCorePath, resourcesDir, taskDir } from '../utils/dirs'
|
import { exePath, mihomoCorePath, resourcesDir, resourcesFilesDir, taskDir } from '../utils/dirs'
|
||||||
import { writeFileSync } from 'fs'
|
import { copyFileSync, writeFileSync } from 'fs'
|
||||||
|
|
||||||
export function getFilePath(ext: string[]): string[] | undefined {
|
export function getFilePath(ext: string[]): string[] | undefined {
|
||||||
return dialog.showOpenDialogSync({
|
return dialog.showOpenDialogSync({
|
||||||
|
@ -81,27 +81,19 @@ const elevateTaskXml = `<?xml version="1.0" encoding="UTF-16"?>
|
||||||
</Settings>
|
</Settings>
|
||||||
<Actions Context="Author">
|
<Actions Context="Author">
|
||||||
<Exec>
|
<Exec>
|
||||||
<Command>wscript.exe</Command>
|
<Command>"${path.join(taskDir(), `mihomo-party-run.exe`)}"</Command>
|
||||||
<Arguments>"${path.join(taskDir(), `mihomo-party-run.vbs`)}"</Arguments>
|
<Arguments>"${exePath()}"</Arguments>
|
||||||
</Exec>
|
</Exec>
|
||||||
</Actions>
|
</Actions>
|
||||||
</Task>
|
</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 {
|
export function createElevateTask(): void {
|
||||||
const taskFilePath = path.join(taskDir(), `mihomo-party-run.xml`)
|
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'))
|
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`)
|
||||||
|
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 {
|
export function taskDir(): string {
|
||||||
if (!existsSync(app.getPath('userData'))) {
|
const dir = path.join(app.getPath('userData'), 'tasks')
|
||||||
mkdirSync(app.getPath('userData'))
|
if (!existsSync(dir)) {
|
||||||
|
mkdirSync(dir, { recursive: true })
|
||||||
}
|
}
|
||||||
return app.getPath('userData')
|
return dir
|
||||||
}
|
}
|
||||||
|
|
||||||
export function exeDir(): string {
|
export function exeDir(): string {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user