Skip to content

Commit

Permalink
处理沙盒中特殊变量赋值&缓存删除
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Oct 10, 2021
1 parent 2f17223 commit 9061571
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/apps/script/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ export class ScriptManager {
}
if (script.status == SCRIPT_STATUS_ENABLE) {
await this.disableScript(script, true);
} else {
script.status = SCRIPT_STATUS_DELETE;
AppEvent.trigger(ScriptStatusChange, script);
}
await this.scriptModel.delete(script.id);
//TODO:释放资源
Expand Down
9 changes: 8 additions & 1 deletion src/pkg/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function buildThis(global: any, context: any) {
case 'window':
case 'global':
case 'globalThis':
return proxy;
return special[name] || proxy;
}
if (name !== 'undefined' && name !== Symbol.unscopables) {
if (context[name]) {
Expand All @@ -96,6 +96,13 @@ export function buildThis(global: any, context: any) {
return name == 'undefined' || context[name] || global.hasOwnProperty(name);
},
set(_, name: string, val) {
switch (name) {
case 'window':
case 'global':
case 'globalThis':
special[name] = val;
return true;
}
if (special[name]) {
special[name] = val;
return true;
Expand Down

0 comments on commit 9061571

Please sign in to comment.