Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
readable error output
Browse files Browse the repository at this point in the history
  • Loading branch information
pompurin404 committed Oct 21, 2024
1 parent cebece3 commit 911d729
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"chokidar": "^4.0.1",
"dayjs": "^1.11.13",
"express": "^5.0.1",
"iconv-lite": "^0.6.3",
"webdav": "^5.7.1",
"ws": "^8.18.0",
"yaml": "^2.6.0"
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import { exePath, taskDir } from './utils/dirs'
import path from 'path'
import { startMonitor } from './resolve/trafficMonitor'
import { showFloatingWindow } from './resolve/floatingWindow'
import iconv from 'iconv-lite'

let quitTimeout: NodeJS.Timeout | null = null
export let mainWindow: BrowserWindow | null = null

if (process.platform === 'win32' && !is.dev && !process.argv.includes('noadmin')) {
if (process.platform === 'win32' && !process.argv.includes('noadmin')) {
try {
createElevateTask()
} catch (createError) {
Expand All @@ -38,9 +39,17 @@ if (process.platform === 'win32' && !is.dev && !process.argv.includes('noadmin')
execSync('C:\\\\Windows\\System32\\schtasks.exe /run /tn mihomo-party-run')
}
} catch (e) {
let createErrorStr = `${createError}`
let eStr = `${e}`
try {
createErrorStr = iconv.decode((createError as { stderr: Buffer }).stderr, 'gbk')
eStr = iconv.decode((e as { stderr: Buffer }).stderr, 'gbk')
} catch {
// ignore
}
dialog.showErrorBox(
'首次启动请以管理员权限运行',
`首次启动请以管理员权限运行\n${createError}\n${e}`
`首次启动请以管理员权限运行\n${createErrorStr}\n${eStr}`
)
} finally {
app.exit()
Expand Down

0 comments on commit 911d729

Please sign in to comment.