detailed logs

This commit is contained in:
Julian Freeman
2026-03-28 19:41:05 -04:00
parent f3150f06fa
commit ac951c31b1
4 changed files with 88 additions and 29 deletions

View File

@@ -159,10 +159,10 @@ export const useSettingsStore = defineStore('settings', () => {
set: (val) => { toneRegisterMap.value[sourceLang.value.code] = val; }
});
const logs = ref<{ id: string; timestamp: string; type: 'request' | 'response' | 'error'; content: any }[]>([]);
const logs = ref<{ id: string; timestamp: string; type: 'request' | 'response' | 'error'; content: any; curl?: string }[]>([]);
const history = useLocalStorage<HistoryItem[]>('translation-history-v1', []);
const addLog = (type: 'request' | 'response' | 'error', content: any) => {
const addLog = (type: 'request' | 'response' | 'error', content: any, curl?: string) => {
const now = new Date();
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')}`;
@@ -170,7 +170,8 @@ export const useSettingsStore = defineStore('settings', () => {
id: crypto.randomUUID(),
timestamp,
type,
content
content,
curl
});
if (logs.value.length > 50) logs.value.pop(); // 稍微增加日志保留数量
};