You've already forked dev-sidecar
mirror of
https://github.com/docmirror/dev-sidecar.git
synced 2025-11-26 14:10:40 +08:00
feat: support arm (#401)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user