// router.js
import store from './store';
router.beforeEach((to, from, next) => {
if (!store.getters.token) {
next({ path: '/login' });
} else {
next();
}
});
// store
const state = {
token: localStorage.getItem('token'),
};
const getters = {
token(state) {
return state.token;
},
};