FE-1: Login-Seite vervollständigen, Theme-Toggle, Sidebar-Historie, Hauptlayout

This commit is contained in:
faligam
2026-09-06 06:51:45 +00:00
parent 631b17ae05
commit 407a30e776
11 changed files with 950 additions and 36 deletions

43
src/lib/sidebar.ts Normal file
View File

@@ -0,0 +1,43 @@
import { writable } from 'svelte/store';
import { apiGet, apiDelete, apiPost } from '$lib/api';
import type { ResearchSummary } from '$lib/types';
// Sidebar visibility (mobile toggle)
export const sidebarOpen = writable(false);
// Currently selected research session ID
export const selectedResearchId = writable<string | null>(null);
export interface ResearchListItem extends ResearchSummary {
truncatedQuery?: string;
truncatedId?: string;
}
const HISTORY_LIMIT = 50;
export async function loadResearchHistory(apiKey: string): Promise<ResearchSummary[]> {
const list = await apiGet<ResearchSummary[]>('/v1/research', { apiKey });
// Sort descending by created_at (newest first), limit to HISTORY_LIMIT
const sorted = list
.slice()
.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())
.slice(0, HISTORY_LIMIT);
return sorted;
}
export async function deleteResearch(id: string, apiKey: string): Promise<void> {
await apiDelete<void>(`/v1/research/${id}`, { apiKey });
}
export async function createResearch(
apiKey: string,
query: string,
language: string,
depth: string
): Promise<{ id: string }> {
return await apiPost<{ id: string }>(
'/v1/research',
{ query, language, depth },
{ apiKey }
);
}