This commit is contained in:
pompurin404 2024-08-28 11:48:56 +08:00
parent 6240351cb9
commit 7504fd8010
No known key found for this signature in database
3 changed files with 14 additions and 14 deletions

View File

@ -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) {

View File

@ -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`)
}

View File

@ -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,