@@ -63,16 +63,41 @@ function doWxss(dir,cb){
63
63
result [ cssFile ] += makeup ( data ) ;
64
64
} ;
65
65
}
66
- function runVM ( name , code ) {
67
- code = code . replace ( '__mainPageFrameReady__()' , '' ) ;
68
- let wxAppCode = { } , handle = { cssFile :name } ;
69
- let vm = new VM ( { sandbox :Object . assign ( new GwxCfg ( ) , { __wxAppCode__ :wxAppCode , setCssToHead :cssRebuild . bind ( handle ) } ) } ) ;
70
- vm . run ( code ) ;
71
- for ( let name in wxAppCode ) if ( name . endsWith ( ".wxss" ) ) {
72
- handle . cssFile = path . resolve ( frameName , ".." , name ) ;
73
- wxAppCode [ name ] ( ) ;
74
- }
75
- }
66
+
67
+ function runVM ( name , code ) {
68
+ // let wxAppCode = {}, handle = {cssFile: name};
69
+ // let vm = new VM({
70
+ // sandbox: Object.assign(new GwxCfg(), {
71
+ // __wxAppCode__: wxAppCode,
72
+ // setCssToHead: cssRebuild.bind(handle)
73
+ // })
74
+ // });
75
+ // vm.run(code);
76
+ // for (let name in wxAppCode) if (name.endsWith(".wxss")) {
77
+ // handle.cssFile = path.resolve(frameName, "..", name);
78
+ // wxAppCode[name]();
79
+ // }
80
+
81
+ let wxAppCode = { } ;
82
+ let handle = { cssFile : name } ;
83
+ let gg = new GwxCfg ( ) ;
84
+ let tsandbox = {
85
+ $gwx : GwxCfg . prototype [ "$gwx" ] ,
86
+ __mainPageFrameReady__ : GwxCfg . prototype [ "$gwx" ] , //解决 $gwx is not defined
87
+ __vd_version_info__ : GwxCfg . prototype [ "$gwx" ] , //解决 __vd_version_info__ is not defined
88
+ __wxAppCode__ : wxAppCode ,
89
+ setCssToHead : cssRebuild . bind ( handle )
90
+ }
91
+
92
+ let vm = new VM ( { sandbox : tsandbox } ) ;
93
+ vm . run ( code ) ;
94
+ for ( let name in wxAppCode ) {
95
+ if ( name . endsWith ( ".wxss" ) ) {
96
+ handle . cssFile = path . resolve ( frameName , ".." , name ) ;
97
+ wxAppCode [ name ] ( ) ;
98
+ }
99
+ }
100
+ }
76
101
function preRun ( dir , frameFile , mainCode , files , cb ) {
77
102
wu . addIO ( cb ) ;
78
103
runList [ path . resolve ( dir , "./app.wxss" ) ] = mainCode ;
@@ -83,8 +108,11 @@ function doWxss(dir,cb){
83
108
} ) ;
84
109
}
85
110
}
86
- function runOnce ( ) {
87
- for ( let name in runList ) runVM ( name , runList [ name ] ) ;
111
+ function runOnce ( ) {
112
+ for ( let name in runList ) {
113
+ // console.log(name, runList[name]);
114
+ runVM ( name , runList [ name ] ) ;
115
+ }
88
116
}
89
117
function transformCss ( style ) {
90
118
let ast = csstree . parse ( style ) ;
0 commit comments