From 5d01b3cc8396104c5ed7a0793b5387afc39683d8 Mon Sep 17 00:00:00 2001 From: yuche Date: Mon, 3 Dec 2018 20:36:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(taroize):=20=20class=20=E5=86=85=E9=83=A8?= =?UTF-8?q?=20wx.=20=E5=BC=80=E5=A4=B4=E7=9A=84=E5=87=BD=E6=95=B0=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E8=BD=AC=E6=8D=A2=E4=B8=BA=20Taro.func()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taroize/src/script.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/taroize/src/script.ts b/packages/taroize/src/script.ts index 2e7bd56b635d..e87dc4d8152c 100644 --- a/packages/taroize/src/script.ts +++ b/packages/taroize/src/script.ts @@ -144,6 +144,25 @@ function parsePage ( refId?: Set ) { const stateKeys: string[] = [] + path.traverse({ + CallExpression (path) { + const callee = path.get('callee') + if (callee.isIdentifier()) { + const name = callee.node.name + if (name === 'getApp' || name === 'getCurrentPages') { + callee.replaceWith( + t.memberExpression(t.identifier('Taro'), callee.node) + ) + } + } + if (callee.isMemberExpression()) { + const object = callee.get('object') + if (object.isIdentifier({ name: 'wx' })) { + object.replaceWith(t.identifier('Taro')) + } + } + } + }) if (refId) { refId.forEach(id => { if (!stateKeys.includes(id)) {