1- import Vue from 'vue' ;
2- import VueRouter from 'vue-router' ;
1+ import { createRouter , createWebHistory } from 'vue-router' ;
32
43import store from '@/store' ;
54
@@ -11,8 +10,6 @@ import Note from '@/views/Note';
1110import Profile from '@/views/Profile' ;
1211import Register from '@/views/Register' ;
1312
14- Vue . use ( VueRouter ) ;
15-
1613const routes = [
1714 {
1815 path : '/' ,
@@ -33,37 +30,36 @@ const routes = [
3330 path : '/dashboard' ,
3431 name : 'Dashboard' ,
3532 component : Dashboard ,
36- meta : { requiresAuth : true } ,
33+ meta : { requiresAuth : true } ,
3734 } ,
3835 {
3936 path : '/profile' ,
4037 name : 'Profile' ,
4138 component : Profile ,
42- meta : { requiresAuth : true } ,
39+ meta : { requiresAuth : true } ,
4340 } ,
4441 {
4542 path : '/note/:id' ,
4643 name : 'Note' ,
4744 component : Note ,
48- meta : { requiresAuth : true } ,
45+ meta : { requiresAuth : true } ,
4946 props : true ,
5047 } ,
5148 {
5249 path : '/editnote/:id' ,
5350 name : 'EditNote' ,
5451 component : EditNote ,
55- meta : { requiresAuth : true } ,
52+ meta : { requiresAuth : true } ,
5653 props : true ,
5754 }
5855]
5956
60- const router = new VueRouter ( {
61- mode : 'history' ,
62- base : process . env . BASE_URL ,
57+ const router = createRouter ( {
58+ history : createWebHistory ( process . env . BASE_URL ) ,
6359 routes,
6460} ) ;
6561
66- router . beforeEach ( ( to , from , next ) => {
62+ router . beforeEach ( ( to , _ , next ) => {
6763 if ( to . matched . some ( record => record . meta . requiresAuth ) ) {
6864 if ( store . getters . isAuthenticated ) {
6965 next ( ) ;
0 commit comments