Merge branch 'dev' into linux-key-service-bundle

This commit is contained in:
xuncha
2026-03-19 16:34:36 +08:00
committed by GitHub
3 changed files with 23 additions and 4 deletions

View File

@@ -96,7 +96,13 @@ let keyService: any
if (process.platform === 'darwin') {
keyService = new KeyServiceMac()
} else if (process.platform === 'linux') {
keyService = new KeyServiceLinux()
// const { KeyServiceLinux } = require('./services/keyServiceLinux')
// keyService = new KeyServiceLinux()
import('./services/keyServiceLinux').then(({ KeyServiceLinux }) => {
keyService = new KeyServiceLinux();
});
} else {
keyService = new KeyService()
}

View File

@@ -3,7 +3,8 @@ import { join } from 'path'
import { existsSync, readdirSync, statSync, readFileSync } from 'fs'
import { execFile, exec } from 'child_process'
import { promisify } from 'util'
import sudo from 'sudo-prompt'
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const execFileAsync = promisify(execFile)
const execAsync = promisify(exec)
@@ -12,6 +13,15 @@ type DbKeyResult = { success: boolean; key?: string; error?: string; logs?: stri
type ImageKeyResult = { success: boolean; xorKey?: number; aesKey?: string; error?: string }
export class KeyServiceLinux {
private sudo: any
constructor() {
try {
this.sudo = require('sudo-prompt');
} catch (e) {
console.error('Failed to load sudo-prompt', e);
}
}
private getHelperPath(): string {
const isPackaged = app.isPackaged
@@ -99,7 +109,7 @@ export class KeyServiceLinux {
const options = { name: 'WeFlow' }
const command = `"${helperPath}" db_hook ${pid} ${targetAddr}`
sudo.exec(command, options, (error, stdout) => {
this.sudo.exec(command, options, (error, stdout) => {
execAsync(`kill -CONT ${pid}`).catch(() => {})
if (error) {
onStatus?.('授权失败或被取消', 2)

View File

@@ -92,7 +92,6 @@
"linux": {
"icon": "public/icon.png",
"target": [
"AppImage",
"pacman",
"deb",
"tar.gz"
@@ -131,6 +130,10 @@
"from": "public/icon.ico",
"to": "icon.ico"
},
{
"from": "public/icon.png",
"to": "icon.png"
},
{
"from": "electron/assets/wasm/",
"to": "assets/wasm/"