Skip to content

Commit 1ce04c8

Browse files
authored
Copilot suggestion dev (#1356)
* feat: copilot suggestion dev * feat: copilot suggestion dev * feat: copilot prompts dev * feat: copilot prompts dev
1 parent 08d59f1 commit 1ce04c8

File tree

20 files changed

+175
-131
lines changed

20 files changed

+175
-131
lines changed

copilot-demo/pages/Prompts/index.axml

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
onTapPromptsItem="onTapPromptsItem" />
2323
</ant-container>
2424

25+
<!-- #if ALIPAY -->
2526
<ant-container title="自定义提示标题">
2627
<ant-prompts
2728
list="{{ arrowList }}"
@@ -41,4 +42,4 @@
4142
</view>
4243
</ant-prompts>
4344
</ant-container>
44-
45+
<!-- #endif -->

copilot-demo/pages/Prompts/index.less

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
page {
2-
// background: #f5f5f5;
32
padding: 12rpx;
43
}
54

65
.customizeStyle {
76
.ant-copilot-prompts-list-item-content {
87
font-family: PingFangSC-Light;
98
font-size: 28rpx;
10-
color: rgba(0,0,0,0.45);
9+
color: #bbbbbb;
1110
line-height: 44rpx;
1211
}
1312
}
@@ -25,4 +24,4 @@ page {
2524
padding: 24rpx;
2625
background: #aaaaaa;
2726
border-radius: 16rpx;
28-
}
27+
}

copilot-demo/pages/Prompts/index.ts

+36-21
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,80 @@
1-
//@ts-ignore
2-
31
Page({
42
data: {
53
promptsTitle: '我可以帮您:',
64
baseList: [
75
{
8-
title: 'Ant Design X 全新升级了什么?'
6+
title: 'Ant Design X 全新升级了什么?',
97
},
108
{
11-
title: 'Ant Design X 组件资产内容'
9+
title: 'Ant Design X 组件资产内容',
1210
},
1311
{
14-
title: '快速实现安装和引入组件'
15-
}
12+
title: '快速实现安装和引入组件',
13+
},
1614
],
1715
arrowList: [
1816
{
1917
showArrow: true,
2018
title: '热门话题:',
21-
image: 'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*wJ5aRpr2q1wAAAAAAAAAAAAADkx8AQ/original',
19+
image:
20+
'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*wJ5aRpr2q1wAAAAAAAAAAAAADkx8AQ/original',
2221
content: 'Ant Design X 全新升级',
2322
},
2423
{
2524
showArrow: true,
2625
title: '组件查询:',
27-
image: 'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*R9L1RLo4x58AAAAAAAAAAAAADkx8AQ/original',
28-
content: '欢迎组件'
26+
image:
27+
'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*R9L1RLo4x58AAAAAAAAAAAAADkx8AQ/original',
28+
content: '欢迎组件',
2929
},
3030
{
3131
showArrow: true,
3232
title: '新手帮助:',
33-
image: 'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*7eRqQ4JpdccAAAAAAAAAAAAADkx8AQ/original',
34-
content: '如何实现快速安装和引入'
35-
}
33+
image:
34+
'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*7eRqQ4JpdccAAAAAAAAAAAAADkx8AQ/original',
35+
content: '如何实现快速安装和引入',
36+
},
3637
],
3738
styleList: [
3839
{
3940
title: '我的日程',
40-
image: 'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*LzX3QIQ3EXMAAAAAAAAAAAAADkx8AQ/original',
41+
image:
42+
'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*LzX3QIQ3EXMAAAAAAAAAAAAADkx8AQ/original',
4143
content: '每日日程提醒,不错过每一个日程',
4244
},
4345
{
4446
title: '组件查询',
45-
image: 'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*2TQ2QaONoRYAAAAAAAAAAAAADkx8AQ/original',
46-
content: '每日审批提醒,不漏信息'
47+
image:
48+
'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*2TQ2QaONoRYAAAAAAAAAAAAADkx8AQ/original',
49+
content: '每日审批提醒,不漏信息',
4750
},
4851
{
4952
title: '会议邀约',
50-
image: 'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*Fw-tQIDYFvsAAAAAAAAAAAAADkx8AQ/original',
51-
content: '实时会邀提醒,不错过重要会议'
53+
image:
54+
'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*Fw-tQIDYFvsAAAAAAAAAAAAADkx8AQ/original',
55+
content: '实时会邀提醒,不错过重要会议',
5256
},
5357
{
5458
title: '更多',
55-
image: 'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*YDWcQbavX8QAAAAAAAAAAAAADkx8AQ/original',
56-
content: '点击了解更多技能'
57-
}
59+
image:
60+
'https://mdn.alipayobjects.com/huamei_upibrs/afts/img/A*YDWcQbavX8QAAAAAAAAAAAAADkx8AQ/original',
61+
content: '点击了解更多技能',
62+
},
5863
],
5964
},
60-
onTapPromptsItem(item) {
65+
onTapPromptsItem(i) {
66+
let item = i;
67+
/// #if ALIPAY
68+
console.log(item);
6169
my.alert({
6270
content: `点击了 ${item.title || ''} ${item.content || ''}`,
6371
});
72+
/// #endif
73+
/// #if WECHAT
74+
item = i.detail;
75+
console.log(item);
76+
// @ts-ignore
77+
wx.showToast({ title: `点击了 ${item.title || ''} ${item.content || ''}` });
78+
/// #endif
6479
},
6580
});

