Skip to content

Commit 65f2b85

Browse files
author
dennis.zpf
committed
fix: 文档翻译
2 parents 59c6191 + 233a610 commit 65f2b85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1725
-298
lines changed

copilot-demo/pages/Actions/index.axml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<ant-container title="基础用法">
2+
<ant-actions
3+
items="{{basicActions}}"
4+
onItemTap="handleTapAction"
5+
/>
6+
</ant-container>
7+
8+
<ant-container title="配合bubble使用">
9+
<ant-switch checked="{{ showBubble }}" onChange="toggleBubble" />
10+
<ant-bubble a:if="{{ showBubble }}" content="永和九年,岁在癸丑,暮春之初,会于会稽山阴之兰亭,修禊事也。群贤毕至,少长咸集。此地有崇山峻岭,茂林修竹,又有清流激湍,映带左右,引以为流觞曲水,列坐其次。虽无丝竹管弦之盛,一觞一咏,亦足以畅叙幽情。" typing="{{ { step: 2, interval: 50 } }}" onTypingComplete="onTypingComplete">
11+
<ant-actions a:if="{{ loaded }}" slot="footer" items="{{bubbleActions}}" onItemTap="handleBubbleAction" />
12+
</ant-bubble>
13+
</ant-container>
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
/// #if WECHAT
3+
"navigationBarTitleText": "Actions",
4+
/// #endif
5+
6+
/// #if ALIPAY
7+
"defaultTitle": "Actions",
8+
/// #endif
9+
10+
"usingComponents": {
11+
"ant-actions": "../../../src/Actions/index",
12+
"ant-bubble": "../../../src/Bubble/index",
13+
"ant-switch": "../../../src/Switch/index",
14+
"ant-container": "../../../src/Container/index"
15+
}
16+
}

copilot-demo/pages/Actions/index.less

Whitespace-only changes.

copilot-demo/pages/Actions/index.ts

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Page({
2+
data: {
3+
liked: false,
4+
loaded: false,
5+
showBubble: true,
6+
basicActions: [
7+
{
8+
label: 'copy',
9+
icon: 'TextOutline',
10+
},
11+
{
12+
label: 'like',
13+
icon: 'LikeOutline',
14+
},
15+
{
16+
label: 'collect',
17+
icon: 'StarOutline',
18+
},
19+
{
20+
label: 'edit',
21+
icon: 'EditSOutline',
22+
},
23+
],
24+
bubbleActions: [
25+
{
26+
label: 'copy',
27+
icon: 'TextOutline',
28+
},
29+
{
30+
label: 'collect',
31+
icon: 'StarOutline',
32+
},
33+
],
34+
},
35+
36+
handleTapAction(item) {
37+
const basicActions = [...this.data.basicActions];
38+
if (item.label === 'like') {
39+
this.setData({
40+
liked: !this.data.liked,
41+
});
42+
basicActions.find((action) => action.label === 'like').icon = this.data.liked
43+
? 'https://mdn.alipayobjects.com/huamei_bsws4g/afts/img/JmVoRp-2UwMAAAAAAAAAAAAADoEQAQFr/original'
44+
: 'LikeOutline';
45+
} else {
46+
my.showToast({
47+
content: `${item.label} tapped`,
48+
});
49+
}
50+
this.setData({
51+
basicActions,
52+
});
53+
},
54+
handleBubbleAction(item) {
55+
my.showToast({
56+
content: `${item.label} tapped`,
57+
});
58+
},
59+
onTypingComplete() {
60+
this.setData({
61+
loaded: true,
62+
});
63+
},
64+
toggleBubble() {
65+
this.setData({
66+
showBubble: !this.data.showBubble,
67+
loaded: false,
68+
});
69+
},
70+
});

