vm 即将在渲染进程内被禁用,改用简单的沙箱执行命令

This commit is contained in:
fofolee
2022-04-18 17:41:04 +08:00
parent 24d0dd1e2a
commit a27fe4c338
12 changed files with 111 additions and 3422 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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
}