2024-09-28 20:58:25 -05:00
|
|
|
import { createRouter, createWebHashHistory } from "vue-router";
|
|
|
|
import { nextTick } from "vue";
|
2018-03-29 01:57:00 -05:00
|
|
|
|
2022-12-01 20:13:53 -06:00
|
|
|
import The404Page from '../components/The404Page';
|
|
|
|
import TheAboutPage from '../components/TheAboutPage';
|
|
|
|
import TheCalculator from '../components/TheCalculator';
|
2018-04-13 10:25:18 -05:00
|
|
|
|
2022-12-01 20:13:53 -06:00
|
|
|
import TheLog from '../components/TheLog';
|
|
|
|
import TheLogList from '../components/TheLogList';
|
|
|
|
import TheLogCreator from '../components/TheLogCreator';
|
|
|
|
import TheLogEditor from '../components/TheLogEditor';
|
2018-04-13 10:25:18 -05:00
|
|
|
|
2022-12-01 20:13:53 -06:00
|
|
|
import TheFoodList from '../components/TheFoodList';
|
|
|
|
import TheFood from "../components/TheFood";
|
|
|
|
import TheFoodEditor from "../components/TheFoodEditor";
|
|
|
|
import TheFoodCreator from "../components/TheFoodCreator";
|
|
|
|
import TheNotesList from '../components/TheNotesList';
|
|
|
|
import TheRecipe from '../components/TheRecipe';
|
|
|
|
import TheRecipeEditor from '../components/TheRecipeEditor';
|
|
|
|
import TheRecipeCreator from '../components/TheRecipeCreator';
|
|
|
|
import TheRecipeList from '../components/TheRecipeList';
|
2018-03-29 01:57:00 -05:00
|
|
|
|
2022-12-01 20:13:53 -06:00
|
|
|
import TheTaskListList from '../components/TheTaskListList';
|
2018-08-28 10:39:11 -05:00
|
|
|
|
2022-12-01 20:13:53 -06:00
|
|
|
import TheUserCreator from '../components/TheUserCreator';
|
|
|
|
import TheUserEditor from '../components/TheUserEditor';
|
2018-06-09 12:36:46 -05:00
|
|
|
|
2022-12-01 20:13:53 -06:00
|
|
|
import TheAdminUserList from '../components/TheAdminUserList';
|
|
|
|
import TheAdminUserEditor from '../components/TheAdminUserEditor';
|
2018-06-09 12:36:46 -05:00
|
|
|
|
2024-09-28 20:58:25 -05:00
|
|
|
import { useAppConfigStore } from "../stores/appConfig";
|
2019-11-10 10:40:26 -06:00
|
|
|
|
2018-03-29 01:57:00 -05:00
|
|
|
|
2024-09-28 20:58:25 -05:00
|
|
|
const router = createRouter({
|
|
|
|
history: createWebHashHistory(),
|
|
|
|
routes: [
|
2018-03-29 01:57:00 -05:00
|
|
|
{
|
|
|
|
path: '/',
|
2018-04-01 21:43:23 -05:00
|
|
|
redirect: '/recipes'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/recipes',
|
2018-03-29 01:57:00 -05:00
|
|
|
name: 'recipeList',
|
2019-11-10 10:40:26 -06:00
|
|
|
component: TheRecipeList,
|
2020-08-06 20:26:45 -05:00
|
|
|
props: route => ({
|
|
|
|
searchQuery: {
|
|
|
|
name: route.query.name,
|
|
|
|
tags: route.query.tags,
|
|
|
|
column: route.query.column,
|
|
|
|
direction: route.query.direction,
|
|
|
|
page: route.query.page,
|
|
|
|
per: route.query.per
|
|
|
|
}
|
|
|
|
}),
|
2019-11-10 10:40:26 -06:00
|
|
|
meta: {
|
|
|
|
handleInitialLoad: true
|
|
|
|
}
|
2018-03-29 01:57:00 -05:00
|
|
|
},
|
2018-04-01 21:43:23 -05:00
|
|
|
{
|
|
|
|
path: '/recipes/new',
|
|
|
|
name: 'new_recipe',
|
|
|
|
component: TheRecipeCreator
|
|
|
|
},
|
2018-03-30 14:31:09 -05:00
|
|
|
{
|
|
|
|
path: '/recipes/:id/edit',
|
|
|
|
name: 'edit_recipe',
|
2018-04-01 21:43:23 -05:00
|
|
|
component: TheRecipeEditor
|
2018-03-30 14:31:09 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/recipe/:id',
|
|
|
|
name: 'recipe',
|
2018-04-01 21:43:23 -05:00
|
|
|
component: TheRecipe
|
2018-03-30 14:31:09 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/about",
|
|
|
|
name: "about",
|
|
|
|
component: TheAboutPage
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/calculator",
|
|
|
|
name: "calculator",
|
|
|
|
component: TheCalculator
|
|
|
|
},
|
|
|
|
{
|
2018-09-11 22:56:26 -05:00
|
|
|
path: "/foods",
|
|
|
|
name: "foods",
|
|
|
|
component: TheFoodList
|
2018-03-30 14:31:09 -05:00
|
|
|
},
|
2018-04-02 00:10:06 -05:00
|
|
|
{
|
2018-09-11 22:56:26 -05:00
|
|
|
path: "/foods/new",
|
|
|
|
name: "new_food",
|
|
|
|
component: TheFoodCreator
|
2018-04-02 00:10:06 -05:00
|
|
|
},
|
|
|
|
{
|
2018-09-11 22:56:26 -05:00
|
|
|
path: "/foods/:id/edit",
|
|
|
|
name: "edit_food",
|
|
|
|
component: TheFoodEditor
|
2018-04-02 00:10:06 -05:00
|
|
|
},
|
|
|
|
{
|
2018-09-11 22:56:26 -05:00
|
|
|
path: "/foods/:id",
|
|
|
|
name: "food",
|
|
|
|
component: TheFood
|
2018-04-02 00:10:06 -05:00
|
|
|
},
|
2018-04-13 10:25:18 -05:00
|
|
|
{
|
|
|
|
path: "/logs",
|
|
|
|
name: "logs",
|
|
|
|
component: TheLogList
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/recipes/:recipeId/logs/new",
|
|
|
|
name: "new_log",
|
|
|
|
component: TheLogCreator
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/logs/:id/edit",
|
|
|
|
name: "edit_log",
|
|
|
|
component: TheLogEditor
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/logs/:id",
|
|
|
|
name: "log",
|
|
|
|
component: TheLog
|
|
|
|
},
|
2018-03-30 14:31:09 -05:00
|
|
|
{
|
|
|
|
path: "/notes",
|
|
|
|
name: "notes",
|
|
|
|
component: TheNotesList
|
|
|
|
},
|
2018-08-28 10:39:11 -05:00
|
|
|
{
|
|
|
|
path: "/tasks",
|
|
|
|
name: "task_lists",
|
|
|
|
component: TheTaskListList
|
|
|
|
},
|
2018-04-01 12:17:54 -05:00
|
|
|
{
|
|
|
|
path: "/logout",
|
|
|
|
name: "logout",
|
2024-09-28 20:58:25 -05:00
|
|
|
beforeEnter: async (to, from, next) => {
|
|
|
|
const appConfig = useAppConfigStore();
|
|
|
|
await appConfig.logout();
|
|
|
|
return next("/");
|
2018-04-01 12:17:54 -05:00
|
|
|
}
|
|
|
|
},
|
2018-06-09 12:36:46 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
path: "/user/new",
|
|
|
|
name: "new_user",
|
|
|
|
component: TheUserCreator
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/user/edit",
|
|
|
|
name: "edit_user",
|
|
|
|
component: TheUserEditor
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
path: "/admin/users",
|
|
|
|
name: "admin_users",
|
|
|
|
component: TheAdminUserList
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
path: "/admin/users/:id/edit",
|
|
|
|
name: "admin_edit_user",
|
|
|
|
component: TheAdminUserEditor
|
|
|
|
},
|
|
|
|
|
2018-03-29 01:57:00 -05:00
|
|
|
{
|
2024-09-28 20:58:25 -05:00
|
|
|
path: '/:pathMatch(.*)*',
|
|
|
|
name: 'NotFound',
|
2018-03-29 01:57:00 -05:00
|
|
|
component: The404Page
|
|
|
|
}
|
|
|
|
]
|
2024-09-28 20:58:25 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
router.afterEach((to, from) => {
|
|
|
|
const appConfigStore = useAppConfigStore();
|
|
|
|
if (to.meta.handleInitialLoad !== true && appConfigStore.initialLoad === false) {
|
|
|
|
appConfigStore.initialLoad = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
document.title = to.meta.title || 'Parsley';
|
|
|
|
});
|
|
|
|
});
|
2018-04-01 12:17:54 -05:00
|
|
|
|
|
|
|
export default router;
|