chet novoe
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {createRouter, createWebHistory, useRoute} from 'vue-router';
|
||||
import {createRouter, createWebHistory} from 'vue-router';
|
||||
import CategoriesList from '@/components/settings/categories/CategoriesList.vue';
|
||||
import CreateCategoryModal from "@/components/settings/categories/CreateCategoryModal.vue";
|
||||
import CategoryListItem from "@/components/settings/categories/CategoryListItem.vue"; // Импортируем новый компонент
|
||||
@@ -10,18 +10,33 @@ import TransactionList from "@/components/transactions/TransactionList.vue";
|
||||
import LoginView from "@/components/auth/LoginView.vue";
|
||||
|
||||
const routes = [
|
||||
|
||||
{path: '/', name: 'Budgets main', component: BudgetList, meta: { requiresAuth: true }},
|
||||
{ path: '/login', component: LoginView },
|
||||
{path: '/budgets', name: 'Budgets', component: BudgetList, meta: { requiresAuth: true }},
|
||||
{path: '/budgets/:id', name: 'BudgetView', component: BudgetView, meta: { requiresAuth: true }},
|
||||
{path: '/transactions/:mode*', name: 'Transaction List', component: TransactionList, meta: { requiresAuth: true }},
|
||||
{path: '/login', component: LoginView},
|
||||
{path: '/', name: 'Budgets main', component: BudgetList, meta: {requiresAuth: true}},
|
||||
{path: '/analytics', name: 'Analytics', component: BudgetList, meta: {requiresAuth: true}},
|
||||
{path: '/budgets', name: 'Budgets', component: BudgetList, meta: {requiresAuth: true}},
|
||||
{path: '/budgets/:id', name: 'BudgetView', component: BudgetView, meta: {requiresAuth: true}},
|
||||
{path: '/transactions/:mode*', name: 'Transaction List', component: TransactionList, meta: {requiresAuth: true}},
|
||||
// {path: '/transactions/create', name: 'Transaction List', component: TransactionList},
|
||||
{path: '/settings/', name: 'Settings', component: SettingsView, meta: { requiresAuth: true }},
|
||||
{path: '/settings/categories', name: 'Categories', component: CategoriesList, meta: { requiresAuth: true }},
|
||||
{path: '/settings/recurrents', name: 'Recurrent operations list', component: RecurrentList, meta: { requiresAuth: true }},
|
||||
{path: '/settings/categories/create', name: "Categories Creation", component: CreateCategoryModal, meta: { requiresAuth: true }},// Добавляем новый маршрут
|
||||
{path: '/settings/categories/one', name: "Categories Creation", component: CategoryListItem, meta: { requiresAuth: true }}// Добавляем новый маршрут
|
||||
{path: '/settings/', name: 'Settings', component: SettingsView, meta: {requiresAuth: true}},
|
||||
{path: '/settings/categories', name: 'Categories', component: CategoriesList, meta: {requiresAuth: true}},
|
||||
{
|
||||
path: '/settings/recurrents',
|
||||
name: 'Recurrent operations list',
|
||||
component: RecurrentList,
|
||||
meta: {requiresAuth: true}
|
||||
},
|
||||
{
|
||||
path: '/settings/categories/create',
|
||||
name: "Categories Creation",
|
||||
component: CreateCategoryModal,
|
||||
meta: {requiresAuth: true}
|
||||
},// Добавляем новый маршрут
|
||||
{
|
||||
path: '/settings/categories/one',
|
||||
name: "Categories Creation",
|
||||
component: CategoryListItem,
|
||||
meta: {requiresAuth: true}
|
||||
}// Добавляем новый маршрут
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
@@ -32,11 +47,8 @@ const router = createRouter({
|
||||
router.beforeEach((to, from, next) => {
|
||||
const token = localStorage.getItem('token');
|
||||
if (to.meta.requiresAuth && !token) {
|
||||
const router= useRoute()
|
||||
console.log(to)
|
||||
console.log(router.path)
|
||||
console.log(router.params)
|
||||
next('/login?back='+to.fullPath);
|
||||
// const router = useRoute()
|
||||
next('/login?back=' + to.fullPath);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user