copilot-demo/pages/Suggestion/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@ Page({
4545
},
4646
],
4747
},
48-
handleSelect(item) {
48+
handleSelect(i) {
49+
let item = i;
4950
/// #if ALIPAY
5051
console.log(item);
5152
my.showToast({ content: item.value });
5253
/// #endif
54+
/// #if WECHAT
55+
item = i.detail[0];
56+
console.log(item);
57+
// @ts-ignore
58+
wx.showToast({ title: item.value });
59+
/// #endif
5360
},
5461
});

copilot-demo/pages/index/index.axml

-1
This file was deleted.

copilot-demo/pages/index/index.json5

-14
This file was deleted.

copilot-demo/pages/index/index.less

Whitespace-only changes.

copilot-demo/pages/index/index.ts

-5
This file was deleted.

copilot/Prompts/index.axml

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
<view class="ant-copilot-prompts {{ className }}">
2+
<!-- #if ALIPAY -->
23
<slot name="prompts-title">
4+
<!-- #endif -->
35
<view a:if="{{ promptsTitle }}" class="ant-copilot-prompts-title">
46
{{ promptsTitle }}
57
</view>
8+
<!-- #if ALIPAY -->
69
</slot>
10+
<!-- #endif -->
711
<view class="ant-copilot-prompts-list">
812
<block a:for="{{ list }}">
13+
<!-- #if ALIPAY -->
914
<slot name="prompts-item" item="{{ item }}">
15+
<!-- #endif -->
1016
<view class="ant-copilot-prompts-list-item" data-item="{{ item }}" onTap="onTapPromptsItem">
11-
<image
17+
<image
1218
mode="scaleToFill"
13-
a:if="{{ item.image }}"
14-
src="{{ item.image }}"
19+
a:if="{{ item.image }}"
20+
src="{{ item.image }}"
1521
class="ant-copilot-prompts-list-item-image" />
1622
<text a:if="{{ item.title }}" class="ant-copilot-prompts-list-item-title">{{ item.title }}</text>
1723
<text a:if="{{ item.content }}" class="ant-copilot-prompts-list-item-content">{{ item.content }}</text>
1824
<ant-icon a:if="{{ item.showArrow }}" type="RightOutline" class="ant-copilot-prompts-list-item-arrow" />
1925
</view>
26+
<!-- #if ALIPAY -->
2027
</slot>
28+
<!-- #endif -->
2129
</block>
2230
</view>
23-
</view>
31+
</view>

copilot/Prompts/index.md

+45-38
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ toc: 'content'
3232

3333
```xml
3434
<ant-prompts
35-
list="{{ baseList }}"
36-
promptsTitle="{{ promptsTitle }}"
37-
onTapPromptsItem="onTapPromptsItem" />
35+
list="{{baseList}}"
36+
promptsTitle="{{promptsTitle}}"
37+
#if ALIPAY
38+
onTapPromptsItem="onTapPromptsItem"
39+
#endif
40+
#if WECHAT
41+
bindtappromptsitem="onTapPromptsItem"
42+
#endif
43+
/>
3844
```
3945

