Skip to content

Commit 4d0e056

Browse files
committed
fix: eval执行脚本内方法
1 parent dac2cc6 commit 4d0e056

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/pkg/sandbox/sandbox.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ for (const key in descs) {
4242
export function buildThis(global: any, context: any) {
4343
let special = Object.assign({}, writables);
4444
// 后台脚本要不要考虑不能使用eval?
45-
let _this: any = { eval: global.eval };
45+
let _this: any = {};
4646
let proxy: any = new Proxy(context, {
4747
defineProperty(_, name, desc) {
4848
return Object.defineProperty(context, name, desc);
@@ -113,5 +113,6 @@ export function buildThis(global: any, context: any) {
113113
return ret;
114114
}
115115
});
116+
_this.eval = global.eval.bind(proxy);
116117
return proxy;
117118
}

0 commit comments

Comments
 (0)