pleroma-fe/src/boot/routes.js

314 lines
9 KiB
JavaScript
Raw Normal View History

2026-06-03 02:19:25 +03:00
import { defineAsyncComponent } from 'vue'
2026-07-10 12:41:11 +03:00
import AuthForm from 'src/components/auth_form/auth_form.js'
import BookmarkTimeline from 'src/components/bookmark_timeline/bookmark_timeline.vue'
import BubbleTimeline from 'src/components/bubble_timeline/bubble_timeline.vue'
import ConversationPage from 'src/components/conversation-page/conversation-page.vue'
import DMs from 'src/components/dm_timeline/dm_timeline.vue'
import FriendsTimeline from 'src/components/friends_timeline/friends_timeline.vue'
2026-06-03 02:19:25 +03:00
import NavPanel from 'src/components/nav_panel/nav_panel.vue'
import PublicAndExternalTimeline from 'src/components/public_and_external_timeline/public_and_external_timeline.vue'
import PublicTimeline from 'src/components/public_timeline/public_timeline.vue'
2026-06-03 02:19:25 +03:00
import QuotesTimeline from 'src/components/quotes_timeline/quotes_timeline.vue'
import RemoteUserResolver from 'src/components/remote_user_resolver/remote_user_resolver.vue'
import TagTimeline from 'src/components/tag_timeline/tag_timeline.vue'
2026-01-29 20:40:00 +02:00
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
2026-01-29 20:40:00 +02:00
export default (store) => {
const validateAuthenticatedRoute = (to, from, next) => {
if (store.state.users.currentUser) {
next()
} else {
2026-01-29 15:11:47 +02:00
next(
useInstanceStore().instanceIdentity.redirectRootNoLogin || '/main/all',
)
}
}
2020-05-07 16:10:53 +03:00
let routes = [
2022-07-31 12:35:48 +03:00
{
name: 'root',
path: '/',
2025-02-04 15:23:21 +02:00
redirect: () => {
2026-01-06 16:22:52 +02:00
return (
(store.state.users.currentUser
2026-01-29 15:07:00 +02:00
? useInstanceStore().instanceIdentity.redirectRootLogin
2026-01-29 15:11:47 +02:00
: useInstanceStore().instanceIdentity.redirectRootNoLogin) ||
'/main/all'
2026-01-06 16:22:52 +02:00
)
},
},
{
name: 'public-external-timeline',
path: '/main/all',
component: PublicAndExternalTimeline,
},
{
name: 'public-timeline',
path: '/main/public',
component: PublicTimeline,
},
{
name: 'friends',
path: '/main/friends',
component: FriendsTimeline,
beforeEnter: validateAuthenticatedRoute,
},
{ name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline },
{ name: 'bookmarks', path: '/bookmarks', component: BookmarkTimeline },
2025-06-18 17:48:11 +03:00
{ name: 'bubble', path: '/bubble', component: BubbleTimeline },
2026-01-06 16:22:52 +02:00
{
name: 'conversation',
path: '/notice/:id',
component: ConversationPage,
meta: { dontScroll: true },
},
{ name: 'quotes', path: '/notice/:id/quotes', component: QuotesTimeline },
2022-07-31 12:35:48 +03:00
{
name: 'remote-user-profile-acct',
2022-03-22 19:20:12 +02:00
path: '/remote-users/:_(@)?:username([^/@]+)@:hostname([^/@]+)',
component: RemoteUserResolver,
2026-01-06 16:22:52 +02:00
beforeEnter: validateAuthenticatedRoute,
},
2022-07-31 12:35:48 +03:00
{
name: 'remote-user-profile',
path: '/remote-users/:hostname/:username',
component: RemoteUserResolver,
2026-01-06 16:22:52 +02:00
beforeEnter: validateAuthenticatedRoute,
},
{
name: 'external-user-profile',
path: '/users/$:id',
2026-06-02 18:09:12 +03:00
component: defineAsyncComponent(
() => import('src/components/user_profile/user_profile.vue'),
),
2026-01-06 16:22:52 +02:00
},
2026-06-10 15:49:51 +03:00
{
name: 'user-profile-admin-view',
2026-06-10 17:38:31 +03:00
path: '/users/$:id/admin_view',
2026-06-10 15:49:51 +03:00
component: defineAsyncComponent(
() => import('src/components/user_profile/user_profile_admin_view.vue'),
),
},
2026-01-06 16:22:52 +02:00
{
name: 'interactions',
path: '/users/:username/interactions',
2026-06-02 18:09:12 +03:00
component: defineAsyncComponent(
() => import('src/components/interactions/interactions.vue'),
),
2026-01-06 16:22:52 +02:00
beforeEnter: validateAuthenticatedRoute,
},
{
name: 'dms',
path: '/users/:username/dms',
component: DMs,
beforeEnter: validateAuthenticatedRoute,
},
{
name: 'registration',
path: '/registration',
component: defineAsyncComponent(
() => import('src/components/registration/registration.vue'),
),
},
2026-01-06 16:22:52 +02:00
{
name: 'password-reset',
path: '/password-reset',
component: defineAsyncComponent(
() => import('src/components/password_reset/password_reset.vue'),
),
2026-01-06 16:22:52 +02:00
props: true,
},
{
name: 'registration-token',
path: '/registration/:token',
component: defineAsyncComponent(
() => import('src/components/registration/registration.vue'),
),
2026-01-06 16:22:52 +02:00
},
{
name: 'friend-requests',
path: '/friend-requests',
component: defineAsyncComponent(
() => import('src/components/follow_requests/follow_requests.vue'),
),
2026-01-06 16:22:52 +02:00
beforeEnter: validateAuthenticatedRoute,
},
{
name: 'notifications',
path: '/:username/notifications',
2026-06-02 18:09:12 +03:00
component: defineAsyncComponent(
() => import('src/components/notifications/notifications.vue'),
),
2026-01-06 16:22:52 +02:00
props: () => ({ disableTeleport: true }),
beforeEnter: validateAuthenticatedRoute,
},
{
name: 'login',
path: '/login',
2026-07-10 12:35:29 +03:00
component: AuthForm,
},
2026-01-06 16:22:52 +02:00
{
name: 'shout-panel',
path: '/shout-panel',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/shout_panel/shout_panel.vue'),
),
2026-01-06 16:22:52 +02:00
props: () => ({ floating: false }),
},
{
name: 'oauth-callback',
path: '/oauth-callback',
component: defineAsyncComponent(
() => import('src/components/oauth_callback/oauth_callback.vue'),
),
2026-01-06 16:22:52 +02:00
props: (route) => ({ code: route.query.code }),
},
{
name: 'search',
path: '/search',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/search/search.vue'),
),
2026-01-06 16:22:52 +02:00
props: (route) => ({ query: route.query.query }),
},
{
name: 'who-to-follow',
path: '/who-to-follow',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/who_to_follow/who_to_follow.vue'),
),
2026-01-06 16:22:52 +02:00
beforeEnter: validateAuthenticatedRoute,
},
2026-06-02 20:14:47 +03:00
{
name: 'about',
path: '/about',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/about/about.vue'),
2026-06-02 20:14:47 +03:00
),
},
2026-01-06 16:22:52 +02:00
{
name: 'announcements',
path: '/announcements',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() =>
import('src/components/announcements_page/announcements_page.vue'),
),
},
{
name: 'drafts',
path: '/drafts',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/drafts/drafts.vue'),
),
2026-01-06 16:22:52 +02:00
},
2026-06-02 18:09:12 +03:00
{
name: 'user-profile',
path: '/users/:name',
component: defineAsyncComponent(
() => import('src/components/user_profile/user_profile.vue'),
),
},
{
name: 'legacy-user-profile',
path: '/:name',
component: defineAsyncComponent(
() => import('src/components/user_profile/user_profile.vue'),
),
},
{
name: 'lists',
path: '/lists',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/lists/lists.vue'),
),
},
{
name: 'lists-timeline',
path: '/lists/:id',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/lists_timeline/lists_timeline.vue'),
),
},
{
name: 'lists-edit',
path: '/lists/:id/edit',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/lists_edit/lists_edit.vue'),
),
},
{
name: 'lists-new',
path: '/lists/new',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/lists_edit/lists_edit.vue'),
),
},
2026-01-06 16:22:52 +02:00
{
name: 'edit-navigation',
path: '/nav-edit',
component: NavPanel,
props: () => ({ forceExpand: true, forceEditMode: true }),
beforeEnter: validateAuthenticatedRoute,
},
{
name: 'bookmark-folders',
path: '/bookmark_folders',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/bookmark_folders/bookmark_folders.vue'),
),
2026-01-06 16:22:52 +02:00
},
{
name: 'bookmark-folder-new',
path: '/bookmarks/new-folder',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() =>
import(
'src/components/bookmark_folder_edit/bookmark_folder_edit.vue'
),
),
2026-01-06 16:22:52 +02:00
},
{
name: 'bookmark-folder',
path: '/bookmarks/:id',
component: BookmarkTimeline,
},
{
name: 'bookmark-folder-edit',
path: '/bookmarks/:id/edit',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() =>
import(
'src/components/bookmark_folder_edit/bookmark_folder_edit.vue'
),
),
2026-01-06 16:22:52 +02:00
},
]
2020-05-07 16:10:53 +03:00
if (useInstanceCapabilitiesStore().pleromaChatMessagesAvailable) {
2020-05-07 16:10:53 +03:00
routes = routes.concat([
2026-01-06 16:22:52 +02:00
{
name: 'chat',
path: '/users/:username/chats/:recipient_id',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/chat/chat.vue'),
),
2026-01-06 16:22:52 +02:00
meta: { dontScroll: false },
beforeEnter: validateAuthenticatedRoute,
},
{
name: 'chats',
path: '/users/:username/chats',
component: defineAsyncComponent(
2026-06-03 02:19:25 +03:00
() => import('src/components/chat_list/chat_list.vue'),
),
2026-01-06 16:22:52 +02:00
meta: { dontScroll: false },
beforeEnter: validateAuthenticatedRoute,
},
2020-05-07 16:10:53 +03:00
])
}
return routes
}