File tree Expand file tree Collapse file tree 5 files changed +1121
-865
lines changed Expand file tree Collapse file tree 5 files changed +1121
-865
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,16 @@ import * as components from 'vuetify/components';
4
4
import * as directives from 'vuetify/directives' ;
5
5
import '@mdi/font/css/materialdesignicons.css' ;
6
6
import { createApp } from 'vue' ;
7
+ import { createPinia } from 'pinia' ;
7
8
import VueAxios from 'vue-axios' ;
8
9
import axios from './plugins/axios' ;
9
10
import App from './App.vue' ;
10
11
import { registerPlugins } from './plugins' ;
11
- import store from './store/user' ;
12
12
13
+ const pinia = createPinia ( ) ;
13
14
const app = createApp ( App ) ;
14
15
app . use ( VueAxios , axios ) ;
15
- app . use ( store ) ;
16
+ app . use ( pinia ) ;
16
17
17
18
registerPlugins ( app ) ;
18
19
Original file line number Diff line number Diff line change 73
73
</template >
74
74
75
75
<script >
76
- import { mapGetters } from ' vuex ' ;
76
+ import { useUserStore } from ' ../../store/user ' ;
77
77
78
78
export default {
79
79
data : () => ({
@@ -93,12 +93,14 @@ export default {
93
93
],
94
94
}),
95
95
computed: {
96
- ... mapGetters ({
97
- user: ' getUser' ,
98
- }),
96
+ user () {
97
+ const userStore = useUserStore ();
98
+ return userStore .getUser ;
99
+ },
99
100
},
100
101
async mounted () {
101
- await this .$store .dispatch (' fetchUser' );
102
+ const userStore = useUserStore ();
103
+ await userStore .fetchUser ();
102
104
this .overlay = false ;
103
105
},
104
106
methods: {
Original file line number Diff line number Diff line change 1
- import { createStore } from 'vuex ' ;
1
+ import { defineStore } from 'pinia ' ;
2
2
import axios from '../plugins/axios' ;
3
3
4
- // Create a new store instance.
5
- export default createStore ( {
6
- state ( ) {
7
- return {
8
- user : null ,
9
- } ;
10
- } ,
11
- mutations : {
12
- setUser ( state , user ) {
13
- state . user = user ;
14
- } ,
15
- } ,
4
+ export const useUserStore = defineStore ( 'user' , {
5
+ state : ( ) => ( {
6
+ user : null ,
7
+ } ) ,
16
8
getters : {
17
- getUser ( state ) {
18
- return state . user ;
19
- } ,
9
+ getUser : ( state ) => state . user ,
20
10
} ,
21
11
actions : {
22
- async fetchUser ( { commit } ) {
12
+ async fetchUser ( ) {
23
13
const { data } = await axios . get ( '/api/user' ) ;
24
- commit ( 'setUser' , data ) ;
14
+ this . user = data ;
25
15
} ,
26
16
} ,
27
17
} ) ;
Original file line number Diff line number Diff line change 23
23
"@vitejs/plugin-vue" : " ^4.2.3" ,
24
24
"axios" : " ^1.4.0" ,
25
25
"core-js" : " ^3.29.0" ,
26
+ "pinia" : " ^2.1.7" ,
26
27
"roboto-fontface" : " *" ,
27
28
"vue" : " ^3.2.0" ,
28
29
"vue-axios" : " ^3.5.2" ,
You can’t perform that action at this time.
0 commit comments