This commit is contained in:
2026-04-20 13:01:00 -04:00
parent bdad27d6ac
commit 505c7e612c
10 changed files with 307 additions and 205 deletions

View File

@@ -1,27 +1,28 @@
<script setup lang="ts">
import { ref, computed, watch } from 'vue';
import { Clock, Search, ArrowRightLeft, Trash2, User, Type, Copy, Check, FileText } from 'lucide-vue-next';
import { useSettingsStore, SPEAKER_IDENTITY_OPTIONS, TONE_REGISTER_OPTIONS } from '../stores/settings';
import { useHistoryStore } from '../stores/history';
import { SPEAKER_IDENTITY_OPTIONS, TONE_REGISTER_OPTIONS } from '../stores/settings';
import { cn } from '../lib/utils';
import { useClipboard } from '../composables/useClipboard';
const settings = useSettingsStore();
const historyStore = useHistoryStore();
const { activeCopyId, copyWithFeedback } = useClipboard();
const searchQuery = ref('');
const selectedHistoryId = ref<string | null>(null);
const filteredHistory = computed(() => {
if (!searchQuery.value.trim()) return settings.history;
if (!searchQuery.value.trim()) return historyStore.history;
const q = searchQuery.value.toLowerCase();
return settings.history.filter(h =>
return historyStore.history.filter(h =>
h.sourceText.toLowerCase().includes(q) ||
h.targetText.toLowerCase().includes(q)
);
});
const selectedHistoryItem = computed(() =>
settings.history.find(h => h.id === selectedHistoryId.value) || null
historyStore.history.find(h => h.id === selectedHistoryId.value) || null
);
watch(filteredHistory, (newVal) => {
@@ -31,7 +32,7 @@ watch(filteredHistory, (newVal) => {
}, { immediate: true });
const deleteHistoryItem = (id: string) => {
settings.history = settings.history.filter(h => h.id !== id);
historyStore.deleteHistoryItem(id);
if (selectedHistoryId.value === id) {
selectedHistoryId.value = filteredHistory.value[0]?.id || null;
}
@@ -55,7 +56,7 @@ const deleteHistoryItem = (id: string) => {
<div class="flex items-center justify-between px-1">
<span class="text-[11px] font-bold text-slate-400 uppercase tracking-wider"> {{ filteredHistory.length }} 条记录</span>
<button
@click="settings.history = []"
@click="historyStore.clearHistory()"
class="text-[11px] text-red-500 hover:underline font-medium"
>清空全部</button>
</div>
@@ -194,4 +195,4 @@ const deleteHistoryItem = (id: string) => {
</div>
</div>
</div>
</template>
</template>