kleine änderung/anpassungen, login zwang, messages hinzugefügt,

This commit is contained in:
danielvici123
2025-03-22 12:51:56 +01:00
parent 7331b1b9b0
commit 932edc5a2b
25 changed files with 938 additions and 472 deletions

View File

@@ -1,8 +1,5 @@
// File: `src/router/index.ts`
import { createRouter, createWebHistory } from "vue-router";
// Vue components imported here.
// the vue components are the Pages that will be rendered
// at these URL's.
import Home from "../components/Home.vue";
import Login from "../components/Login.vue";
import wip from "../components/wip.vue";
@@ -10,63 +7,86 @@ import settings from "../components/settings.vue";
import notifications from "../components/notifications.vue";
import register from "../components/register.vue";
import search from "../components/search.vue";
import post from '../components/posts.vue';
import post from "../components/posts.vue";
import profile from "../components/profile.vue";
// The routing does not happen automatically
// Each route has to be defined here, or it won't work.
import messages from "../components/messages.vue";
const routes = [
{
path: "/",
name: "home",
component: Home,
meta: { requiresAuth: true }
},
{
path: "/login",
name: "login",
component: Login,
component: Login
},
{
path: "/wip",
name: "Work in Progress",
component: wip,
meta: { requiresAuth: true }
},
{
path: "/settings",
name: "Settings",
component: settings,
meta: { requiresAuth: true }
},
{
path: "/notifications",
name: "Notifications",
component: notifications,
meta: { requiresAuth: true }
},
{
path: "/register",
name: "Register",
component: register,
component: register
},
{
path: "/search",
name: "Search",
component: search,
meta: { requiresAuth: true }
},
{
path: '/post/:id',
name: 'PostDetail',
path: "/post/:id",
name: "PostDetail",
component: post,
props: true
props: true,
meta: { requiresAuth: true }
},
{
path: '/profile/:username',
name: 'Profile ',
path: "/profile/:username",
name: "Profile",
component: profile,
props: true
props: true,
meta: { requiresAuth: true }
},
{
path: "/messages",
name: "Messages",
component: messages,
meta: { requiresAuth: true }
}
]
];
const router = createRouter({
history: createWebHistory("/"),
routes,
});
router.beforeEach((to, from, next) => {
if (to.meta.requiresAuth && localStorage.getItem("isLoggedIn") !== "true") {
console.log("User not logged in: redirecting to login.");
next({ name: "login" });
} else {
console.log("User logged in or no auth required.");
next();
}
});
export default router;