add refinement to history
This commit is contained in:
@@ -178,10 +178,11 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
const addHistory = (item: Omit<HistoryItem, 'id' | 'timestamp'>) => {
|
||||
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')}`;
|
||||
const id = crypto.randomUUID();
|
||||
|
||||
history.value.unshift({
|
||||
...item,
|
||||
id: crypto.randomUUID(),
|
||||
id,
|
||||
timestamp
|
||||
});
|
||||
|
||||
@@ -189,6 +190,15 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
if (history.value.length > 100) {
|
||||
history.value = history.value.slice(0, 100);
|
||||
}
|
||||
|
||||
return id;
|
||||
};
|
||||
|
||||
const updateHistoryItem = (id: string, updates: Partial<HistoryItem>) => {
|
||||
const index = history.value.findIndex(h => h.id === id);
|
||||
if (index !== -1) {
|
||||
history.value[index] = { ...history.value[index], ...updates };
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -210,6 +220,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
logs,
|
||||
history,
|
||||
addLog,
|
||||
addHistory
|
||||
addHistory,
|
||||
updateHistoryItem
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user