Skip to content

Commit

Permalink
feat: dev copilot conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
rayhomie committed Jan 22, 2025
1 parent 95e6b44 commit 12d94f9
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 12 deletions.
5 changes: 4 additions & 1 deletion copilot-demo/pages/Conversations/index.axml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<view class="navigation-bar"/>

<ant-container title="基础用法">
<ant-conversations />
<ant-conversations
items="{{items}}"
menus="{{menus}}"
/>
</ant-container>
3 changes: 0 additions & 3 deletions copilot-demo/pages/Conversations/index.less
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
page {
padding: 12rpx;
}
36 changes: 35 additions & 1 deletion copilot-demo/pages/Conversations/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
Page({
data: {},
data: {
items: [
{
key: '1',
label: '给我推荐一首歌',
description: '这是会话的部分富文本信息描述',
icon: '',
timestamp: '10:23',
disabled: false,
},
{
key: '2',
label: '请根据图片里的提示,写一篇小学二年级的数学题目',
description:
'这首歌来自英国歌手艾德·希兰旋律轻快,歌曲写自上个世纪落日',
icon: '',
timestamp: '10:23',
disabled: true,
},
],
menus: [
{
text: '编辑',
bgColor: '#FFA91B',
color: '#fff',
width: 160,
},
{
text: '删除',
bgColor: '#FF2B00',
color: '#fff',
width: 160,
},
],
},
onItemTap(i) {
let item = i;
/// #if ALIPAY
Expand Down
19 changes: 18 additions & 1 deletion copilot/Conversations/index.axml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
<view class="ant-copilot-conversations {{ className }}" style="{{ style }}">

<block
a:for="{{ items }}"
a:for-index="index"
a:for-item="item"
a:key="key">
<view class="t-swipe-item-con">
<ant-swipe-action
data-item="{{ item }}"
rightButtons="{{ menus }}"
elasticity="{{ true }}"
onButtonTap="onButtonTap"
>
<slot>
<view class="t-swipe-item-con-view">{{item.label}}</view>
</slot>
</ant-swipe-action>
</view>
</block>

</view>
4 changes: 3 additions & 1 deletion copilot/Conversations/index.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"component": true,
"usingComponents": {}
"usingComponents": {
"ant-swipe-action": "../../src/SwipeAction/index"
}
}
29 changes: 29 additions & 0 deletions copilot/Conversations/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,32 @@

.@{buttonPrefix} {
}

.t-swipe {
&-item {
&-con {
height: 130 * @rpx;
line-height: 130 * @rpx;
width: 100%;
&-view {
background-color: var(--color-card);
text-indent: 1em;
position: relative;
height: 100%;
color: var(--color-text-primary);
&::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 1px;
max-height: 1px;
min-height: 1px;
transform: scaleY(0.5);
background-color: var(--color-border);
}
}
}
}
}
4 changes: 2 additions & 2 deletions copilot/Conversations/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, triggerEventValues } from '../../src/_util/simply';
import { PromptsProps } from './props';
import { ConversationsProps } from './props';

Component(PromptsProps, {
Component(ConversationsProps, {
onItemTap(e) {
const { item, index } = e.currentTarget.dataset;
triggerEventValues(this, 'itemTap', [item, index], e);
Expand Down
6 changes: 3 additions & 3 deletions copilot/Conversations/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface IPromptsProps extends IBaseProps {
* @description 会话操作菜单
* @default []
*/
menu?: MenuItem[];
menus?: MenuItem[];

/**
* @description 点击会话项之后的回调
Expand All @@ -68,10 +68,10 @@ export interface IPromptsProps extends IBaseProps {
onMenuItemTap?: (item: MenuItem, index: number) => void;
}

export const PromptsProps: Partial<IPromptsProps> = {
export const ConversationsProps: Partial<IPromptsProps> = {
className: '',
style: '',
items: [],
menu: [],
menus: [],
onItemTap() {},
};

0 comments on commit 12d94f9

Please sign in to comment.