File tree Expand file tree Collapse file tree 6 files changed +72
-45
lines changed
Expand file tree Collapse file tree 6 files changed +72
-45
lines changed Original file line number Diff line number Diff line change 11# Credits
22
3- * Background Created by Quinky - Freepik.com https://www.freepik.com/free-photos-vectors/background
43* UI by Enrico Deleo https://enricodeleo.com
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ export default {
4444 padding : 0 ;
4545 margin : 0 ;
4646 background-color : #f8f9f9 ;
47+ overflow-x : hidden ;
4748 }
4849
4950 body {
@@ -83,5 +84,4 @@ export default {
8384 .header-main {
8485 margin-bottom : 20px ;
8586 }
86-
8787 </style >
Original file line number Diff line number Diff line change 11// main.js
22import Vue from 'vue' ;
3- import App from './App.vue' ;
4- import VueRouter from 'vue-router' ;
5-
6- import { store } from './store' ;
7- import IndexPage from './pages/Index' ;
8- import LoginPage from './pages/Login' ;
9-
10- const router = new VueRouter ( {
11- routes : [
12- {
13- path : '/' ,
14- name : 'index' ,
15- component : IndexPage ,
16- } ,
17- {
18- path : '/login' ,
19- name : 'login' ,
20- component : LoginPage ,
21- } ,
22- ]
23- } ) ;
243
25- Vue . use ( VueRouter ) ;
4+ import App from './App.vue' ;
5+ import router from './router' ;
6+ import store from './store' ;
267
278new Vue ( {
289 el : '#app' ,
2910 render : h => h ( App ) ,
3011 router,
3112 store,
32- } ) ;
13+ } ) ;
Original file line number Diff line number Diff line change 11// Index.vue
22<template >
33 <div class =" container" >
4- < img src = " https://images.pexels.com/photos/1759406/pexels-photo-1759406.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260 " >
4+ Pagina profilo
55 </div >
66</template >
77
Original file line number Diff line number Diff line change @@ -5,18 +5,46 @@ Vue.use(Vuex);
55
66const user = {
77 state : {
8+ id : null ,
9+ registeredAt : null ,
10+ avatar : null ,
11+ name : null ,
812 email : null ,
9- password : null ,
13+ accessToken : null ,
1014 } ,
11- mutations : { } ,
12- actions : { } ,
13- getters : { }
14- }
15+ mutations : {
16+ updateUser : ( state , data ) => {
17+ state = data ;
18+ } ,
19+ logout : ( state ) => {
20+ state . accessToken = null ;
21+ } ,
22+ } ,
23+ actions : {
24+ async doLogin ( { commit } , loginData ) {
25+ const rawResponse = await fetch ( 'https://5dfd619831f32a0014c82843.mockapi.io/login' , {
26+ method : 'POST' ,
27+ headers : {
28+ 'Accept' : 'application/json' ,
29+ 'Content-Type' : 'application/json'
30+ } ,
31+ body : JSON . stringify ( loginData ) ,
32+ } ) ;
33+ const response = await rawResponse . json ( ) ;
34+ commit ( 'updateUser' , response ) ;
35+ } ,
36+
37+ doLogout ( { commit } ) {
38+ commit ( 'logout' ) ;
39+ }
40+ } ,
41+ getters : { } ,
42+ } ;
1543
1644const store = new Vuex . Store ( {
1745 modules : {
1846 user,
19- }
20- } )
47+ } ,
48+ } ) ;
2149
22- export { store }
50+ export default store ;
You can’t perform that action at this time.
0 commit comments