File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ ListenerMessage(new LoggerDAO(), center);
41
41
42
42
IoC . instance ( SystemConfig ) . init ( ) ;
43
43
44
- // 等待沙盒启动后再进行后续的步骤
45
44
IoC . instance ( SystemManager ) . init ( ) ;
46
45
// 资源管理器
47
46
const resourceManager = new ResourceManager ( center ) ;
@@ -66,6 +65,8 @@ window.onload = () => {
66
65
// eslint-disable-next-line no-undef
67
66
const sandboxConnect = new MessageSandbox ( sandbox ) ;
68
67
runtime . startSandbox ( sandboxConnect ) ;
68
+ // eslint-disable-next-line no-undef
69
+ center . setSandbox ( sandbox ) ;
69
70
} ;
70
71
center . setHandler ( "sandboxOnload" , ( ) => {
71
72
return Promise . resolve ( true ) ;
Original file line number Diff line number Diff line change @@ -16,20 +16,22 @@ const loggerCore = new LoggerCore({
16
16
labels : { env : "sandbox" } ,
17
17
} ) ;
18
18
19
- loggerCore . logger ( ) . debug ( "sandbox start" ) ;
20
-
21
19
IoC . instance ( SandboxRuntime ) . init ( ) ;
22
20
21
+ let flag = false ;
23
22
// 为了确认能与background通讯
24
23
const retry = ( ) => {
24
+ if ( flag ) {
25
+ return ;
26
+ }
25
27
const t = setTimeout ( ( ) => {
26
28
retry ( ) ;
27
29
} , 1000 ) ;
28
30
connectSandbox . syncSend ( "sandboxOnload" , { } ) . then ( ( ) => {
29
31
clearTimeout ( t ) ;
32
+ flag = true ;
33
+ loggerCore . logger ( ) . debug ( "sandbox start" ) ;
30
34
} ) ;
31
35
} ;
32
36
33
- window . onload = ( ) => {
34
- retry ( ) ;
35
- } ;
37
+ retry ( ) ;
You can’t perform that action at this time.
0 commit comments