11<script setup>
22import { ref , onMounted } from ' vue'
33import initSqlJs from ' sql.js' ;
4- import FileUploader from ' ./components/FileUploader.vue'
5- import CoinList from " @/components/CoinList.vue" ;
4+ import FileUploaderView from ' ./components/FileUploaderView.vue'
5+ import CoinListView from " @/components/CoinListView.vue" ;
6+ import AboutView from " @/components/AboutView.vue" ;
67
78const selectedFile = ref (null )
89const coinsList = ref ([])
@@ -12,18 +13,9 @@ const status = ref('');
1213
1314let SQL = null ;
1415
15- import { useRoute , useRouter } from ' vue-router'
16-
17- const router = useRouter ()
18- const route = useRoute ()
19-
16+ const currentComponent = ref (' OpenFile' );
2017const drawer = ref (false )
2118
22- const goToHome = () => {
23- router .push (' /' )
24- drawer .value = false
25- }
26-
2719onMounted (async () => {
2820 try {
2921 SQL = await initSqlJs ({
@@ -40,6 +32,8 @@ const handleFileUpload = async (file) => {
4032 if (! file) return ;
4133
4234 status .value = ' Loading database...' ;
35+ currentComponent .value = ' CoinList' ;
36+ selectedFile .value = file;
4337
4438 const reader = new FileReader ();
4539
@@ -73,48 +67,51 @@ const handleFileUpload = async (file) => {
7367 };
7468
7569 reader .readAsArrayBuffer (file);
76- };
70+ }
7771 </script >
7872
7973<template >
8074 <v-layout >
81- <v-app-bar color =" primary" v-if = " route.path === '/' " >
82- <v-app-bar-nav-icon
83- @click.stop =" drawer = !drawer"
75+ <v-app-bar color =" primary" >
76+ <v-app-bar-nav-icon v-if = " currentComponent === 'OpenFile' || currentComponent === 'CoinList' "
77+ @click =" drawer = !drawer"
8478 ></v-app-bar-nav-icon >
85-
86- <v-toolbar-title >OpenNumismat</v-toolbar-title >
87- </v-app-bar >
88- <v-app-bar color =" primary" v-else >
89- <v-app-bar-nav-icon
79+ <v-app-bar-nav-icon v-else
9080 icon =" mdi-chevron-left"
91- @click.stop = " goToHome() "
81+ @click = " currentComponent = 'OpenFile' "
9282 ></v-app-bar-nav-icon >
9383
94- <v-toolbar-title >About </v-toolbar-title >
84+ <v-toolbar-title >OpenNumismat </v-toolbar-title >
9585 </v-app-bar >
9686
9787 <v-navigation-drawer v-model =" drawer" temporary >
9888 <v-list >
89+ <v-list-item
90+ prepend-icon =" mdi-cloud-upload"
91+ title =" Open"
92+ value =" open"
93+ @click =" currentComponent = 'OpenFile'; drawer = false"
94+ :active =" currentComponent === 'OpenFile'"
95+ ></v-list-item >
9996 <v-list-item
10097 prepend-icon =" mdi-information"
10198 title =" About"
10299 value =" about"
103- @click =" router.push('/about') "
104- :active =" route.path === '/about '"
100+ @click =" currentComponent = 'About'; drawer = false "
101+ :active =" currentComponent === 'About '"
105102 ></v-list-item >
106103 </v-list >
107104 </v-navigation-drawer >
108105
109- <router-view ></ router-view >
110-
111- < v-main v-if = " route.path !== '/about' " >
112- <div v-if = " !selectedFile " class = " select-view " >
113- < FileUploader :handleFile = " handleFileUpload " / >
114- <p >Your file not will be uploaded to the internet. You can disable internet connection.</ p >
106+ <v-main >
107+ < div v-if = " currentComponent === 'OpenFile' " >
108+ < FileUploaderView :onFileUploaded = " handleFileUpload " / >
109+ </ div >
110+ < div v-if = " currentComponent === 'CoinList' " >
111+ <CoinListView :file_name = " selectedFile.name " :coins_list = " coinsList " / >
115112 </div >
116- <div v-else class = " file-view " >
117- <CoinList :file_name = " selectedFile.name " :coins_list = " coinsList " />
113+ <div v-if = " currentComponent === 'About' " >
114+ <AboutView />
118115 </div >
119116 <div v-if =" status" class =" status" >{{ status }}</div >
120117 </v-main >
0 commit comments