File tree Expand file tree Collapse file tree 8 files changed +67
-5
lines changed Expand file tree Collapse file tree 8 files changed +67
-5
lines changed Original file line number Diff line number Diff line change 14
14
"@commitlint/cli" : " ^19.3.0" ,
15
15
"@commitlint/config-conventional" : " ^19.2.2" ,
16
16
"axios" : " ^1.7.2" ,
17
+ "pinia" : " ^2.1.7" ,
17
18
"primeicons" : " ^7.0.0" ,
18
19
"vue" : " ^3.4.21" ,
19
20
"vue-router" : " 4" ,
Original file line number Diff line number Diff line change 1
1
<script setup>
2
2
import ' primeicons/primeicons.css'
3
+ import { computed } from ' vue'
4
+ import { useLoadingStore } from " @/store/loading" ;
5
+ import Icon from " @/components/Icon.vue" ;
3
6
7
+ const loadingStore = useLoadingStore ();
8
+ const isLoading = computed (() => loadingStore .isLoading );
4
9
</script >
5
10
6
11
<template >
12
+ <div v-if =" isLoading" class =" bg-white/80 fixed top-0 left-0 z-[1000] h-screen w-full flex justify-center items-center" >
13
+ <Icon icon =" pi-spin pi-spinner" className =" text-3xl text-[#67c23a]" />
14
+ </div >
7
15
<router-view ></router-view >
8
16
</template >
9
17
10
- <style scoped>
11
-
12
- </style >
Original file line number Diff line number Diff line change
1
+ import AxiosClient from "./axios" ;
2
+
3
+ const resource = "/category" ;
4
+
5
+ export default {
6
+ get ( classId : string ) {
7
+ return AxiosClient . get ( `${ resource } /${ classId } /exams` ) ;
8
+ }
9
+ }
10
+
Original file line number Diff line number Diff line change 1
1
import { createApp } from 'vue'
2
+ import { createPinia } from 'pinia'
2
3
import './style.css'
3
4
import App from './App.vue'
4
5
import router from './router'
@@ -7,6 +8,7 @@ import loading from "@/assets/avatarDefault.webp";
7
8
8
9
const app = createApp ( App )
9
10
11
+ app . use ( createPinia ( ) )
10
12
app . use ( router )
11
13
app . use ( VueLazyLoad , {
12
14
loading,
Original file line number Diff line number Diff line change
1
+ import { defineStore } from 'pinia' ;
2
+
3
+ interface LoadingState {
4
+ isLoading : boolean ;
5
+ } ;
6
+
7
+ export const useLoadingStore = defineStore ( {
8
+ id : "loading" ,
9
+
10
+ state : ( ) :LoadingState => ( {
11
+ isLoading : false ,
12
+ } ) ,
13
+
14
+ getters : {
15
+
16
+ } ,
17
+
18
+ actions : {
19
+ changeLoadingState ( _isLoading : boolean ) {
20
+ this . isLoading = _isLoading ;
21
+ if ( _isLoading ) {
22
+ document . body . style . overflowY = "hidden" ;
23
+ } else {
24
+ document . body . style . overflowY = "scroll" ;
25
+ }
26
+ }
27
+ }
28
+ } ) ;
Original file line number Diff line number Diff line change 8
8
:url =" `/danh-sach-bai-tap/${category.slug}`"
9
9
/>
10
10
</div >
11
- <div v-else >Loading...</div >
12
11
13
12
</template >
14
13
15
14
<script setup>
16
15
import ListCard from " @/components/ListCard.vue" ;
17
16
import { RepositoryFactory } from " @/api/RepositoryFactory" ;
18
17
import { onMounted , reactive } from " vue" ;
18
+ import { useLoadingStore } from " @/store/loading" ;
19
19
20
+ const loadingStore = useLoadingStore ();
20
21
const homeData = reactive ([]);
21
22
22
23
onMounted (async ()=> {
23
24
const HomeRepository = RepositoryFactory .get (" home" );
25
+ loadingStore .changeLoadingState (true );
24
26
const { data } = await HomeRepository .get ();
27
+ loadingStore .changeLoadingState (false );
25
28
homeData .value = data;
26
29
});
27
30
Original file line number Diff line number Diff line change 545
545
" @vue/compiler-dom" " 3.4.29"
546
546
" @vue/shared" " 3.4.29"
547
547
548
- " @vue/devtools-api@^6.5.1 " :
548
+ " @vue/devtools-api@^6.5.0 " , "@vue/devtools-api@^6.5. 1":
549
549
version "6.6.3"
550
550
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.6.3.tgz#b23a588154cba8986bba82b6e1d0248bde3fd1a0"
551
551
integrity sha512-0MiMsFma/HqA6g3KLKn+AGpL1kgKhFWszC9U29NfpWK5LE7bjeXxySWJrOJ77hBz+TBrBQ7o4QJqbPbqbs8rJw==
@@ -1575,6 +1575,14 @@ pify@^2.3.0:
1575
1575
resolved "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz"
1576
1576
integrity sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==
1577
1577
1578
+ pinia@^2.1.7 :
1579
+ version "2.1.7"
1580
+ resolved "https://registry.yarnpkg.com/pinia/-/pinia-2.1.7.tgz#4cf5420d9324ca00b7b4984d3fbf693222115bbc"
1581
+ integrity sha512-+C2AHFtcFqjPih0zpYuvof37SFxMQ7OEG2zV9jRI12i9BOy3YQVAHwdKtyyc8pDcDyIc33WCIsZaCFWU7WWxGQ==
1582
+ dependencies :
1583
+ " @vue/devtools-api" " ^6.5.0"
1584
+ vue-demi ">=0.14.5"
1585
+
1578
1586
pirates@^4.0.1 :
1579
1587
version "4.0.6"
1580
1588
resolved "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz"
@@ -1958,6 +1966,11 @@ vscode-uri@^3.0.8:
1958
1966
resolved "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz"
1959
1967
integrity sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==
1960
1968
1969
+ vue-demi@>=0.14.5 :
1970
+ version "0.14.8"
1971
+ resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.8.tgz#00335e9317b45e4a68d3528aaf58e0cec3d5640a"
1972
+ integrity sha512-Uuqnk9YE9SsWeReYqK2alDI5YzciATE0r2SkA6iMAtuXvNTMNACJLJEXNXaEy94ECuBe4Sk6RzRU80kjdbIo1Q==
1973
+
1961
1974
vue-demi@^0.12.5 :
1962
1975
version "0.12.5"
1963
1976
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.12.5.tgz#8eeed566a7d86eb090209a11723f887d28aeb2d1"
You can’t perform that action at this time.
0 commit comments