feat: support arm (#401)

This commit is contained in:
star knight
2024-11-27 00:52:16 +08:00
committed by GitHub
parent aa4017d5c0
commit 5b43171ec5
18 changed files with 15880 additions and 254 deletions

View File

@@ -1,14 +1,35 @@
/* global __static */
import DevSidecar from '@docmirror/dev-sidecar'
import Sudoer from 'electron-sudo'
import sudoPrompt from '@vscode/sudo-prompt'
import { join } from 'node:path'
import log from '../../utils/util.log'
export default {
async open () {
const options = { name: '设置loopback' }
const sudoer = new Sudoer(options)
open () {
const options = {
name: 'EnableLoopback',
icns: process.platform === 'darwin' ? join(__static, 'icon.icns') : undefined,
env: { PARAM: 'VALUE' },
}
const exeFile = DevSidecar.api.shell.extraPath.getEnableLoopbackPath()
await sudoer.exec(
exeFile,
{ env: { PARAM: 'VALUE' } },
)
const sudoCommand = [`"${exeFile}"`]
return new Promise((resolve, reject) => {
sudoPrompt.exec(
sudoCommand.join(' '),
options,
(error, _, stderr) => {
if (stderr) {
log.error(`[sudo-prompt] 发生错误: ${stderr}`)
}
if (error) {
reject(error)
} else {
resolve(undefined)
}
},
)
})
},
}