feat(i18n): 改造10个组件为i18n国际化,同步更新9种语言翻译文件
- 组件改造:EmptyState、ExportPanel、SearchConditionItem、SearchHistoryPanel、 SearchResultCard、SearchResultList、Select、SortSwitcher、TemplatePanel、 BottomNavigation、SearchConditionPanel - 替换硬编码中文为 $t() 调用和 computed 响应式翻译 - 新增翻译键:search(搜索历史/模板/条件)、export(导出选项)、 common.pleaseSelect 等 - 同步更新 zh-CN、en、zh-TW、ja、ko、es、fr、de、pt 共9种语言文件 - 重构 errorHandler:从 API 错误处理改为本地应用错误处理 - 移除 search.ts 中未使用的 SearchService 接口
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<Card class="template-panel">
|
||||
<view class="panel-header">
|
||||
<Typography variant="h4" weight="semibold">搜索模板</Typography>
|
||||
<Typography variant="h4" weight="semibold">{{ $t('search.searchTemplates') }}</Typography>
|
||||
<Button size="small" type="text" @click="handleRefresh">
|
||||
<Icon name="refresh" size="16rpx" color="rgba(113, 113, 122, 255)" />
|
||||
</Button>
|
||||
@@ -12,7 +12,7 @@
|
||||
<Icon name="search" size="16rpx" color="rgba(113, 113, 122, 255)" />
|
||||
<input
|
||||
v-model="searchKeyword"
|
||||
placeholder="搜索模板"
|
||||
:placeholder="$t('search.searchTemplates')"
|
||||
class="input-field"
|
||||
/>
|
||||
</view>
|
||||
@@ -33,8 +33,8 @@
|
||||
<view v-if="filteredTemplates.length === 0" class="empty-templates">
|
||||
<EmptyState
|
||||
icon="empty"
|
||||
title="暂无模板"
|
||||
description="没有找到符合条件的模板"
|
||||
:title="$t('search.noTemplatesTitle')"
|
||||
:description="$t('search.noTemplatesDesc')"
|
||||
size="small"
|
||||
/>
|
||||
</view>
|
||||
@@ -65,6 +65,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { SearchRequest, SearchTemplate } from '../../types/search'
|
||||
import templateService from '../../services/templateService'
|
||||
import Card from '../Card/Card.vue'
|
||||
@@ -73,23 +74,25 @@ import Icon from '../Icon/Icon.vue'
|
||||
import Typography from '../Typography/Typography.vue'
|
||||
import EmptyState from '../EmptyState/index.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const emit = defineEmits<{
|
||||
select: [condition: SearchRequest]
|
||||
}>()
|
||||
|
||||
const searchKeyword = ref('')
|
||||
const selectedCategory = ref('全部')
|
||||
const selectedCategory = ref('__all__')
|
||||
const templates = ref<SearchTemplate[]>([])
|
||||
|
||||
const categories = computed(() => {
|
||||
const allCategories = templateService.getCategories()
|
||||
return ['全部', ...allCategories]
|
||||
return [t('search.allCategories'), ...allCategories]
|
||||
})
|
||||
|
||||
const filteredTemplates = computed(() => {
|
||||
let result = templates.value
|
||||
|
||||
if (selectedCategory.value !== '全部') {
|
||||
if (selectedCategory.value !== '__all__') {
|
||||
result = templateService.getTemplatesByCategory(selectedCategory.value)
|
||||
}
|
||||
|
||||
@@ -105,7 +108,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
function loadTemplates() {
|
||||
templates.value = templateService.getTemplates()
|
||||
templates.value = templateService.getSearchTemplates()
|
||||
}
|
||||
|
||||
function handleRefresh() {
|
||||
|
||||
Reference in New Issue
Block a user