mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
use vbs
This commit is contained in:
parent
6240351cb9
commit
7504fd8010
|
@ -27,7 +27,7 @@ if (process.platform === 'win32' && !is.dev) {
|
|||
if (process.argv.slice(1).length > 0) {
|
||||
writeFileSync(path.join(dataDir(), 'param.txt'), process.argv.slice(1).join(' '))
|
||||
} else {
|
||||
writeFileSync(path.join(dataDir(), 'param.txt'), '')
|
||||
writeFileSync(path.join(dataDir(), 'param.txt'), 'empty')
|
||||
}
|
||||
execSync('schtasks /run /tn mihomo-party-run')
|
||||
} catch (e) {
|
||||
|
|
|
@ -81,25 +81,27 @@ const elevateTaskXml = `<?xml version="1.0" encoding="UTF-16"?>
|
|||
</Settings>
|
||||
<Actions Context="Author">
|
||||
<Exec>
|
||||
<Command>powershell</Command>
|
||||
<Arguments>-WindowStyle Hidden -File "${path.join(dataDir(), `mihomo-party-run.ps1`)}"</Arguments>
|
||||
<Command>wscript.exe</Command>
|
||||
<Arguments>"${path.join(dataDir(), `mihomo-party-run.vbs`)}"</Arguments>
|
||||
</Exec>
|
||||
</Actions>
|
||||
</Task>
|
||||
`
|
||||
|
||||
const startScript = `$paramFilePath = Join-Path -Path $PSScriptRoot -ChildPath "param.txt"
|
||||
if (Test-Path -Path $paramFilePath) {
|
||||
$paramContent = Get-Content -Path $paramFilePath
|
||||
& "${exePath()}" $paramContent
|
||||
} else {
|
||||
& "${exePath()}"
|
||||
}
|
||||
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(dataDir(), `mihomo-party-run.xml`)
|
||||
writeFileSync(path.join(dataDir(), `mihomo-party-run.ps1`), startScript)
|
||||
writeFileSync(path.join(dataDir(), `mihomo-party-run.vbs`), startScript)
|
||||
writeFileSync(taskFilePath, Buffer.from(`\ufeff${elevateTaskXml}`, 'utf-16le'))
|
||||
execSync(`schtasks /create /tn "mihomo-party-run" /xml "${taskFilePath}" /f`)
|
||||
}
|
||||
|
|
|
@ -10,9 +10,7 @@ const RuleCard: React.FC = () => {
|
|||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const match = location.pathname.includes('/rules')
|
||||
const { data: rules } = useSWR<IMihomoRulesInfo>('mihomoRules', mihomoRules, {
|
||||
refreshInterval: 5000
|
||||
})
|
||||
const { data: rules } = useSWR<IMihomoRulesInfo>('mihomoRules', mihomoRules)
|
||||
const {
|
||||
attributes,
|
||||
listeners,
|
||||
|
|
Loading…
Reference in New Issue
Block a user