copilot-demo/pages/Bubble/index.axml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<view class="navigation-bar" />
2+
3+
<ant-container title="基础用法">
4+
<ant-bubble content="这是一条普通消息" avatar="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ" />
5+
</ant-container>
6+
7+
<ant-container title="打字动画">
8+
<ant-switch checked="{{ showTyping }}" onChange="onTypingChange" />
9+
<block a:if="{{ showTyping }}">
10+
<ant-bubble content="你好,这是一段打字效果动画" typing="{{true}}" onTypingComplete="onTypingComplete" />
11+
<ant-bubble content="你好,这是一段快速的打字效果动画" typing="{{{ step: 1, interval: 50 }}}" onTypingComplete="onTypingComplete" />
12+
<ant-bubble content="这是一段很长的文本消息,用于测试打字效果动画。该条消息会一次打印多个字符" typing="{{{ step: 3, interval: 100 }}}" onTypingComplete="onTypingComplete" />
13+
</block>
14+
</ant-container>
15+
<ant-container title="用户消息">
16+
<ant-bubble content="这是用户发送的消息" placement="end" avatar="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ" />
17+
</ant-container>
18+
19+
<ant-container title="长文本">
20+
<ant-bubble
21+
content="这是一段很长的文本消息,用于测试气泡的自动换行效果。气泡会根据内容自动调整宽度,这样可以保证良好的阅读体验。"
22+
avatar="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ"
23+
/>
24+
</ant-container>
25+
26+
<ant-container title="对话场景">
27+
<ant-bubble content="你好,请问有什么可以帮你?" avatar="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ" />
28+
<ant-bubble content="我想了解一下这个产品的功能" placement="end" avatar="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ" />
29+
<ant-bubble content="好的,这个产品主要有以下功能..." avatar="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ" />
30+
</ant-container>
31+
32+
<!-- 各种形状 -->
33+
<ant-container title="各种形状">
34+
<ant-bubble content="shape: default" shape="default" />
35+
<ant-bubble content="shape: round" shape="round" />
36+
<ant-bubble content="shape: corner" shape="corner" placement="end" />
37+
<ant-bubble content="variant: borderless" variant="borderless" />
38+
<ant-bubble content="variant: outlined" variant="outlined" />
39+
<ant-bubble content="variant: shadow" variant="shadow" />
40+
</ant-container>
41+
42+
<ant-container title="用户名">
43+
<ant-bubble content="你好,请问有什么可以帮你?" avatar="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ">
44+
<view slot="header">
45+
<text class="ant-copilot-bubble-name">Ant Design Mini</text>
46+
</view>
47+
</ant-bubble>
48+
</ant-container>
49+
50+
<ant-container title="加载中">
51+
<ant-switch checked="{{ loading }}" onChange="onSwitchChange" />
52+
<ant-bubble content="你好,这是一段加载后显示的内容" loading="{{loading}}" />
53+
<ant-bubble content="你好,这是一段加载后显示的内容,同时附带打字效果" loading="{{loading}}" typing="{{true}}" />
54+
</ant-container>
55+
56+
<ant-container title="自定义内容">
57+
<ant-bubble placement="end">
58+
<view>这是一段图文组合消息</view>
59+
<image class="ant-copilot-bubble-image" src="https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*5m0ZQYhxhjEAAAAAAAAAAAAAARQnAQ" />
60+
</ant-bubble>
61+
</ant-container>
62+

copilot-demo/pages/Bubble/index.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"usingComponents": {
3+
"ant-bubble": "../../../src/Bubble/index",
4+
"ant-container": "../../../src/Container/index",
5+
"ant-switch": "../../../src/Switch/index"
6+
}
7+
}

copilot-demo/pages/Bubble/index.less

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.navigation-bar {
2+
height: var(--tf-status-bar-height);
3+
}
4+
5+
.ant-copilot-bubble-name {
6+
font-weight: 400;
7+
font-size: 24rpx;
8+
color: #737373;
9+
line-height: 40rpx;
10+
}
11+
12+
.ant-copilot-bubble-image {
13+
width: 400rpx;
14+
height: 400rpx;
15+
border-radius: 10rpx;
16+
}

copilot-demo/pages/Bubble/index.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Page({
2+
data: {
3+
loading: true,
4+
showTyping: true,
5+
},
6+
onTypingComplete() {
7+
console.log('typing complete at', Date.now());
8+
},
9+
onTypingChange(e) {
10+
this.setData({
11+
showTyping: !this.data.showTyping,
12+
});
13+
},
14+
onSwitchChange() {
15+
this.setData({
16+
loading: !this.data.loading,
17+
});
18+
},
19+
});

copilot-demo/pages/Sender/index.axml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<view class="page">
2+
<view class="content">
3+
<ant-container title="基础用法">
4+
<ant-sender value="{{value}}" onChange="handleChange" onSubmit="handleSend" />
5+
</ant-container>
6+
7+
<ant-container title="发送loading状态">
8+
<ant-sender
9+
value="{{value1}}"
10+
placeholder="输入你想说的话..."
11+
onChange="handleChange1"
12+
onSubmit="handleSend1"
13+
onCancel="handleCancel"
14+
loading="{{loading}}"
15+
/>
16+
</ant-container>
17+
18+
<ant-container title="禁用状态">
19+
<ant-sender disabled="{{true}}" placeholder="输入框已禁用" />
20+
</ant-container>
21+
22+
<ant-container title="配合upload组件">
23+
<ant-sender
24+
value="{{value3}}"
25+
placeholder="可以配合其他组件使用"
26+
onChange="handleChange3"
27+
onSubmit="handleSend3"
28+
>
29+
<view slot="input-header">
30+
<ant-upload defaultFileList="{{[{ url: 'https://gw.alipayobjects.com/mdn/rms_226d75/afts/img/A*znK_ToIL8rQAAAAAAAAAAAAAARQnAQ', status: 'done' }]}}" />
31+
</view>
32+
</ant-sender>
33+
</ant-container>
34+
35+
<ant-container title="配合bubble和prompts">
36+
<scroll-view scroll-y style="height: 600rpx;" scroll-into-view="{{scrollToView}}">
37+
<view a:for="{{bubbleList}}" id="msg-{{index}}">
38+
<ant-bubble
39+
content="{{item.content}}"
40+
placement="{{index%2 ? 'end' : 'start'}}"
41+
shape="{{index%2 ? 'corner' : 'default'}}"
42+
typing="{{index%2 === 0}}"
43+
/>
44+
</view>
45+
</scroll-view>
46+
<ant-sender
47+
value="{{value4}}"
48+
placeholder="自定义样式"
49+
onChange="handleChange4"
50+
onSubmit="handleSend4"
51+
>
52+
</ant-sender>
53+
</ant-container>
54+
</view>
55+
</view>

