feat: 修复 H5 底部导航覆盖 + 更新项目进度文档

## H5 底部导航修复 (Bug #10)
- 精简 App.vue,移除重复 tabbar,仅保留全局样式
- uni-page 设置 height: calc(100% - 50px) + overflow-y: auto
- 内容区域精确停在底部导航上方,独立滚动不再叠加
- 恢复 custom-tab-bar 组件

## 项目进度文档
- PROGRESS.md 更新至 10 个 Bug 修复
- 新增 H5 底部导航修复记录
- 新增历史变更条目
This commit is contained in:
TradeMate Dev
2026-05-12 20:24:42 +08:00
parent 69e164dcae
commit 7b62c2f8b4
125 changed files with 19725 additions and 728 deletions
+223 -7
View File
@@ -42,11 +42,36 @@
<view class="result-section" v-if="result">
<view class="result-header">
<text class="result-label">翻译结果</text>
<text class="copy-btn" @click="copyResult">复制</text>
<view class="result-actions">
<text class="action-btn extract-btn" @click="handleExtract">抽取信息</text>
<text class="action-btn" @click="playTts">朗读</text>
<text class="copy-btn" @click="copyResult">复制</text>
</view>
</view>
<view class="result-content">
<text class="result-text">{{ result }}</text>
</view>
<view class="rating-section" v-if="result">
<text class="rating-label">评价:</text>
<view class="stars">
<text
class="star"
v-for="s in 5"
:key="s"
@click="rateTranslation(s)"
>{{ s <= rating ? '★' : '☆' }}</text>
</view>
</view>
</view>
<view class="extract-section" v-if="extractedInfo">
<view class="extract-header">
<text class="extract-label">抽取信息</text>
<text class="extract-close" @click="extractedInfo = null">×</text>
</view>
<view class="extract-content">
<text class="extract-text">{{ extractedInfo }}</text>
</view>
</view>
<view class="suggestions-section" v-if="suggestions.length > 0">
@@ -66,13 +91,23 @@
</view>
</view>
<view class="preferences-section" v-if="preferences">
<view class="preferences-header">
<text class="preferences-label">AI偏好设置</text>
</view>
<view class="preferences-body">
<text class="pref-text">{{ preferences.preferred_tone || '尚未分析偏好' }}</text>
<text class="pref-detail" v-if="preferences.common_words">常用词: {{ preferences.common_words.join(', ') }}</text>
</view>
</view>
<view class="keyboard-height" :style="{ height: keyboardHeight + 'px' }"></view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { translateApi } from '@/utils/api.js'
import { translateApi, interactionApi, BASE_URL } from '@/utils/api.js'
const mode = ref('translate')
const inputText = ref('')
@@ -81,6 +116,9 @@ const suggestions = ref([])
const loading = ref(false)
const targetIndex = ref(1)
const keyboardHeight = ref(0)
const rating = ref(0)
const extractedInfo = ref(null)
const preferences = ref(null)
const targetLangs = ref([
{ code: 'en', name: 'English' },
@@ -93,7 +131,6 @@ const onTargetChange = (e) => {
}
const onInput = () => {
// Real-time input handling
}
const handleTranslate = async () => {
@@ -111,6 +148,7 @@ const handleTranslate = async () => {
targetLangs[targetIndex.value].code
)
result.value = res.translated
loadPreferences()
} else {
const res = await translateApi.getReply(inputText.value, 'professional', 3)
suggestions.value = res.suggestions || []
@@ -127,6 +165,8 @@ const clearAll = () => {
inputText.value = ''
result.value = ''
suggestions.value = []
extractedInfo.value = null
rating.value = 0
}
const copyResult = () => {
@@ -138,11 +178,69 @@ const copyResult = () => {
})
}
const playTts = () => {
if (!result.value) return
const lang = targetLangs[targetIndex.value].code
const token = uni.getStorageSync('token')
const url = `${BASE_URL}/translate/tts?text=${encodeURIComponent(result.value)}&lang=${lang}`
uni.showLoading({ title: '语音生成中...' })
uni.downloadFile({
url,
header: { Authorization: `Bearer ${token}` },
success: (res) => {
uni.hideLoading()
if (res.statusCode === 200) {
const audioCtx = uni.createInnerAudioContext()
audioCtx.src = res.tempFilePath
audioCtx.play()
audioCtx.onEnded(() => audioCtx.destroy())
} else {
uni.showToast({ title: '语音生成失败', icon: 'none' })
}
},
fail: () => {
uni.hideLoading()
uni.showToast({ title: '语音生成失败', icon: 'none' })
},
})
}
const handleExtract = async () => {
if (!result.value) return
try {
const res = await translateApi.extract(result.value)
extractedInfo.value = typeof res.extracted === 'string' ? res.extracted : JSON.stringify(res.extracted, null, 2)
} catch (err) {
uni.showToast({ title: err.message || '抽取失败', icon: 'none' })
}
}
const rateTranslation = async (s) => {
rating.value = s
try {
await translateApi.sendFeedback(null, s)
uni.showToast({ title: '感谢评价', icon: 'success' })
} catch (err) {
console.error('反馈提交失败', err)
}
}
const loadPreferences = async () => {
try {
const res = await interactionApi.getPreferences()
preferences.value = res
} catch (err) {
console.error('加载偏好失败', err)
}
}
const selectSuggestion = (index) => {
const selected = suggestions.value[index]
uni.setClipboardData({
data: selected.text,
success: () => {
interactionApi.recordEdit(null, selected.text).catch(() => {})
uni.showToast({ title: '已复制建议内容', icon: 'success' })
},
})
@@ -151,9 +249,10 @@ const selectSuggestion = (index) => {
<style lang="scss" scoped>
.translate-container {
min-height: 100vh;
min-height: 100%;
background: #f5f5f5;
padding: 20rpx;
box-sizing: border-box;
}
.mode-switch {
@@ -254,10 +353,30 @@ const selectSuggestion = (index) => {
color: #999;
}
.copy-btn {
.result-actions {
display: flex;
gap: 12rpx;
}
.action-btn, .copy-btn {
font-size: 24rpx;
color: #1890ff;
padding: 8rpx 16rpx;
border-radius: 6rpx;
}
.action-btn {
color: #52c41a;
background: #f6ffed;
}
.extract-btn {
color: #722ed1;
background: #f9f0ff;
}
.copy-btn {
color: #1890ff;
background: #e6f7ff;
}
.result-content {
@@ -271,10 +390,72 @@ const selectSuggestion = (index) => {
line-height: 1.6;
}
.rating-section {
display: flex;
align-items: center;
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 2rpx solid #f5f5f5;
}
.rating-label {
font-size: 24rpx;
color: #999;
margin-right: 12rpx;
}
.stars {
display: flex;
gap: 8rpx;
}
.star {
font-size: 36rpx;
color: #faad14;
}
.extract-section {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
}
.extract-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12rpx;
}
.extract-label {
font-size: 26rpx;
color: #722ed1;
font-weight: 600;
}
.extract-close {
font-size: 36rpx;
color: #999;
}
.extract-content {
padding: 16rpx;
background: #f9f0ff;
border-radius: 8rpx;
}
.extract-text {
font-size: 26rpx;
line-height: 1.5;
white-space: pre-wrap;
}
.suggestions-section {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
}
.suggestions-header {
@@ -313,7 +494,42 @@ const selectSuggestion = (index) => {
border-radius: 6rpx;
}
.preferences-section {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
}
.preferences-header {
margin-bottom: 12rpx;
}
.preferences-label {
font-size: 26rpx;
color: #666;
font-weight: 600;
}
.preferences-body {
padding: 12rpx;
background: #f0f5ff;
border-radius: 8rpx;
}
.pref-text {
font-size: 26rpx;
color: #1890ff;
display: block;
margin-bottom: 8rpx;
}
.pref-detail {
font-size: 24rpx;
color: #666;
}
.keyboard-height {
width: 100%;
}
</style>
</style>