From 5c7f1b7ac5c1d26ff7698f12f336f18f572413e8 Mon Sep 17 00:00:00 2001 From: 4qwerty7 <5781325+qwerty472123@users.noreply.github.com> Date: Tue, 24 Apr 2018 03:09:02 +0800 Subject: [PATCH] update wuRestoreZ.js to fix an error by mistake --- README.md | 1 + wuRestoreZ.js | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9f6749a2..ba5cf725 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Android 手机最近使用过的微信小程序所对应的 wxapkg 包文件都 - wxs 文件会将所有的变量如 Math 改为 nv_Math ,这里仅通过字符串替换去除。 - 一些被引用 wxss 文件本身的源文件丢失,因此无法恢复原始目录。 - 有些项目开启了难以复原的`es6转es5`选项,检验本项目结果是否正确时需要关闭项目中的`es6转es5`选项。 +- wxml 中一些无法找到正向语句的内容无法还原。 ## 依赖 diff --git a/wuRestoreZ.js b/wuRestoreZ.js index 835901e2..f020184b 100644 --- a/wuRestoreZ.js +++ b/wuRestoreZ.js @@ -11,14 +11,14 @@ function catchZ(code,cb){ vm.run(code); cb(z); } -function restoreSingle(ops,withScope=false,par=''){ +function restoreSingle(ops,withScope=false){ if(typeof ops=="undefined")return ""; function scope(value){ if(value.startsWith('{')&&value.endsWith('}'))return withScope?value:"{"+value+"}"; return withScope?value:"{{"+value+"}}"; } - function restoreNext(ops,w=withScope,p=par){ - return restoreSingle(ops,w,p); + function restoreNext(ops,w=withScope){ + return restoreSingle(ops,w); } function jsoToWxon(obj){//convert JS Object to Wechat Object Notation(No quotes@key+str) let ans=""; @@ -44,9 +44,9 @@ function restoreSingle(ops,withScope=false,par=''){ return "'"+ret.join('"')+"'"; }else return JSON.stringify(obj); } - function son(value,notObject=false){ + function son(value){ if(/^[A-Za-z\_][A-Za-z\d\_]*$/.test(value)/*is a qualified id*/){return '.'+value} - else return '['+(notObject?value:jsoToWxon(value))+']'; + else return '['+value+']'; } let op=ops[0]; if(typeof op!="object"){ @@ -131,17 +131,26 @@ function restoreSingle(ops,withScope=false,par=''){ break; } case 6://get value of an object - ans=restoreNext(ops[1],true)+son(restoreNext(ops[2],true),true); + { + let sonName=restoreNext(ops[2],true); + if(sonName._type==="var") + ans=restoreNext(ops[1],true)+'['+sonName+']'; + else + ans=restoreNext(ops[1],true)+son(sonName); break; - case 7://get value(may be value of one object) + } + case 7://get value of str { switch(ops[1][0]){ case 11: - ans=par; + ans="{__unTestedGetValue:["+jsoToWxon(ops)+"]}"; break; case 3: - ans=par?(par+son(ops[1][1])):ops[1][1]; + ans=new String(ops[1][1]); + ans._type="var"; break; + default: + throw "Unknown type to get value"; } break; }