Skip to content

Commit

Permalink
feat(taroize): 在类中调用 微信钩子函数转换为相应地 Taro 钩子函数
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Dec 5, 2018
1 parent 717f7b2 commit e4d9e67
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/taroize/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib
t.js
*.wxml
s.js
2 changes: 1 addition & 1 deletion packages/taroize/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ specialEvents.set('bindanimationstart', 'onAnimationStart')
specialEvents.set('bindanimationtteration', 'onAnimationIteration')
specialEvents.set('bindanimationend', 'onAnimationEnd')
specialEvents.set('bindtouchforcechange', 'onTouchForceChange')
specialEvents.set('bindtap', 'onTouchForceChange')
specialEvents.set('bindtap', 'onClick')
specialEvents.forEach((value, key) => {
specialEvents.set(key.replace(/^bind/, 'catch'), value)
})
9 changes: 7 additions & 2 deletions packages/taroize/src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,13 @@ function parsePage (
}
if (callee.isMemberExpression()) {
const object = callee.get('object')
if (object.isIdentifier({ name: 'wx' })) {
object.replaceWith(t.identifier('Taro'))
if (object.isIdentifier()) {
const methodName = object.node.name
if (PageLifecycle.has(methodName)) {
object.replaceWith(t.identifier(PageLifecycle.get(methodName)!))
} else if (methodName === 'wx') {
object.replaceWith(t.identifier('Taro'))
}
}
}
},
Expand Down

0 comments on commit e4d9e67

Please sign in to comment.