fix(h5): 修复H5 SSE流完成信号兼容和页面onShow时序

- sendHttpStream 兼容 data.event === 'done' 和嵌套 data.data 格式
- index.vue onShow 用  确保 ref 就绪后加载历史
- 组件 mounted 兜底调用 loadHistoryIfNeeded
- 历史消息映射添加 type:'text',兼容 msg.content 字段
- 去掉所有有帮助/没帮助按钮
This commit is contained in:
2026-05-14 18:23:32 +08:00
parent bd778c0283
commit 7a713e07e1
3 changed files with 36 additions and 17 deletions

View File

@@ -570,6 +570,8 @@ export default {
// 初始加载时滚底(仅一次)
this.$nextTick(() => {
this.scrollToBottom()
// 确保 H5 在组件挂载后也尝试加载历史(兜底)
this.loadHistoryIfNeeded()
})
},
watch: {

View File

@@ -148,17 +148,23 @@ export default {
onShow() {
console.log('[AI Chat Page] onShow 触发');
// 监听键盘高度变化
uni.onKeyboardHeightChange((res) => {
this.keyboardHeight = res.height;
if (this.$refs.chat && this.$refs.chat.updateKeyboardHeight) {
this.$refs.chat.updateKeyboardHeight(res.height);
// 监听键盘高度变化(H5 可能不支持,try-catch 保护)
try {
uni.onKeyboardHeightChange((res) => {
this.keyboardHeight = res.height;
if (this.$refs.chat && this.$refs.chat.updateKeyboardHeight) {
this.$refs.chat.updateKeyboardHeight(res.height);
}
});
} catch (e) {
console.warn('onKeyboardHeightChange 不可用:', e.message);
}
// 每次页面显示时尝试加载历史记录(H5可能组件尚未创建,用 nextTick 确保 ref 就绪)
this.$nextTick(() => {
if (this.$refs.chat && this.$refs.chat.loadHistoryIfNeeded) {
this.$refs.chat.loadHistoryIfNeeded();
}
});
// 每次页面显示时尝试加载历史记录
if (this.$refs.chat && this.$refs.chat.loadHistoryIfNeeded) {
this.$refs.chat.loadHistoryIfNeeded();
}
},
onHide() {