18603046467
3 years ago
17 changed files with 141 additions and 103 deletions
@ -0,0 +1,22 @@
|
||||
/** |
||||
*/ |
||||
const Shell = require('../shell') |
||||
const extraPath = require('./extra-path') |
||||
const execute = Shell.execute |
||||
const executor = { |
||||
async windows (exec) { |
||||
const loopbackPath = extraPath.getEnableLoopbackPath() |
||||
const execFile = Shell.execFile |
||||
await execFile(loopbackPath) |
||||
}, |
||||
async linux (exec, { port }) { |
||||
throw Error('不支持此操作') |
||||
}, |
||||
async mac (exec, { port }) { |
||||
throw Error('不支持此操作') |
||||
} |
||||
} |
||||
|
||||
module.exports = async function (args) { |
||||
return execute(executor, args) |
||||
} |
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
const log = require('../../../utils/util.log') |
||||
const path = require('path') |
||||
|
||||
function getExtraPath () { |
||||
let extraPath = process.env.DS_EXTRA_PATH |
||||
log.info('extraPath', extraPath) |
||||
if (!extraPath) { |
||||
extraPath = __dirname |
||||
} |
||||
return extraPath |
||||
} |
||||
|
||||
function getProxyExePath () { |
||||
const extraPath = getExtraPath() |
||||
return path.join(extraPath, 'sysproxy.exe') |
||||
} |
||||
|
||||
function getClearBatPath () { |
||||
const extraPath = getExtraPath() |
||||
return path.join(extraPath, 'clear.bat') |
||||
} |
||||
|
||||
function getEnableLoopbackPath () { |
||||
const extraPath = getExtraPath() |
||||
return path.join(extraPath, 'EnableLoopback.exe') |
||||
} |
||||
module.exports = { |
||||
getProxyExePath, |
||||
getEnableLoopbackPath, |
||||
getClearBatPath |
||||
} |
After Width: | Height: | Size: 97 KiB |
@ -0,0 +1,12 @@
|
||||
import Sudoer from 'electron-sudo' |
||||
import DevSidecar from '@docmirror/dev-sidecar' |
||||
export default { |
||||
async open () { |
||||
const options = { name: '设置loopback' } |
||||
const sudoer = new Sudoer(options) |
||||
const exeFile = DevSidecar.api.shell.extraPath.getEnableLoopbackPath() |
||||
await sudoer.exec( |
||||
exeFile, { env: { PARAM: 'VALUE' } } |
||||
) |
||||
} |
||||
} |
Loading…
Reference in new issue