4046
```js
@@ -54,9 +60,16 @@ Page({
5460
],
5561
},
5662
onTapPromptsItem(item) {
63+
let item = i;
64+
#if ALIPAY
5765
my.alert({
5866
content: `点击了 ${item.title || ''} ${item.content || ''}`,
5967
});
68+
#endif
69+
#if WECHAT
70+
item = i.detail;
71+
wx.showToast({ title: `点击了 ${item.title || ''} ${item.content || ''}` });
72+
#endif
6073
},
6174
});
6275
```
@@ -65,9 +78,9 @@ Page({
6578

6679
```xml
6780
<ant-prompts
68-
list="{{ arrowList }}"
69-
promptsTitle="{{ promptsTitle }}"
70-
onTapPromptsItem="onTapPromptsItem" />
81+
list="{{ arrowList }}"
82+
promptsTitle="{{ promptsTitle }}"
83+
/>
7184
```
7285

7386
```js
@@ -98,11 +111,6 @@ Page({
98111
},
99112
],
100113
},
101-
onTapPromptsItem(item) {
102-
my.alert({
103-
content: `点击了 ${item.title || ''} ${item.content || ''}`,
104-
});
105-
},
106114
});
107115
```
108116

@@ -113,7 +121,7 @@ Page({
113121
list="{{ styleList }}"
114122
className="customizeStyle"
115123
promptsTitle="{{ promptsTitle }}"
116-
onTapPromptsItem="onTapPromptsItem" />
124+
/>
117125
```
118126

119127
```css
@@ -128,21 +136,17 @@ Page({
128136
### 自定义提示标题
129137

130138
```xml
131-
<ant-prompts
132-
list="{{ arrowList }}"
133-
onTapPromptsItem="onTapPromptsItem">
134-
<view slot="prompts-title" class="customize-prompts-title">
135-
自定义提示标题:
136-
</view>
137-
</ant-prompts>
139+
<ant-prompts list="{{ arrowList }}">
140+
<view slot="prompts-title" class="customize-prompts-title">
141+
自定义提示标题:
142+
</view>
143+
</ant-prompts>
138144
```
139145

140146
### 自定义提示项
141147

142148
```xml
143-
<ant-prompts
144-
list="{{ baseList }}"
145-
onTapPromptsItem="onTapPromptsItem">
149+
<ant-prompts list="{{ baseList }}">
146150
<view slot="prompts-item" slot-scope="props" class="customize-prompts-item">
147151
自定义提示项:{{ props.item.title }}
148152
</view>
@@ -159,23 +163,26 @@ Page({
159163

160164
以下表格介绍了 Prompts 组件的 API 属性:
161165

162-
| 属性 | 说明 | 类型 | 默认值 |
163-
| ------------ | -------- | -------------- | ------ |
164-
| promptsTitle | 提示标题 | string | - |
165-
| className | 类名 | string | - |
166-
| list | 提示列表 | IPromptsItem[] | - |
166+
| 属性 | 说明 | 类型 | 默认值 |
167+
| ----------------------------- | ------------ | -------------------------------------------- | ------ |
168+
| promptsTitle | 提示标题 | string | - |
169+
| className | 类名 | string | - |
170+
| list | 提示列表 | [PromptsItem](#promptsitem)[] | - |
171+
| #if ALIPAY onTapPromptsItem | 提示点击回调 | (item: [PromptsItem](#promptsitem)) => void; | - |
172+
| #if WECHAT bindtappromptsitem | 提示点击回调 | (item: [PromptsItem](#promptsitem)) => void; | - |
173+
174+
### PromptsItem 属性
167175

168-
IPromptsItem 属性
169-
| 属性 | 说明 | 类型 | 默认值 |
170-
| --------------------------- | --------------------------------------------------------------- | ----------------------------------------------------------------------------- | --------- |
171-
| image | 提示项的图片 | string | - |
172-
| title |提示项标题 | string | - |
173-
| content | 提示内容 | string
174-
| showArrow | 是否展示箭头 | boolean
176+
| 属性 | 说明 | 类型 | 默认值 |
177+
| --------- | ------------ | ------- | ------ |
178+
| image | 提示项的图片 | string | - |
179+
| title | 提示项标题 | string | - |
180+
| content | 提示内容 | string | - |
181+
| showArrow | 是否展示箭头 | boolean | - |
175182

176-
插槽 slot
183+
### 插槽 slot
177184

178185
| 插槽名称 | 说明 |
179-
| ------------- | -------------- | --- |
180-
| prompts-title | 提示项的标题题 | |
181-
| prompts-item | 提示子项项 | |
186+
| ------------- | -------------- |
187+
| prompts-title | 提示项的标题题 |
188+
| prompts-item | 提示子项项 |

copilot/Prompts/index.ts

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1+
import { Component, triggerEvent } from '../../src/_util/simply';
12
import { PromptsProps } from './props';
2-
import { Component } from '../../src/_util/simply';
33

44
Component(
55
PromptsProps,
6-
// methods
76
{
87
onTapPromptsItem(e) {
9-
if (this.props.onTapPromptsItem) {
10-
const { item } = e.target.dataset || {};
11-
this.props.onTapPromptsItem(item);
12-
}
8+
const { item } = e.currentTarget.dataset;
9+
triggerEvent(this, 'tapPromptsItem', item, e);
1310
},
14-
},
15-
// data
16-
{
17-
},
18-
// mixins
19-
undefined,
20-
// 生命周期方法
21-
{
2211
}
2312
);

0 commit comments

Comments
 (0)