update dependencies and fix elevate

This commit is contained in:
pompurin404 2024-10-03 14:35:47 +08:00
parent d247dbebfc
commit bf52f02b82
No known key found for this signature in database
4 changed files with 981 additions and 1020 deletions

View File

@ -43,25 +43,25 @@
"@electron-toolkit/tsconfig": "^1.0.1",
"@nextui-org/react": "^2.4.8",
"@types/adm-zip": "^0.5.5",
"@types/express": "^4.17.21",
"@types/node": "^22.6.1",
"@types/express": "^5.0.0",
"@types/node": "^22.7.4",
"@types/pubsub-js": "^1.8.6",
"@types/react": "^18.3.9",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@types/ws": "^8.5.12",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.3.2",
"autoprefixer": "^10.4.20",
"cron-validator": "^1.3.1",
"driver.js": "^1.3.1",
"electron": "^32.1.2",
"electron-builder": "^25.0.5",
"electron-builder": "25.0.4",
"electron-vite": "^2.3.0",
"electron-window-state": "^5.0.3",
"eslint": "^8.57.1",
"eslint-plugin-react": "^7.36.1",
"framer-motion": "^11.5.6",
"eslint-plugin-react": "^7.37.1",
"framer-motion": "^11.9.0",
"lodash": "^4.17.21",
"meta-json-schema": "^1.18.8",
"meta-json-schema": "^1.18.9",
"monaco-yaml": "^5.2.2",
"nanoid": "^5.0.7",
"next-themes": "^0.3.0",
@ -83,7 +83,7 @@
"tsx": "^4.19.1",
"types-pac": "^1.0.3",
"typescript": "^5.6.2",
"vite": "^5.4.7",
"vite": "^5.4.8",
"vite-plugin-monaco-editor": "^1.1.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ import { init } from './utils/init'
import { join } from 'path'
import { initShortcut } from './resolve/shortcut'
import { execSync, spawn } from 'child_process'
import { createElevateTask } from './sys/misc'
import { createElevateTask, isElvated } from './sys/misc'
import { initProfileUpdater } from './core/profileUpdater'
import { existsSync, writeFileSync } from 'fs'
import { exePath, taskDir } from './utils/dirs'
@ -20,9 +20,15 @@ import { startMonitor } from './resolve/trafficMonitor'
let quitTimeout: NodeJS.Timeout | null = null
export let mainWindow: BrowserWindow | null = null
if (process.platform === 'win32' && !is.dev && !process.argv.includes('noadmin')) {
try {
createElevateTask()
isElvated()
try {
createElevateTask()
} catch {
// ignore
}
} catch (e) {
try {
if (process.argv.slice(1).length > 0) {

View File

@ -105,6 +105,10 @@ const elevateTaskXml = `<?xml version="1.0" encoding="UTF-16"?>
</Task>
`
export function isElvated(): void {
execSync('net session')
}
export function createElevateTask(): void {
const taskFilePath = path.join(taskDir(), `mihomo-party-run.xml`)
writeFileSync(taskFilePath, Buffer.from(`\ufeff${elevateTaskXml}`, 'utf-16le'))