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) { if (process.argv.slice(1).length > 0) {
writeFileSync(path.join(dataDir(), 'param.txt'), process.argv.slice(1).join(' ')) writeFileSync(path.join(dataDir(), 'param.txt'), process.argv.slice(1).join(' '))
} else { } else {
writeFileSync(path.join(dataDir(), 'param.txt'), '') writeFileSync(path.join(dataDir(), 'param.txt'), 'empty')
} }
execSync('schtasks /run /tn mihomo-party-run') execSync('schtasks /run /tn mihomo-party-run')
} catch (e) { } catch (e) {

View File

@ -81,25 +81,27 @@ const elevateTaskXml = `<?xml version="1.0" encoding="UTF-16"?>
</Settings> </Settings>
<Actions Context="Author"> <Actions Context="Author">
<Exec> <Exec>
<Command>powershell</Command> <Command>wscript.exe</Command>
<Arguments>-WindowStyle Hidden -File "${path.join(dataDir(), `mihomo-party-run.ps1`)}"</Arguments> <Arguments>"${path.join(dataDir(), `mihomo-party-run.vbs`)}"</Arguments>
</Exec> </Exec>
</Actions> </Actions>
</Task> </Task>
` `
const startScript = `$paramFilePath = Join-Path -Path $PSScriptRoot -ChildPath "param.txt" const startScript = `Dim fso, file, params, shell, currentPath
if (Test-Path -Path $paramFilePath) { Set fso = CreateObject("Scripting.FileSystemObject")
$paramContent = Get-Content -Path $paramFilePath currentPath = fso.GetParentFolderName(WScript.ScriptFullName)
& "${exePath()}" $paramContent Set file = fso.OpenTextFile(currentPath & "\\param.txt", 1)
} else { params = file.ReadAll
& "${exePath()}" 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(dataDir(), `mihomo-party-run.xml`) 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')) 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`)
} }

View File

@ -10,9 +10,7 @@ const RuleCard: React.FC = () => {
const navigate = useNavigate() const navigate = useNavigate()
const location = useLocation() const location = useLocation()
const match = location.pathname.includes('/rules') const match = location.pathname.includes('/rules')
const { data: rules } = useSWR<IMihomoRulesInfo>('mihomoRules', mihomoRules, { const { data: rules } = useSWR<IMihomoRulesInfo>('mihomoRules', mihomoRules)
refreshInterval: 5000
})
const { const {
attributes, attributes,
listeners, listeners,