27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
import {createMemoryHistory, createRouter} from 'vue-router';
|
|
import Home from './views/Home.vue';
|
|
import Product from './views/Product.vue';
|
|
import CategoriesList from "./views/CategoriesList.vue";
|
|
import ProductsList from "./views/ProductsList.vue";
|
|
import Cart from "./views/Cart.vue";
|
|
|
|
const routes = [
|
|
{path: '/', name: 'home', component: Home},
|
|
{path: '/product/:id', name: 'product.show', component: Product},
|
|
{path: '/categories', name: 'categories', component: CategoriesList},
|
|
{path: '/category/:id', name: 'category.show', component: ProductsList},
|
|
{path: '/cart', name: 'cart.show', component: Cart},
|
|
];
|
|
|
|
export const router = createRouter({
|
|
history: createMemoryHistory('/image/catalog/tgshopspa/'),
|
|
routes,
|
|
scrollBehavior(to, from, savedPosition) {
|
|
if (savedPosition) {
|
|
return savedPosition; // Восстановить позицию прокрутки
|
|
} else {
|
|
return { top: 0 }; // Или оставить на старте
|
|
}
|
|
}
|
|
});
|