mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-04 01:15:19 -05:00
nuxt init
This commit is contained in:
74
frontend.old/src/routes/admin.js
Normal file
74
frontend.old/src/routes/admin.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const Admin = () => import(/* webpackChunkName: "admin-pages" */ "@/pages/Admin");
|
||||
const Migration = () => import(/* webpackChunkName: "admin-pages" */ "@/pages/Admin/Migration");
|
||||
const Profile = () => import(/* webpackChunkName: "admin-pages" */ "@/pages/Admin/Profile");
|
||||
const ManageUsers = () => import(/* webpackChunkName: "admin-pages" */ "@/pages/Admin/ManageUsers");
|
||||
const Settings = () => import(/* webpackChunkName: "admin-pages" */ "@/pages/Admin/Settings");
|
||||
const About = () => import(/* webpackChunkName: "admin-pages" */ "@/pages/Admin/About");
|
||||
const ToolBox = () => import(/* webpackChunkName: "admin-pages" */ "@/pages/Admin/ToolBox");
|
||||
const Dashboard = () => import(/* webpackChunkName: "admin-pages" */ "@/pages/Admin/Dashboard");
|
||||
import { store } from "../store";
|
||||
|
||||
export const adminRoutes = {
|
||||
path: "/admin",
|
||||
component: Admin,
|
||||
beforeEnter: (to, _from, next) => {
|
||||
if (store.getters.getIsLoggedIn) {
|
||||
next();
|
||||
} else next({ path: "/login", query: { redirect: to.fullPath } });
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
component: Profile,
|
||||
},
|
||||
{
|
||||
path: "profile",
|
||||
component: Profile,
|
||||
meta: {
|
||||
title: "settings.profile",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "migrations",
|
||||
component: Migration,
|
||||
meta: {
|
||||
title: "settings.migrations",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "manage-users",
|
||||
component: ManageUsers,
|
||||
meta: {
|
||||
title: "user.manage-users",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "settings",
|
||||
component: Settings,
|
||||
meta: {
|
||||
title: "settings.site-settings",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "toolbox",
|
||||
component: ToolBox,
|
||||
meta: {
|
||||
title: "settings.toolbox.toolbox",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "about",
|
||||
component: About,
|
||||
meta: {
|
||||
title: "about.about",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "dashboard",
|
||||
component: Dashboard,
|
||||
meta: {
|
||||
title: "general.dashboard",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
18
frontend.old/src/routes/auth.js
Normal file
18
frontend.old/src/routes/auth.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const LoginPage = () => import("@/pages/LoginPage");
|
||||
const SignUpPage = () => import("@/pages/SignUpPage");
|
||||
import { store } from "../store";
|
||||
|
||||
export const authRoutes = [
|
||||
{
|
||||
path: "/logout",
|
||||
beforeEnter: (_to, _from, next) => {
|
||||
store.commit("setToken", "");
|
||||
store.commit("setIsLoggedIn", false);
|
||||
next("/");
|
||||
},
|
||||
},
|
||||
{ path: "/login", component: LoginPage },
|
||||
|
||||
{ path: "/sign-up", redirect: "/" },
|
||||
{ path: "/sign-up/:token", component: SignUpPage },
|
||||
];
|
||||
16
frontend.old/src/routes/general.js
Normal file
16
frontend.old/src/routes/general.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const SearchPage = () => import("@/pages/SearchPage");
|
||||
const ShoppingList = () => import("@/pages/ShoppingList");
|
||||
import HomePage from "@/pages/HomePage";
|
||||
|
||||
export const generalRoutes = [
|
||||
{ path: "/", name: "home", component: HomePage },
|
||||
{ path: "/mealie", component: HomePage },
|
||||
{ path: "/shopping-list", component: ShoppingList },
|
||||
{
|
||||
path: "/search",
|
||||
component: SearchPage,
|
||||
meta: {
|
||||
title: "search.search",
|
||||
},
|
||||
},
|
||||
];
|
||||
51
frontend.old/src/routes/index.js
Normal file
51
frontend.old/src/routes/index.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import Page404 from "@/pages/404Page";
|
||||
import { adminRoutes } from "./admin";
|
||||
import { authRoutes } from "./auth";
|
||||
import { recipeRoutes } from "./recipes";
|
||||
import { mealRoutes } from "./meal";
|
||||
import { generalRoutes } from "./general";
|
||||
import { store } from "@/store";
|
||||
import VueRouter from "vue-router";
|
||||
import { loadLanguageAsync } from "@/i18n";
|
||||
import Vue from "vue";
|
||||
import i18n from "@/i18n.js";
|
||||
|
||||
export const routes = [
|
||||
...generalRoutes,
|
||||
adminRoutes,
|
||||
...authRoutes,
|
||||
...mealRoutes,
|
||||
...recipeRoutes,
|
||||
|
||||
{ path: "/page-not-found", component: Page404 },
|
||||
{ path: "*", component: Page404 },
|
||||
];
|
||||
|
||||
const router = new VueRouter({
|
||||
base: process.env.BASE_URL,
|
||||
routes,
|
||||
mode: process.env.NODE_ENV === "production" ? "history" : "hash",
|
||||
scrollBehavior() {
|
||||
return { x: 0, y: 0 };
|
||||
},
|
||||
});
|
||||
|
||||
const DEFAULT_TITLE = "Mealie";
|
||||
const TITLE_SEPARATOR = "|";
|
||||
const TITLE_SUFFIX = " " + TITLE_SEPARATOR + " " + DEFAULT_TITLE;
|
||||
router.afterEach(to => {
|
||||
Vue.nextTick(async () => {
|
||||
if (typeof to.meta.title === "function") {
|
||||
const title = await to.meta.title(to);
|
||||
document.title = title + TITLE_SUFFIX;
|
||||
} else {
|
||||
document.title = i18n.t(to.meta.title) ? i18n.t(to.meta.title) + TITLE_SUFFIX : DEFAULT_TITLE;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
router.beforeEach((__, _, next) => {
|
||||
loadLanguageAsync(store.getters.getActiveLang).then(() => next());
|
||||
});
|
||||
|
||||
export { router };
|
||||
51
frontend.old/src/routes/meal.js
Normal file
51
frontend.old/src/routes/meal.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const Planner = () => import("@/pages/MealPlan/Planner");
|
||||
const ThisWeek = () => import("@/pages/MealPlan/ThisWeek");
|
||||
import { api } from "@/api";
|
||||
import { utils } from "@/utils";
|
||||
import i18n from "@/i18n.js";
|
||||
|
||||
export const mealRoutes = [
|
||||
{
|
||||
path: "/meal-plan",
|
||||
component: ThisWeek,
|
||||
meta: {
|
||||
title: "meal-plan.dinner-this-week",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/meal-plan/planner",
|
||||
component: Planner,
|
||||
meta: {
|
||||
title: "meal-plan.meal-planner",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/meal-plan/this-week",
|
||||
component: ThisWeek,
|
||||
meta: {
|
||||
title: "meal-plan.dinner-this-week",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/meal-plan/today",
|
||||
beforeEnter: async (_to, _from, next) => {
|
||||
await todaysMealRoute().then(redirect => {
|
||||
if (redirect) {
|
||||
next(redirect);
|
||||
} else {
|
||||
utils.notify.error(i18n.t("meal-plan.no-meal-planned-for-today"));
|
||||
next(_from);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
async function todaysMealRoute() {
|
||||
const response = await api.mealPlans.today();
|
||||
if (response.status == 200 && response.data) {
|
||||
return "/recipe/" + response.data.slug;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
37
frontend.old/src/routes/recipes.js
Normal file
37
frontend.old/src/routes/recipes.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const ViewRecipe = () => import(/* webpackChunkName: "recipe-page" */ "@/pages/Recipe/ViewRecipe");
|
||||
const NewRecipe = () => import(/* webpackChunkName: "recipe-page" */ "@/pages/Recipe/NewRecipe");
|
||||
const ScraperDebugger = () => import("@/pages/Recipe/ScraperDebugger");
|
||||
const CustomPage = () => import("@/pages/Recipes/CustomPage");
|
||||
const AllRecipes = () => import("@/pages/Recipes/AllRecipes");
|
||||
const CategoryTagPage = () => import("@/pages/Recipes/CategoryTagPage");
|
||||
const Favorites = () => import("@/pages/Recipes/Favorites");
|
||||
import { api } from "@/api";
|
||||
|
||||
export const recipeRoutes = [
|
||||
// Recipes
|
||||
{ path: "/recipes/all", component: AllRecipes },
|
||||
{ path: "/recipes/debugger", component: ScraperDebugger },
|
||||
{ path: "/user/:id/favorites", component: Favorites },
|
||||
{ path: "/recipes/tag/:tag", component: CategoryTagPage },
|
||||
{ path: "/recipes/tag", component: CategoryTagPage },
|
||||
{ path: "/recipes/category", component: CategoryTagPage },
|
||||
{ path: "/recipes/category/:category", component: CategoryTagPage },
|
||||
// Misc
|
||||
{ path: "/new/", component: NewRecipe },
|
||||
{ path: "/pages/:customPage", component: CustomPage },
|
||||
|
||||
// Recipe Page
|
||||
{
|
||||
path: "/recipe/:recipe",
|
||||
component: ViewRecipe,
|
||||
meta: {
|
||||
title: async route => {
|
||||
const [response, error] = await api.recipes.requestDetails(route.params.recipe);
|
||||
if (error) console.log({ error });
|
||||
const recipe = response.data;
|
||||
if (recipe && recipe.name) return recipe.name;
|
||||
else return null;
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user