11<script setup lang="ts">
2+ import { ref } from ' vue' ;
3+ import { VLayout , VAppBar , VNavigationDrawer , VMain , VBtn , VIcon , VToolbarTitle , VContainer } from ' vuetify/components' ;
4+ import { Menu as MenuIcon , FileText } from ' lucide-vue-next' ; // Lucide Icons
5+ import Sidebar from ' ./Sidebar.vue' ;
6+ import InputSection from ' ./InputSection.vue' ;
7+ import ResultsSection from ' ./ResultsSection.vue' ;
8+ import { Paper , Project } from ' ./types' ; // Importiere die Typen
9+
10+ import { useAuthStore } from ' @/stores/auth' ;
11+ import { login } from ' @/services/auth' ;
12+ import {AxiosError } from " axios" ;
13+
14+ // Zustand
15+ const sidebarOpen = ref (false );
16+ const currentQuery = ref <string | null >(null );
17+ const outputs = ref <Paper []>([]);
18+ // const isLoggedIn = ref(false);
19+
20+ const errorMessage = ref <string | null >(null );
21+ const isLoading = ref (false );
22+ const authStore = useAuthStore ();
23+
24+ const initialProjects: Project [] = [
25+ {
26+ id: ' 1' ,
27+ name: ' Project Alpha' ,
28+ query: ' Machine learning applications in healthcare' ,
29+ date: ' 2025-11-15' ,
30+ outputs: [
31+ { title: ' Deep Learning for Medical Image Analysis' , author: ' Smith, J. et al.' , year: 2024 , url: ' https://example.com/paper1' },
32+ { title: ' AI-Driven Diagnosis Systems' , author: ' Johnson, M. & Lee, K.' , year: 2023 , url: ' https://example.com/paper2' }
33+ ]
34+ },
35+ {
36+ id: ' 2' ,
37+ name: ' Project Beta' ,
38+ query: ' Climate change impacts on biodiversity' ,
39+ date: ' 2025-11-14' ,
40+ outputs: [
41+ { title: ' Global Warming Effects on Ecosystems' , author: ' Brown, A. et al.' , year: 2024 , url: ' https://example.com/paper3' }
42+ ]
43+ },
44+ {
45+ id: ' 3' ,
46+ name: ' Project Gamma' ,
47+ query: ' Quantum computing advances' ,
48+ date: ' 2025-11-13' ,
49+ outputs: [
50+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
51+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
52+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
53+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
54+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
55+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
56+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
57+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
58+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
59+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
60+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
61+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
62+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
63+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' },
64+ { title: ' Quantum Algorithms for Optimization' , author: ' Chen, L. & Wang, Y.' , year: 2023 , url: ' https://example.com/paper4' }
65+ ]
66+ }
67+ ];
68+ const recentProjects = ref <Project []>(initialProjects );
69+
70+ // Methoden
71+ const handleSubmitQuery = (query : string ) => {
72+ currentQuery .value = query ;
73+
74+ // Simuliere die Generierung von Artikeln
75+ const generatedOutputs: Paper [] = [
76+ { title: ' Recent Advances in Natural Language Processing' , author: ' Anderson, P. & Martinez, R.' , year: 2024 , url: ' https://example.com/nlp-advances' },
77+ { title: ' Transformer Models: A Comprehensive Review' , author: ' Davis, K. et al.' , year: 2023 , url: ' https://example.com/transformers' },
78+ { title: ' Attention Mechanisms in Neural Networks' , author: ' Wilson, T. & Thompson, S.' , year: 2024 , url: ' https://example.com/attention' },
79+ { title: ' BERT and Beyond: Language Model Evolution' , author: ' Garcia, M. et al.' , year: 2023 , url: ' https://example.com/bert' },
80+ { title: ' Large Language Models in Practice' , author: ' Taylor, J. & White, L.' , year: 2024 , url: ' https://example.com/llm-practice' }
81+ ];
82+ outputs .value = generatedOutputs ;
83+
84+ // Füge zu den aktuellen Projekten hinzu
85+ const newProject: Project = {
86+ id: Date .now ().toString (),
87+ name: ` Project ${recentProjects .value .length + 1 } ` ,
88+ query ,
89+ date: new Date ().toISOString ().split (' T' )[0 ],
90+ outputs: generatedOutputs
91+ };
92+ recentProjects .value .unshift (newProject ); // Füge am Anfang hinzu
93+ };
94+
95+ const handleProjectSelect = (project : Project ) => {
96+ currentQuery .value = project .query ;
97+ outputs .value = project .outputs ;
98+ sidebarOpen .value = false ;
99+ };
100+
101+ const handleNewQuery = () => {
102+ currentQuery .value = null ;
103+ outputs .value = [];
104+ };
105+ /*
106+ const handleLogin = (email: string, password: string) => {
107+ // Mock login logic
108+ isLoggedIn.value = true;
109+ sidebarOpen.value = false;
110+ console.log(`Logging in with: ${email} and ${password}`);
111+ };
112+ */
113+ const handleLogin = async (usernameFromSidebar : string ) => {
114+ isLoading .value = true ;
115+ errorMessage .value = null ;
116+
117+ try {
118+ const { access_token, refresh_token, user } = await login (usernameFromSidebar );
119+
120+ authStore .setAuth ({
121+ accessToken: access_token ,
122+ refreshToken: refresh_token ,
123+ user: user ,
124+ });
125+ sidebarOpen .value = false ;
126+ } catch (error : unknown ) {
127+ const axiosError = error as AxiosError <{ detail? : string }>;
128+
129+ if (axiosError .response ?.data ?.detail ) {
130+ errorMessage .value = axiosError .response .data .detail ;
131+ } else {
132+ errorMessage .value = ' An unexpected error occurred.' ;
133+ }
134+ } finally {
135+ isLoading .value = false ;
136+ }
137+ }
138+ const handleLogout = () => {
139+ // isLoggedIn.value = false;
140+ authStore .clearAuth ();
141+ };
142+ </script >
143+
144+ <template >
145+ <v-app >
146+ <v-layout >
147+ <v-navigation-drawer
148+ v-model =" sidebarOpen"
149+ location =" left"
150+ temporary
151+ width =" 320"
152+ >
153+ <Sidebar
154+ :is-open =" sidebarOpen "
155+ :recent-projects =" recentProjects "
156+ :is-logged-in =" authStore .isAuthenticated "
157+ @close =" sidebarOpen = false "
158+ @project-select =" handleProjectSelect "
159+ @new-project =" handleNewQuery "
160+ @login =" handleLogin "
161+ @logout =" handleLogout "
162+ />
163+ </v-navigation-drawer >
164+
165+ <v-app-bar app color =" white" flat border >
166+ <v-btn icon variant =" text" @click =" sidebarOpen = !sidebarOpen" >
167+ <v-icon :icon =" MenuIcon" />
168+ </v-btn >
169+ <v-toolbar-title class =" text-h6" >AI Text Processor</v-toolbar-title >
170+ <v-spacer ></v-spacer >
171+ <v-btn v-if =" currentQuery" @click =" handleNewQuery" variant =" outlined" color =" primary" >
172+ Neue Abfrage
173+ </v-btn >
174+ </v-app-bar >
175+
176+ <v-main class =" bg-grey-lighten-4" >
177+ <v-container fluid class =" h-100" >
178+ <div v-if =" !currentQuery" >
179+ <InputSection @submit =" handleSubmitQuery " />
180+ </div >
181+ <div v-else >
182+ <ResultsSection :query =" currentQuery " :outputs =" outputs " />
183+ </div >
184+ </v-container >
185+ </v-main >
186+ </v-layout >
187+ </v-app >
188+ </template >
189+ <!-- <script setup lang="ts">
2190import { useAuthStore } from '@/stores/auth';
3191
4192const authStore = useAuthStore();
@@ -9,4 +197,4 @@ const authStore = useAuthStore();
9197 <p>{{ authStore.accessToken }}</p>
10198</template>
11199
12- <style scoped></style >
200+ <style scoped></style>-->
0 commit comments