rebuild logs ui

This commit is contained in:
Julian Freeman
2026-03-25 18:21:07 -04:00
parent 352047c123
commit 69a8047743
2 changed files with 93 additions and 25 deletions

View File

@@ -159,7 +159,7 @@ export const useSettingsStore = defineStore('settings', () => {
set: (val) => { toneRegisterMap.value[sourceLang.value.code] = val; }
});
const logs = ref<{ timestamp: string; type: 'request' | 'response' | 'error'; content: any }[]>([]);
const logs = ref<{ id: string; timestamp: string; type: 'request' | 'response' | 'error'; content: any }[]>([]);
const history = useLocalStorage<HistoryItem[]>('translation-history-v1', []);
const addLog = (type: 'request' | 'response' | 'error', content: any) => {
@@ -167,11 +167,12 @@ export const useSettingsStore = defineStore('settings', () => {
const timestamp = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
logs.value.unshift({
id: crypto.randomUUID(),
timestamp,
type,
content
});
if (logs.value.length > 20) logs.value.pop();
if (logs.value.length > 50) logs.value.pop(); // 稍微增加日志保留数量
};
const addHistory = (item: Omit<HistoryItem, 'id' | 'timestamp'>) => {