copilot-demo/pages/Sender/index.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"usingComponents": {
3+
"ant-sender": "../../../src/Sender/index",
4+
"ant-upload": "../../../src/ImageUpload/index",
5+
"ant-bubble": "../../../src/Bubble/index",
6+
"ant-container": "../../../src/Container/index"
7+
}
8+
}

copilot-demo/pages/Sender/index.less

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.page {
2+
min-height: 100vh;
3+
background: var(--color-background);
4+
box-sizing: border-box;
5+
padding-bottom: 200rpx;
6+
}
7+
8+
.navigation-bar {
9+
margin-bottom: 24rpx;
10+
height: var(--tf-status-bar-height);
11+
}
12+
13+
.content {
14+
padding: 24rpx;
15+
}

copilot-demo/pages/Sender/index.ts

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
const mockResponse = [
2+
'很高兴见到你!让我们开始愉快的对话吧。',
3+
'你说得很有意思,能详细说说吗?',
4+
'这是个很好的问题,我来仔细想想...',
5+
'我明白你的想法,确实值得深入讨论。',
6+
'感谢分享,这让我想到了一些新的观点。',
7+
'你提到的这点很有启发性,我们可以进一步探讨。'
8+
]
9+
Page({
10+
senderTimer: null,
11+
data: {
12+
value: '',
13+
value1: '',
14+
value3: '',
15+
value4: '',
16+
loading: false,
17+
scrollToView: '',
18+
bubbleList: [
19+
{ content: '你好,世界!'}
20+
],
21+
},
22+
/** 基础用法 */
23+
handleChange(value: string) {
24+
this.setData({ value });
25+
},
26+
handleSend() {
27+
this.setData({ value: '' });
28+
},
29+
/** 发送loading状态 */
30+
handleChange1(value: string) {
31+
this.setData({ value1: value });
32+
},
33+
handleSend1() {
34+
this.setData({ loading: true });
35+
this.senderTimer = setTimeout(() => {
36+
this.setData({ value1: '', loading: false });
37+
}, 2000);
38+
},
39+
handleCancel() {
40+
clearTimeout(this.senderTimer);
41+
this.setData({ loading: false });
42+
},
43+
/** 配合upload组件 */
44+
handleChange3(value: string) {
45+
this.setData({ value3: value });
46+
},
47+
handleSend3() {
48+
this.setData({ value3: '' });
49+
},
50+
/** 配合bubble和prompts */
51+
addBubble(value: string) {
52+
const bubbleList = [...this.data.bubbleList];
53+
bubbleList.push({ content: value });
54+
this.setData({ bubbleList }, () => {
55+
this.setData({ scrollToView: `msg-${bubbleList.length - 1}` });
56+
});
57+
},
58+
handleChange4(value: string) {
59+
this.setData({ value4: value });
60+
},
61+
handleSend4() {
62+
if (!this.data.value4) return;
63+
this.addBubble(this.data.value4);
64+
this.setData({ value4: '' });
65+
setTimeout(() => {
66+
this.addBubble(mockResponse[Math.floor(Math.random() * mockResponse.length)]);
67+
}, 500);
68+
},
69+
});

copilot/Actions/check.sjs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function checkIcon(icon = '') {
2+
return getRegExp('^[a-zA-Z]+$').test(icon);
3+
}

copilot/Actions/index.axml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<import-sjs from="./check.sjs" name="{ checkIcon }" />
2+
3+
<view class="ant-copilot-actions {{className}}" style="{{style}}">
4+
<view
5+
a:for="{{items}}"
6+
class="ant-copilot-actions-item"
7+
hover-class="ant-copilot-actions-item-hover"
8+
onTap="handleTapAction"
9+
data-action="{{item}}"
10+
>
11+
<ant-icon
12+
a:if="{{checkIcon(item.icon)}}"
13+
className="ant-copilot-actions-item-icon"
14+
type="{{item.icon}}"
15+
/>
16+
<image a:else class="ant-copilot-actions-item-icon" src="{{item.icon}}" />
17+
</view>
18+
</view>

0 commit comments

Comments
 (0)