提交 acf88518 编写于 作者: A aistri

Update wuWxss.js

上级 53a4400d
...@@ -63,16 +63,41 @@ function doWxss(dir,cb){ ...@@ -63,16 +63,41 @@ function doWxss(dir,cb){
result[cssFile]+=makeup(data); result[cssFile]+=makeup(data);
}; };
} }
function runVM(name,code){
code = code.replace('__mainPageFrameReady__()', ''); function runVM(name, code) {
let wxAppCode={},handle={cssFile:name}; // let wxAppCode = {}, handle = {cssFile: name};
let vm=new VM({sandbox:Object.assign(new GwxCfg(),{__wxAppCode__:wxAppCode,setCssToHead:cssRebuild.bind(handle)})}); // let vm = new VM({
vm.run(code); // sandbox: Object.assign(new GwxCfg(), {
for(let name in wxAppCode)if(name.endsWith(".wxss")){ // __wxAppCode__: wxAppCode,
handle.cssFile=path.resolve(frameName,"..",name); // setCssToHead: cssRebuild.bind(handle)
wxAppCode[name](); // })
} // });
} // vm.run(code);
// for (let name in wxAppCode) if (name.endsWith(".wxss")) {
// handle.cssFile = path.resolve(frameName, "..", name);
// wxAppCode[name]();
// }
let wxAppCode = {};
let handle = {cssFile: name};
let gg = new GwxCfg();
let tsandbox = {
$gwx: GwxCfg.prototype["$gwx"],
__mainPageFrameReady__: GwxCfg.prototype["$gwx"], //解决 $gwx is not defined
__vd_version_info__: GwxCfg.prototype["$gwx"], //解决 __vd_version_info__ is not defined
__wxAppCode__: wxAppCode,
setCssToHead: cssRebuild.bind(handle)
}
let vm = new VM({sandbox: tsandbox});
vm.run(code);
for (let name in wxAppCode) {
if (name.endsWith(".wxss")) {
handle.cssFile = path.resolve(frameName, "..", name);
wxAppCode[name]();
}
}
}
function preRun(dir,frameFile,mainCode,files,cb){ function preRun(dir,frameFile,mainCode,files,cb){
wu.addIO(cb); wu.addIO(cb);
runList[path.resolve(dir,"./app.wxss")]=mainCode; runList[path.resolve(dir,"./app.wxss")]=mainCode;
...@@ -83,8 +108,11 @@ function doWxss(dir,cb){ ...@@ -83,8 +108,11 @@ function doWxss(dir,cb){
}); });
} }
} }
function runOnce(){ function runOnce() {
for(let name in runList)runVM(name,runList[name]); for (let name in runList) {
// console.log(name, runList[name]);
runVM(name, runList[name]);
}
} }
function transformCss(style){ function transformCss(style){
let ast=csstree.parse(style); let ast=csstree.parse(style);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册