Skip to content

Commit 3987495

Browse files
committed
fix: add demos
1 parent 187331b commit 3987495

File tree

9 files changed

+85
-10
lines changed

9 files changed

+85
-10
lines changed

copilot-demo/pages/Bubble/index.axml

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@
3939
<ant-bubble content="variant: shadow" variant="shadow" />
4040
</ant-container>
4141

42-
<ant-container title="用户名">
42+
<ant-container title="用户名和操作">
4343
<ant-bubble content="你好,请问有什么可以帮你?" avatar="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ">
4444
<view slot="header">
4545
<text class="ant-copilot-bubble-name">Ant Design Mini</text>
4646
</view>
47+
<view slot="footer">
48+
<ant-actions items="{{basicActions}}" onItemTap="handleTapAction" />
49+
</view>
4750
</ant-bubble>
4851
</ant-container>
4952

copilot-demo/pages/Bubble/index.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"usingComponents": {
33
"ant-bubble": "../../../src/Bubble/index",
4+
"ant-actions": "../../../src/Actions/index",
45
"ant-container": "../../../src/Container/index",
56
"ant-switch": "../../../src/Switch/index"
67
}

copilot-demo/pages/Bubble/index.ts

+27
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ Page({
22
data: {
33
loading: true,
44
showTyping: true,
5+
basicActions: [
6+
{
7+
label: 'copy',
8+
icon: 'TextOutline',
9+
},
10+
{
11+
label: 'like',
12+
icon: 'LikeOutline',
13+
},
14+
],
515
},
616
onTypingComplete() {
717
console.log('typing complete at', Date.now());
@@ -16,4 +26,21 @@ Page({
1626
loading: !this.data.loading,
1727
});
1828
},
29+
handleTapAction(item) {
30+
/// #if WECHAT
31+
// @ts-ignore
32+
item = item.detail;
33+
/// #endif
34+
/// #if ALIPAY
35+
my.showToast({
36+
content: `${item.label} tapped`,
37+
});
38+
/// #endif
39+
/// #if WECHAT
40+
// @ts-ignore
41+
wx.showToast({
42+
title: `${item.label} tapped`,
43+
});
44+
/// #endif
45+
},
1946
});

copilot-demo/pages/Sender/index.axml

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
onChange="handleChange4"
5050
onSubmit="handleSend4"
5151
>
52+
<ant-prompts
53+
slot="header"
54+
list="{{horizontalList}}"
55+
vertical="{{false}}"
56+
onItemTap="onItemTap"
57+
></ant-prompts>
5258
</ant-sender>
5359
</ant-container>
5460
</view>

copilot-demo/pages/Sender/index.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"usingComponents": {
33
"ant-sender": "../../../src/Sender/index",
44
"ant-upload": "../../../src/ImageUpload/index",
5+
"ant-prompts": "../../../src/Prompts/index",
56
"ant-bubble": "../../../src/Bubble/index",
67
"ant-container": "../../../src/Container/index"
78
}

copilot-demo/pages/Sender/index.ts

+42-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const mockResponse = [
44
'这是个很好的问题,我来仔细想想...',
55
'我明白你的想法,确实值得深入讨论。',
66
'感谢分享,这让我想到了一些新的观点。',
7-
'你提到的这点很有启发性,我们可以进一步探讨。'
8-
]
7+
'你提到的这点很有启发性,我们可以进一步探讨。',
8+
];
99
Page({
1010
senderTimer: null,
1111
data: {
@@ -15,8 +15,33 @@ Page({
1515
value4: '',
1616
loading: false,
1717
scrollToView: '',
18-
bubbleList: [
19-
{ content: '你好,世界!'}
18+
bubbleList: [{ content: '你好,世界!' }],
19+
horizontalList: [
20+
{
21+
icon: 'https://mdn.alipayobjects.com/huamei_2jrq4g/afts/img/A*AdC9RZfDwicAAAAAAAAAAAAADtF8AQ/original',
22+
label: '我的日程',
23+
value: 'schedule',
24+
key: '1',
25+
},
26+
{
27+
icon: 'https://mdn.alipayobjects.com/huamei_2jrq4g/afts/img/A*Mbi1R5eGTecAAAAAAAAAAAAADtF8AQ/original',
28+
label: '快捷功能',
29+
value: 'suggestion',
30+
key: '2',
31+
},
32+
{
33+
icon: 'https://mdn.alipayobjects.com/huamei_2jrq4g/afts/img/A*WqBJSZEpPbwAAAAAAAAAAAAADtF8AQ/original',
34+
label: '诊断分析',
35+
value: 'analyze',
36+
key: '3',
37+
},
38+
{
39+
// 支持 antd-icon
40+
icon: 'MoreOutline',
41+
label: '更多',
42+
value: 'more',
43+
key: '4',
44+
},
2045
],
2146
},
2247
/** 基础用法 */
@@ -74,12 +99,21 @@ Page({
7499
/// #endif
75100
this.setData({ value4: value });
76101
},
77-
handleSend4() {
78-
if (!this.data.value4) return;
79-
this.addBubble(this.data.value4);
102+
onItemTap(e) {
103+
/// #if WECHAT
104+
// @ts-ignore
105+
e = e.detail;
106+
/// #endif
107+
this.handleSend4(e.label)
108+
},
109+
handleSend4(val: string) {
110+
if (!this.data.value4 && !val) return;
111+
this.addBubble(val || this.data.value4);
80112
this.setData({ value4: '' });
81113
setTimeout(() => {
82-
this.addBubble(mockResponse[Math.floor(Math.random() * mockResponse.length)]);
114+
this.addBubble(
115+
mockResponse[Math.floor(Math.random() * mockResponse.length)]
116+
);
83117
}, 500);
84118
},
85119
});

copilot/Actions/check.sjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/// #if ALIPAY
2-
export function checkIcon(icon = '') {
2+
function checkIcon(icon = '') {
33
return getRegExp('^[a-zA-Z]+$').test(icon);
44
}
5+
export default { checkIcon };
56
/// #endif
67
/// #if WECHAT
78
function checkIcon(icon = '') {

copilot/Bubble/index.en.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ When you need to display the content of the dialogue, it supports a variety of b
4242
| --- | --- |
4343
| default | Custom bubble content |
4444
| header | Custom header content (such as user name) |
45+
| footer | Custom footer content (such as custom operations) |
4546

4647
### Theme customization
4748

copilot/Bubble/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ toc: 'content'
4242
| --- | --- |
4343
| default | 自定义气泡内容 |
4444
| header | 自定义头部内容(如用户名) |
45+
| footer | 自定义底部内容(如自定义操作等) |
4546

4647
### 主题定制
4748

0 commit comments

Comments
 (0)