支持获取进入插件的payload

This commit is contained in:
fofolee 2020-06-28 23:36:00 +08:00
parent 5967bab60e
commit 96c431a230
3 changed files with 15 additions and 10 deletions

View File

@ -46,7 +46,7 @@
if (db.program == "custom") {
option = db.customOptions;
} else if(db.program == "quickcommand"){
option = "quickcommand";
option = { mode: "quickcommand", payload: payload };
}else{
option = programs[db.program];
}
@ -109,12 +109,12 @@
setTimeout(() => { utools.outPlugin(); }, 500);
}
var outputOpts = { type: output, autoScroll: autoScroll, autoHeight: autoHeight }
if (option == "quickcommand") {
if (option.mode) {
// 内置环境
runCodeInVm(cmd, (stdout, stderr) => {
if (cmd.includes("utools.setExpendHeight")) outputOpts.autoHeight = false
switchQuickCommandResult(stdout, stderr, outputOpts)
})
}, option.payload)
} else {
var terminal = output == 'terminal' ? true : false
outputOpts.scriptPath = getQuickCommandScriptFile(option.ext)
@ -200,9 +200,11 @@
// 兼容暗黑模式
let adaptDarkMode = () => {
if (utools.isDarkColors()) {
!$('#darkmode').length && $('head').append('<link id="darkmode" rel="stylesheet" href="assets/style/darkmode.css">')
!$('#darkmode').length && $('head').append(`
<link id="darkmode" rel="stylesheet" href="assets/style/darkmode.css">
<link id="darkswal" rel="stylesheet" href="assets/plugins/sweetalert2/dark.min.css">`)
} else {
$('#darkmode').length && $('#darkmode').remove()
$('#darkmode').length && $('#darkmode, #darkswal').remove()
}
}
}()

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" href="assets/style/options.css">
<link rel="stylesheet" href="assets/plugins/select2/select2.min.css">
<script src="assets/plugins/jquery-3.3.1.min.js"></script>
<script src="assets/plugins/sweetalert2.all.min.js"></script>
<script src="assets/plugins/sweetalert2/sweetalert2.all.min.js"></script>
<script src="assets/plugins/beautify.min.js"></script>
<script src="assets/plugins/mousetrap/mousetrap.min.js"></script>
<script src="assets/plugins/mousetrap/mousetrap-record.min.js"></script>

View File

@ -105,7 +105,7 @@ quickcommand = {
var options = {
html: html,
focusConfirm: false,
backdrop: '#bbb',
backdrop: utools.isDarkColors() ? '#464646' : '#bbb',
preConfirm: () => {
for (let i = 0; i < inputBoxNumbers; i++) {
result.push(document.getElementById(`inputBox${i}`).value)
@ -139,7 +139,7 @@ quickcommand = {
}
},
html: html,
backdrop: '#bbb',
backdrop: utools.isDarkColors() ? '#464646' : '#bbb',
showConfirmButton: false
}
swalOneByOne(options)
@ -263,7 +263,9 @@ var getSandboxFuns = () => {
return sandbox
}
runCodeInVm = (cmd, cb) => {
runCodeInVm = (cmd, cb, payload = "") => {
var sandbox = getSandboxFuns()
sandbox.quickcommand.payload = payload
const vm = new NodeVM({
require: {
external: true,
@ -271,7 +273,7 @@ runCodeInVm = (cmd, cb) => {
},
console: 'redirect',
env: process.env,
sandbox: getSandboxFuns(),
sandbox: sandbox,
});
var parseItem = item => {
@ -392,6 +394,7 @@ dirPythonMod = (mod, cb) => {
getNodeJsCommand = () => {
var obj = getSandboxFuns()
obj.Buffer = Buffer
obj.quickcommand.payload = ''
return obj
}