mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-24 21:13:34 +08:00
vm 即将在渲染进程内被禁用,改用简单的沙箱执行命令
This commit is contained in:
@@ -97,7 +97,7 @@ export default {
|
||||
utools.outPlugin();
|
||||
}, 500);
|
||||
if (currentCommand.program === "quickcommand") {
|
||||
window.runCodeInVm(currentCommand.cmd, (stdout, stderr) => {
|
||||
window.runCodeInSandbox(currentCommand.cmd, (stdout, stderr) => {
|
||||
if (stderr) {
|
||||
return quitBeforeShowResult
|
||||
? alert(stderr)
|
||||
|
@@ -10,21 +10,21 @@ let escapeItem = item => {
|
||||
|
||||
let handlingJsonVar = (jsonVar, name) => {
|
||||
try {
|
||||
return escapeItem(window.VmEval(jsonVar.slice(2, -2), {
|
||||
return escapeItem(window.evalCodeInSandbox(jsonVar.slice(2, -2), {
|
||||
[name]: quickcommand.enterData.payload
|
||||
}))
|
||||
} catch {
|
||||
return ""
|
||||
} catch (e) {
|
||||
return utools.showNotification(e)
|
||||
}
|
||||
}
|
||||
|
||||
let handlingJsExpression = js => {
|
||||
try {
|
||||
return window.VmEval(js.slice(5, -2), {
|
||||
return window.evalCodeInSandbox(js.slice(5, -2), {
|
||||
utools: window.getuToolsLite(),
|
||||
})
|
||||
} catch {
|
||||
return ""
|
||||
} catch (e) {
|
||||
return utools.showNotification(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ const specialVars = {
|
||||
name: "js",
|
||||
label: "{{js:}}",
|
||||
desc: "获取js表达式的值,如{{js:utools.isMacOs()}}",
|
||||
tooltip: "注意,必须为表达式而非语句,类似Vue的文本插值。不支持异步/Node",
|
||||
tooltip: "注意,必须为表达式而非语句,类似Vue的文本插值",
|
||||
type: "command",
|
||||
match: /{{js:(.*?)}}/mg,
|
||||
repl: js => handlingJsExpression(js)
|
||||
@@ -147,4 +147,4 @@ const specialVars = {
|
||||
}
|
||||
}
|
||||
|
||||
export default specialVars
|
||||
export default specialVars
|
||||
|
13
src/plugins/monaco/types/common.d.ts
vendored
13
src/plugins/monaco/types/common.d.ts
vendored
@@ -88,16 +88,3 @@ declare var console: {
|
||||
log(message?: any): void,
|
||||
error(message?: any): void
|
||||
}
|
||||
|
||||
// process
|
||||
declare var process: {
|
||||
argv: any[];
|
||||
title: string;
|
||||
version: string;
|
||||
versions: object;
|
||||
arch: string;
|
||||
platform: string;
|
||||
env: object;
|
||||
pid: number;
|
||||
features: object
|
||||
}
|
||||
|
Reference in New Issue
Block a user