Skip to content

Commit 3fd007e

Browse files
author
dennis.zpf
committed
fix: 修复微信兼容问题
1 parent 8bdf40d commit 3fd007e

File tree

7 files changed

+63
-26
lines changed

7 files changed

+63
-26
lines changed

copilot-demo/pages/ThoughtChain/index.axml

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<view class="navigation-bar" />
2-
2+
<!-- #if ALIPAY -->
33
<ant-container title="基础用法">
4-
<thought-chain items="{{basicList}}" onContentItemTap="onContentItemTap" collapsible="{{true}}">
5-
</thought-chain>
4+
<ant-thought-chain items="{{basicList}}" onContentTap="onContentItemTap" collapsible="{{true}}">
5+
</ant-thought-chain>
66
</ant-container>
7-
<!-- #if ALIPAY -->
7+
88
<ant-container title="自定义内容">
9-
<thought-chain items="{{basicList}}" onContentItemTap="onContentItemTap" collapsible="{{false}}">
9+
<ant-thought-chain items="{{basicList}}" onContentTap="onContentItemTap" collapsible="{{false}}">
1010
<view slot="content" slot-scope="module" style="color: red">
1111
{{module.content}}
1212
</view>
13-
</thought-chain>
13+
</ant-thought-chain>
1414
</ant-container>
1515
<ant-container title="二级节点">
16-
<thought-chain items="{{customList}}" onContentItemTap="onContentItemTap" collapsible="{{true}}">
16+
<ant-thought-chain items="{{customList}}" onContentTap="onContentItemTap" collapsible="{{true}}">
1717
<view slot="content" slot-scope="module">
1818
<view a:if="{{typeof(module.content) === 'object'}}" class="secondLevel">
1919
<thought-chain
@@ -33,6 +33,12 @@
3333
</view>
3434
<view a:else>{{module.content}}</view>
3535
</view>
36-
</thought-chain>
36+
</ant-thought-chain>
37+
</ant-container>
38+
<!-- #endif -->
39+
<!-- #if WECHAT -->
40+
<ant-container title="基础用法">
41+
<ant-thought-chain items="{{basicList}}" onContentTap="onContentItemTap" collapsible="{{true}}">
42+
</ant-thought-chain>
3743
</ant-container>
3844
<!-- #endif -->

copilot-demo/pages/ThoughtChain/index.json5

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
"usingComponents": {
1111
"ant-container": "../../../src/Container/index",
12-
"thought-chain": "../../../src/ThoughtChain/index"
12+
"ant-thought-chain": "../../../src/ThoughtChain/index"
1313
},
1414
"transparentTitle": "always"
1515
}

