diff --git a/packages/pro-components/chat/attachments/_example/attachments.json b/packages/pro-components/chat/attachments/_example/attachments.json
index c8df4ffe9..b886d7832 100644
--- a/packages/pro-components/chat/attachments/_example/attachments.json
+++ b/packages/pro-components/chat/attachments/_example/attachments.json
@@ -1,5 +1,6 @@
{
"navigationBarTitleText": "Attachments 聊天附件",
+ "disableScroll": true,
"usingComponents": {
"base": "./base",
"fileLoading": "./file-loading",
diff --git a/packages/pro-components/chat/attachments/_example/attachments.less b/packages/pro-components/chat/attachments/_example/attachments.less
index e69de29bb..2d7f838b4 100644
--- a/packages/pro-components/chat/attachments/_example/attachments.less
+++ b/packages/pro-components/chat/attachments/_example/attachments.less
@@ -0,0 +1,10 @@
+.skyline {
+ display: flex;
+ flex-direction: column;
+ height: 100vh;
+
+ .scroll-view {
+ flex: 1;
+ height: 0;
+ }
+}
diff --git a/packages/pro-components/chat/attachments/_example/attachments.wxml b/packages/pro-components/chat/attachments/_example/attachments.wxml
index b09a7e2cb..850c8d501 100644
--- a/packages/pro-components/chat/attachments/_example/attachments.wxml
+++ b/packages/pro-components/chat/attachments/_example/attachments.wxml
@@ -1,20 +1,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/pro-components/chat/attachments/attachments.less b/packages/pro-components/chat/attachments/attachments.less
index 3ff937047..66ff8ce6c 100644
--- a/packages/pro-components/chat/attachments/attachments.less
+++ b/packages/pro-components/chat/attachments/attachments.less
@@ -23,7 +23,7 @@
// 可滚动内容区域
&__scrollable {
- height: 100%;
+ /* 移除固定高度设置,由动态绑定控制高度 */
display: flex;
align-items: center;
justify-content: flex-start;
@@ -80,6 +80,7 @@
&__files {
box-sizing: border-box;
margin-left: @attachments-file-margin;
+ display: inline-block;
&:first-of-type {
margin-left: 0;
diff --git a/packages/pro-components/chat/attachments/attachments.ts b/packages/pro-components/chat/attachments/attachments.ts
index 2c78d7785..84cf41f93 100644
--- a/packages/pro-components/chat/attachments/attachments.ts
+++ b/packages/pro-components/chat/attachments/attachments.ts
@@ -27,11 +27,17 @@ export default class Attachments extends SuperComponent {
data = {
classPrefix: name,
files: [],
+ isSkyline: false,
+ scrollViewHeight: 0, // 新增:scroll-view的高度
};
observers = {
items() {
this.setFiles();
+ // 新增:文件列表变化时重新计算高度
+ wx.nextTick(() => {
+ this.getScrollViewHeight();
+ });
},
};
@@ -51,6 +57,13 @@ export default class Attachments extends SuperComponent {
this.handleRemove(item, index);
}
},
+ // 新增:图片加载完成回调
+ onImageLoad() {
+ // 图片加载完成后重新计算高度
+ wx.nextTick(() => {
+ this.getScrollViewHeight();
+ });
+ },
handleFileClick(item) {
if (this.data.imageViewer && item.fileType === 'image') {
wx.previewImage({
@@ -62,6 +75,20 @@ export default class Attachments extends SuperComponent {
handleRemove(item, index) {
this.triggerEvent('remove', { item, index });
},
+ // 修改:获取所有文件元素的最大高度
+ getScrollViewHeight() {
+ const query = this.createSelectorQuery();
+ query.selectAll('.t-attachments__files').boundingClientRect();
+ query.exec((res) => {
+ if (res[0] && res[0].length > 0) {
+ // 获取所有文件元素的最大高度
+ const maxFileHeight = Math.max(...res[0].map((rect) => rect.height));
+ this.setData({
+ scrollViewHeight: maxFileHeight,
+ });
+ }
+ });
+ },
renderDesc(item) {
const sizeInBytes = item.size || 0;
let formattedSize;
@@ -187,9 +214,15 @@ export default class Attachments extends SuperComponent {
this.data.renderIcon = this.renderIcon.bind(this);
this.data.renderFileType = this.renderFileType.bind(this);
this.data.renderExtension = this.renderExtension.bind(this);
+ // 检测 Skyline 模式
+ this.setData({ isSkyline: this.renderer === 'skyline' });
},
attached() {
this.setFiles();
+ // 新增:组件挂载时计算高度
+ wx.nextTick(() => {
+ this.getScrollViewHeight();
+ });
},
detached() {},
};
diff --git a/packages/pro-components/chat/attachments/attachments.wxml b/packages/pro-components/chat/attachments/attachments.wxml
index 0769446fe..09fdda5ed 100644
--- a/packages/pro-components/chat/attachments/attachments.wxml
+++ b/packages/pro-components/chat/attachments/attachments.wxml
@@ -1,75 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.name}}
+ 上传中...{{item.progress || 0+"%"}}
+ 上传失败
+ {{item.errorMessage}}
+ {{item.desc}}
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{item.name}}
-
- 上传中...{{item.progress || 0+"%"}}
- 上传失败
- {{item.errorMessage}}
- {{item.desc}}
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/pro-components/chat/attachments/attachments.wxs b/packages/pro-components/chat/attachments/attachments.wxs
index d258fd6b1..084c9a105 100644
--- a/packages/pro-components/chat/attachments/attachments.wxs
+++ b/packages/pro-components/chat/attachments/attachments.wxs
@@ -46,8 +46,25 @@ function getFileTypeClass(inChat, files) {
return allImages ? 'all_images' : 'all_files';
}
+function hasImageFile(files) {
+ // 如果 files 为空或不存在,返回 false
+ if (!files || files.length === 0) {
+ return false;
+ }
+
+ // 检查是否存在至少一个图片文件
+ for (var i = 0; i < files.length; i++) {
+ if (files[i].fileType === 'image') {
+ return true;
+ }
+ }
+
+ return false;
+}
+
module.exports = {
imageStyle: imageStyle,
getImageMode: getImageMode,
getFileTypeClass: getFileTypeClass,
+ hasImageFile: hasImageFile,
};
diff --git a/packages/pro-components/chat/chat-actionbar/chat-actionbar.less b/packages/pro-components/chat/chat-actionbar/chat-actionbar.less
index 05d6960a2..54e83f2d6 100644
--- a/packages/pro-components/chat/chat-actionbar/chat-actionbar.less
+++ b/packages/pro-components/chat/chat-actionbar/chat-actionbar.less
@@ -67,6 +67,9 @@
border-right: 2rpx solid @component-stroke;
background-color: unset;
outline: none;
+ border: none;
+ border-radius: 0;
+ line-height: inherit;
&:after {
display: none;
diff --git a/packages/pro-components/chat/chat-content/_example/chat-content.json b/packages/pro-components/chat/chat-content/_example/chat-content.json
index 25ff5b753..a18591687 100644
--- a/packages/pro-components/chat/chat-content/_example/chat-content.json
+++ b/packages/pro-components/chat/chat-content/_example/chat-content.json
@@ -1,5 +1,6 @@
{
"navigationBarTitleText": "ChatContent",
+ "disableScroll": true,
"usingComponents": {
"base": "./base"
}
diff --git a/packages/pro-components/chat/chat-content/_example/chat-content.less b/packages/pro-components/chat/chat-content/_example/chat-content.less
index e69de29bb..2d7f838b4 100644
--- a/packages/pro-components/chat/chat-content/_example/chat-content.less
+++ b/packages/pro-components/chat/chat-content/_example/chat-content.less
@@ -0,0 +1,10 @@
+.skyline {
+ display: flex;
+ flex-direction: column;
+ height: 100vh;
+
+ .scroll-view {
+ flex: 1;
+ height: 0;
+ }
+}
diff --git a/packages/pro-components/chat/chat-content/_example/chat-content.wxml b/packages/pro-components/chat/chat-content/_example/chat-content.wxml
index 2d63cc958..c761e7106 100644
--- a/packages/pro-components/chat/chat-content/_example/chat-content.wxml
+++ b/packages/pro-components/chat/chat-content/_example/chat-content.wxml
@@ -1,7 +1,15 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/pro-components/chat/chat-content/chat-content.less b/packages/pro-components/chat/chat-content/chat-content.less
index 00a16fa62..2de28041d 100644
--- a/packages/pro-components/chat/chat-content/chat-content.less
+++ b/packages/pro-components/chat/chat-content/chat-content.less
@@ -5,14 +5,16 @@
@chat-content-user-text-color: var(--td-chat-content-user-text-color, @text-color-primary);
@chat-content-assistant-text-color: var(--td-chat-content-assistant-text-color, @text-color-primary);
@chat-content-error-text-color: var(--td-chat-content-error-text-color, @error-color);
+@chat-content-line-height: 1.5;
.@{chat-content} {
font: @font-body-large;
+ line-height: @chat-content-line-height;
word-break: break-all;
word-wrap: break-word;
overflow-wrap: break-word;
box-sizing: border-box;
- width: fit-content;
+ max-width: 100%;
&__user,
&__system {
@@ -42,7 +44,7 @@
border-radius: @radius-small;
}
}
-// 错误状态样式
+ // 错误状态样式
&__error {
color: @chat-content-error-text-color;
}
diff --git a/packages/pro-components/chat/chat-list/_example/agent/index.wxss b/packages/pro-components/chat/chat-list/_example/agent/index.wxss
index 8150545a5..225a4751d 100644
--- a/packages/pro-components/chat/chat-list/_example/agent/index.wxss
+++ b/packages/pro-components/chat/chat-list/_example/agent/index.wxss
@@ -54,11 +54,11 @@
}
.t-steps-item__circle--finish {
- background-color: transparent;
- color: var(--td-text-color-primary);
- border: 1px solid var(--td-text-color-primary);
- width: 16px;
- height: 16px;
+ background-color: transparent !important;
+ color: var(--td-text-color-primary) !important;
+ border: 1px solid var(--td-text-color-primary) !important;
+ width: 16px !important;
+ height: 16px !important;
}
.t-steps-item__circle--finish .t-icon {
@@ -66,10 +66,10 @@
}
.t-steps-item__line--finish {
- background-color: var(--td-component-border);
+ background-color: var(--td-component-border) !important;
}
.t-steps-item__title--finish {
- color: var(--td-text-color-primary);
- font-weight: 600;
+ color: var(--td-text-color-primary) !important;
+ font-weight: 600 !important;
}
diff --git a/packages/pro-components/chat/chat-list/_example/image/index.wxss b/packages/pro-components/chat/chat-list/_example/image/index.wxss
index e31bbe356..09852ba34 100644
--- a/packages/pro-components/chat/chat-list/_example/image/index.wxss
+++ b/packages/pro-components/chat/chat-list/_example/image/index.wxss
@@ -21,18 +21,21 @@
width: 100%;
}
+.image-chat .assistant .t-chat-message__detail {
+ width: 100%;
+}
+
.attachment-slide {
height: 274rpx;
- width: 100%;
+ width: calc(100% + 128rpx) !important;
}
.attachment-slide .t-attachments {
- padding-right: 32rpx;
padding-top: 24rpx;
box-sizing: border-box;
- position: fixed;
+ position: relative;
z-index: 2;
- left: 0;
+ left: -128rpx;
right: 0;
}
@@ -41,5 +44,5 @@
}
.attachment-slide .t-attachments .t-attachments__files:last-child {
- padding-right: 32rpx;
+ padding-right: 64rpx;
}
diff --git a/packages/pro-components/chat/chat-list/chat-list.less b/packages/pro-components/chat/chat-list/chat-list.less
index 5f9c896f1..0d59661ab 100644
--- a/packages/pro-components/chat/chat-list/chat-list.less
+++ b/packages/pro-components/chat/chat-list/chat-list.less
@@ -12,7 +12,6 @@
color: @chat-text-color;
&__content {
- flex: 1;
overflow-y: auto;
overflow-x: hidden;
width: 100%;
@@ -26,10 +25,15 @@
transform: scaleY(-1);
}
}
+ }
- .placeholder {
- flex-grow: 1;
- flex-shrink: 1;
- }
+ &__placeholder {
+ flex-grow: 1;
+ flex-shrink: 1;
+ }
+
+ &__footer {
+ flex-grow: 0;
+ flex-shrink: 0;
}
}
diff --git a/packages/pro-components/chat/chat-list/chat-list.wxml b/packages/pro-components/chat/chat-list/chat-list.wxml
index 4d595befb..7b0513b5a 100644
--- a/packages/pro-components/chat/chat-list/chat-list.wxml
+++ b/packages/pro-components/chat/chat-list/chat-list.wxml
@@ -12,10 +12,8 @@
bindscroll="onScroll"
bindscrolltoupper="handlerScrollToUpper"
bindscrolltolower="handlerScrollToLower"
+ type="list"
>
-
-
-
-
+
{{node.text}}
diff --git a/packages/pro-components/chat/chat-markdown/chat-markdown.less b/packages/pro-components/chat/chat-markdown/chat-markdown.less
index 9351a6ff3..8557683ff 100644
--- a/packages/pro-components/chat/chat-markdown/chat-markdown.less
+++ b/packages/pro-components/chat/chat-markdown/chat-markdown.less
@@ -4,7 +4,7 @@
@chat-markdown-table: ~'@{prefix}-chat-markdown-table';
@chat-markdown-color: @text-color-primary;
-@chat-markdown-line-height: 1.75;
+@chat-markdown-line-height: 1.5;
@chat-markdown-h1: 2em;
@chat-markdown-h2: 1.75em;
@chat-markdown-h3: 1.5em;
@@ -115,7 +115,7 @@
&-list {
display: block;
padding: 0;
- margin: 0 0 @spacer 1.5em;;
+ margin: 0 0 @spacer 1.5em;
// 有序列表
&__decimal {
diff --git a/packages/pro-components/chat/chat-message/_example/chat-message.json b/packages/pro-components/chat/chat-message/_example/chat-message.json
index cec314a9b..0e5a4ed0a 100644
--- a/packages/pro-components/chat/chat-message/_example/chat-message.json
+++ b/packages/pro-components/chat/chat-message/_example/chat-message.json
@@ -1,5 +1,6 @@
{
"navigationBarTitleText": "ChatItem",
+ "disableScroll": true,
"usingComponents": {
"t-skeleton": "tdesign-miniprogram/skeleton/skeleton",
"base": "./base",
diff --git a/packages/pro-components/chat/chat-message/_example/chat-message.less b/packages/pro-components/chat/chat-message/_example/chat-message.less
index 191f5946d..213f45bfd 100644
--- a/packages/pro-components/chat/chat-message/_example/chat-message.less
+++ b/packages/pro-components/chat/chat-message/_example/chat-message.less
@@ -5,3 +5,14 @@
.t-button:last-child {
margin-right: 0;
}
+
+.skyline {
+ display: flex;
+ flex-direction: column;
+ height: 100vh;
+
+ .scroll-view {
+ flex: 1;
+ height: 0;
+ }
+}
diff --git a/packages/pro-components/chat/chat-message/_example/chat-message.wxml b/packages/pro-components/chat/chat-message/_example/chat-message.wxml
index b42ab7051..7fd6195e9 100644
--- a/packages/pro-components/chat/chat-message/_example/chat-message.wxml
+++ b/packages/pro-components/chat/chat-message/_example/chat-message.wxml
@@ -1,26 +1,30 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/pro-components/chat/chat-message/chat-message.less b/packages/pro-components/chat/chat-message/chat-message.less
index ca1e6aa03..37345b70b 100644
--- a/packages/pro-components/chat/chat-message/chat-message.less
+++ b/packages/pro-components/chat/chat-message/chat-message.less
@@ -47,7 +47,8 @@
.@{chat-message}__detail {
max-width: 100%;
box-sizing: border-box;
- display: contents;
+ display: flex;
+ flex-direction: column;
}
// 有头部时的样式
@@ -66,10 +67,6 @@
.@{chat-message}__base {
padding-right: @spacer-2;
}
-
- .@{chat-content} {
- max-width: 90%;
- }
}
// 助手消息样式
diff --git a/packages/pro-components/chat/chat-sender/_example/attachments/index.wxml b/packages/pro-components/chat/chat-sender/_example/attachments/index.wxml
index 6b5f70cb3..30c76ba46 100644
--- a/packages/pro-components/chat/chat-sender/_example/attachments/index.wxml
+++ b/packages/pro-components/chat/chat-sender/_example/attachments/index.wxml
@@ -1,5 +1,5 @@