refactor(ai-chat): 重构AI聊天国际化文件结构

- 将 ai-chat 语言文件从 ai/ 迁移至 ai-chat/ 目录
- 重构消息组件及多个子组件
This commit is contained in:
2026-05-18 15:36:13 +08:00
parent 5c56cfaaa7
commit 556ce9d132
12 changed files with 312 additions and 96 deletions

View File

@@ -1,9 +1,9 @@
<template>
<view class="ai-chat-search">
<!-- 搜索入口按钮(浮动在消息区右上角) -->
<view class="search-entrance" v-if="!showSearchBar" @click="toggleSearch">
<view class="search-entrance" :class="{ 'icon-only': !showLabel }" v-if="!showSearchBar" @click="toggleSearch">
<text class="iconfont icon-sousuo search-entrance-icon"></text>
<text class="search-entrance-label">搜索</text>
<text class="search-entrance-label" v-if="showLabel">{{ $lang('searchEntrance') }}</text>
</view>
<!-- 搜索浮条 -->
@@ -14,7 +14,7 @@
<input
class="search-bar-input"
v-model="searchKeyword"
placeholder="搜索聊天记录"
:placeholder="$lang('searchPlaceholder')"
:focus="true"
@input="onSearchInput"
@confirm="doSearch" />
@@ -27,7 +27,7 @@
<text class="search-bar-nav" :class="{ disabled: searchResultIndex >= searchResults.length - 1 }" @click="scrollToNextResult">▼</text>
</view>
</view>
<text class="search-bar-close" @click="closeSearch">完成</text>
<text class="search-bar-close" @click="closeSearch">{{ $lang('searchClose') }}</text>
</view>
</view>
</view>
@@ -39,6 +39,7 @@
*
* Props:
* messages: Array - 原始消息列表
* showLabel: Boolean - (默认 true) 是否显示"搜索"文字;设为 false 则只显示搜索图标
*
* Events:
* scroll-to: (messageKey: string) => void - 请求父组件滚动到指定消息
@@ -53,6 +54,11 @@ export default {
messages: {
type: Array,
default: () => []
},
// 是否显示文字标签;设为 false 则只显示搜索图标
showLabel: {
type: Boolean,
default: true
}
},
@@ -66,6 +72,7 @@ export default {
},
computed: {
// 过滤后的消息列表(与 v-for 保持一致)
filteredMessages() {
return this.messages.filter(
@@ -150,7 +157,7 @@ export default {
this._emitScrollTo(filteredIdx)
})
} else {
uni.showToast({ title: '未找到匹配结果', icon: 'none' })
uni.showToast({ title: this.$lang('noMatchResult'), icon: 'none' })
}
},
@@ -174,7 +181,7 @@ export default {
if (idx >= 0) {
this.scrollToSearchResult(idx)
} else {
uni.showToast({ title: '已到顶部', icon: 'none' })
uni.showToast({ title: this.$lang('searchAtTop'), icon: 'none' })
}
},
@@ -183,7 +190,7 @@ export default {
if (idx < this.searchResults.length) {
this.scrollToSearchResult(idx)
} else {
uni.showToast({ title: '已到底部', icon: 'none' })
uni.showToast({ title: this.$lang('searchAtBottom'), icon: 'none' })
}
},
@@ -251,7 +258,7 @@ export default {
// 搜索入口按钮
.search-entrance {
position: absolute;
top: 88rpx;
top: 44rpx;
right: 16rpx;
z-index: 10;
display: flex;
@@ -277,6 +284,15 @@ export default {
&:active {
background: rgba(255, 255, 255, 0.8);
}
// 仅显示图标模式(圆形小按钮)
&.icon-only {
width: 56rpx;
height: 56rpx;
padding: 0;
justify-content: center;
border-radius: 50%;
}
}
// 搜索浮条