Skip to content

Commit

Permalink
chore: 修改函数名,解藕支付宝事件
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Aug 19, 2020
1 parent c16e433 commit eee6411
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
8 changes: 0 additions & 8 deletions packages/shared/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ const touchEvents = {
bindLongTap: ''
}

export const alipayEvents = {
onTap: 'eh',
onTouchMove: 'eh',
onTouchEnd: 'eh',
onTouchCancel: 'eh',
onLongTap: 'eh'
}

export const specialEvents = new Set([
'htouchmove',
'vtouchmove'
Expand Down
12 changes: 6 additions & 6 deletions packages/shared/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export class BaseTemplate {
protected supportXS = false
protected miniComponents: Components
protected modifyCompProps?: (compName: string, target: Record<string, string>) => Record<string, string>
protected modifyTemplateChild?: (child: string, nodeName: string) => string
protected modifyTemplateChildren?: (children: string, nodeName: string) => string
protected modifyLoopBody?: (child: string, nodeName: string) => string
protected modifyLoopContainer?: (children: string, nodeName: string) => string
protected modifyTemplateResult?: (res: string, nodeName: string, level: number, children: string) => string

public Adapter = weixinAdapter
Expand Down Expand Up @@ -214,8 +214,8 @@ export class BaseTemplate {

let child = `<template is="tmpl_${nextLevel}_${Shortcuts.Container}" data="{{${this.dataKeymap('i: item')}}}" />`

if (isFunction(this.modifyTemplateChild)) {
child = this.modifyTemplateChild(child, comp.nodeName)
if (isFunction(this.modifyLoopBody)) {
child = this.modifyLoopBody(child, comp.nodeName)
}

let children = voidElements.has(comp.nodeName)
Expand All @@ -226,8 +226,8 @@ export class BaseTemplate {
</block>
`

if (isFunction(this.modifyTemplateChildren)) {
children = this.modifyTemplateChildren(children, comp.nodeName)
if (isFunction(this.modifyLoopContainer)) {
children = this.modifyLoopContainer(children, comp.nodeName)
}

const nodeName = comp.nodeName === 'slot' || comp.nodeName === 'slot-view' ? 'view' : comp.nodeName
Expand Down
14 changes: 10 additions & 4 deletions packages/taro-cli/src/presets/platforms/alipay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IPluginContext } from '@tarojs/service'
import { RecursiveTemplate, alipayEvents, capitalize, toCamelCase } from '@tarojs/shared'
import { RecursiveTemplate, capitalize, toCamelCase } from '@tarojs/shared'
import { recursiveReplaceObjectKeys, printDevelopmentTip } from '../../util'

export class Template extends RecursiveTemplate {
Expand Down Expand Up @@ -27,7 +27,13 @@ export class Template extends RecursiveTemplate {
}

getEvents () {
return alipayEvents
return {
onTap: 'eh',
onTouchMove: 'eh',
onTouchEnd: 'eh',
onTouchCancel: 'eh',
onLongTap: 'eh'
}
}

buildThirdPartyAttr (attrs: Set<string>) {
Expand Down Expand Up @@ -55,7 +61,7 @@ export class Template extends RecursiveTemplate {
return target
}

modifyTemplateChild = (child: string, nodeName: string) => {
modifyLoopBody = (child: string, nodeName: string) => {
if (nodeName === 'picker-view') {
return `<picker-view-column>
<view a:for="{{item.cn}}" a:key="id">
Expand All @@ -73,7 +79,7 @@ export class Template extends RecursiveTemplate {
return child
}

modifyTemplateChildren = (children: string, nodeName: string) => {
modifyLoopContainer = (children: string, nodeName: string) => {
if (nodeName === 'picker') {
return `
<view>${children}</view>
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli/src/presets/platforms/swan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Template extends RecursiveTemplate {
return `{ ${value} }`
}

modifyTemplateChild = (child: string, nodeName: string) => {
modifyLoopBody = (child: string, nodeName: string) => {
if (nodeName === 'text') {
return `<block>{{ i.${Shortcuts.Childnodes}[index].${Shortcuts.Text} }}</block>`
}
Expand Down

0 comments on commit eee6411

Please sign in to comment.