copilot-demo/pages/ThoughtChain/index.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Page({
66
{
77
title: '理解问题',
88
content: '3A游戏',
9-
icon: 'CheckCircleOutline'
9+
icon: 'CheckCircleOutline',
1010
},
1111
{
1212
title: '没有在本地找到结果',
1313
content: '当前主流显卡',
14-
icon: 'CheckCircleOutline'
14+
icon: 'CheckCircleOutline',
1515
},
1616
{
1717
title: '在互联网上搜索问题',
@@ -51,9 +51,13 @@ Page({
5151
],
5252
},
5353
onContentItemTap(e) {
54-
const { content } = e.target.dataset || {};
55-
my.alert({
56-
content: `点击了内容「${content}」`,
57-
});
54+
const { content } = e.currentTarget.dataset || {};
55+
/// #if ALIPAY
56+
my.showToast({ content: content });
57+
/// #endif
58+
/// #if WECHAT
59+
// @ts-ignore
60+
wx.showToast({ title: content });
61+
/// #endif
5862
},
5963
});

copilot/ThoughtChain/index.axml

+23-1
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,37 @@
1616
</view>
1717
</view>
1818
</view>
19+
<!-- #if ALIPAY -->
1920
<view
2021
a:if="{{utils.isExpand(collapsible, item.key || index, foldStatusMap)}}"
2122
class="ant-copilot-thoughtchain-node-content"
2223
>
2324
<slot name="content" content="{{item.content}}" item="{{item}}">
24-
<view class="ant-copilot-thoughtchain-node-content-text" onTap="onContentItemTap" data-key="{{item.key || index}}" data-content="{{item.content}}">
25+
<view
26+
class="ant-copilot-thoughtchain-node-content-text"
27+
onTap="onContentTap"
28+
data-key="{{item.key || index}}"
29+
data-content="{{item.content}}"
30+
>
2531
<view>{{item.content}}</view>
2632
</view>
2733
</slot>
2834
</view>
35+
<!-- #endif -->
36+
<!-- #if WECHAT -->
37+
<view
38+
a:if="{{utils.isExpand(collapsible, item.key || index, foldStatusMap)}}"
39+
class="ant-copilot-thoughtchain-node-content"
40+
>
41+
<view
42+
class="ant-copilot-thoughtchain-node-content-text"
43+
onTap="onContentTap"
44+
data-key="{{item.key || index}}"
45+
data-content="{{item.content}}"
46+
>
47+
<view>{{item.content}}</view>
48+
</view>
49+
</view>
50+
<!-- #endif -->
2951
</view>
3052
</view>

copilot/ThoughtChain/index.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
import { Component, triggerEvent } from '../../src/_util/simply';
1+
import {
2+
Component,
3+
getValueFromProps,
4+
triggerEventValues,
5+
} from '../../src/_util/simply';
26
import { ThoughtChainProps } from './props';
37

48
Component(
59
ThoughtChainProps,
610
// methods
711
{
8-
onContentItemTap(e) {
9-
if (this.props.onContentItemTap) {
10-
triggerEvent(this, 'contentItemTap', e, e);
11-
}
12+
onContentTap(e) {
13+
triggerEventValues(this, 'contentTap', [e], e);
1214
},
1315
onTitleTap(e) {
14-
if (!this.props.collapsible) return;
16+
const [collapsible, onExpand] = getValueFromProps(this, ['collapsible', 'onExpand']);
17+
if (!collapsible) return;
1518
// 受控模式
16-
if (this.props.onExpand && this.props.collapsible?.expandedKeys) {
17-
const { collapsible } = this.props;
19+
if (onExpand && collapsible?.expandedKeys) {
1820
const { expandedKeys } = collapsible;
1921
const { key } = e.currentTarget.dataset;
2022
const isExpandNow = expandedKeys.includes(key);
@@ -24,7 +26,7 @@ Component(
2426
} else {
2527
newExpandedKeys.push(key);
2628
}
27-
triggerEvent(this, 'expand', newExpandedKeys, key);
29+
triggerEventValues(this, 'expand', [newExpandedKeys, key]);
2830
} else {
2931
const { key } = e.currentTarget.dataset;
3032
const foldStatusMap = { ...this.data.foldStatusMap };

copilot/ThoughtChain/props.ts

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export interface IThoughtChainProps extends IBaseProps {
5757
style?: string;
5858

5959
onExpand?: (expandedKeys: string[], currentExpandeKey: string) => void;
60+
/** 内容点击事件 */
61+
onContentTap?: (e) => void;
6062
}
6163

6264
export const ThoughtChainProps: Partial<IThoughtChainProps> = {
@@ -65,4 +67,5 @@ export const ThoughtChainProps: Partial<IThoughtChainProps> = {
6567
collapsible: true,
6668
style: '',
6769
onExpand: () => {},
70+
onContentTap: () => {},
6871
};

scripts/axml/mapping.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export const wechatCustomMapping = {
207207
},
208208
'ant-thought-chain': {
209209
onExpand: 'bindexpand',
210-
onContentItemTap: 'bindcontentitemtap'
210+
onContentTap: 'bindcontenttap'
211211
},
212212
'ant-actions': {
213213
onItemTap: 'binditemtap',

0 commit comments

Comments
 (0)