2018-12-06 01:05:35 +00:00
|
|
|
import PublicTimeline from 'components/public_timeline/public_timeline.vue'
|
|
|
|
import PublicAndExternalTimeline from 'components/public_and_external_timeline/public_and_external_timeline.vue'
|
|
|
|
import FriendsTimeline from 'components/friends_timeline/friends_timeline.vue'
|
|
|
|
import TagTimeline from 'components/tag_timeline/tag_timeline.vue'
|
2020-07-03 19:45:49 +00:00
|
|
|
import BookmarkTimeline from 'components/bookmark_timeline/bookmark_timeline.vue'
|
2018-12-06 01:05:35 +00:00
|
|
|
import ConversationPage from 'components/conversation-page/conversation-page.vue'
|
2019-05-14 19:38:16 +00:00
|
|
|
import Interactions from 'components/interactions/interactions.vue'
|
2018-12-06 01:05:35 +00:00
|
|
|
import DMs from 'components/dm_timeline/dm_timeline.vue'
|
2020-05-07 13:10:53 +00:00
|
|
|
import ChatList from 'components/chat_list/chat_list.vue'
|
|
|
|
import Chat from 'components/chat/chat.vue'
|
2018-12-06 01:05:35 +00:00
|
|
|
import UserProfile from 'components/user_profile/user_profile.vue'
|
2019-07-15 16:42:27 +00:00
|
|
|
import Search from 'components/search/search.vue'
|
2018-12-06 01:05:35 +00:00
|
|
|
import Registration from 'components/registration/registration.vue'
|
2019-09-05 11:23:28 +00:00
|
|
|
import PasswordReset from 'components/password_reset/password_reset.vue'
|
2018-12-06 01:05:35 +00:00
|
|
|
import FollowRequests from 'components/follow_requests/follow_requests.vue'
|
|
|
|
import OAuthCallback from 'components/oauth_callback/oauth_callback.vue'
|
2018-12-28 19:39:54 +00:00
|
|
|
import Notifications from 'components/notifications/notifications.vue'
|
2019-06-12 20:16:55 +00:00
|
|
|
import AuthForm from 'components/auth_form/auth_form.js'
|
2020-08-03 23:44:35 +00:00
|
|
|
import ShoutPanel from 'components/shout_panel/shout_panel.vue'
|
2019-01-16 02:33:08 +00:00
|
|
|
import WhoToFollow from 'components/who_to_follow/who_to_follow.vue'
|
2019-01-07 17:26:47 +00:00
|
|
|
import About from 'components/about/about.vue'
|
2019-11-08 22:27:25 +00:00
|
|
|
import RemoteUserResolver from 'components/remote_user_resolver/remote_user_resolver.vue'
|
2018-12-03 18:36:59 +00:00
|
|
|
|
|
|
|
export default (store) => {
|
2019-07-24 00:54:15 +00:00
|
|
|
const validateAuthenticatedRoute = (to, from, next) => {
|
|
|
|
if (store.state.users.currentUser) {
|
|
|
|
next()
|
|
|
|
} else {
|
|
|
|
next(store.state.instance.redirectRootNoLogin || '/main/all')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 13:10:53 +00:00
|
|
|
let routes = [
|
2018-12-03 18:36:59 +00:00
|
|
|
{ name: 'root',
|
|
|
|
path: '/',
|
|
|
|
redirect: _to => {
|
|
|
|
return (store.state.users.currentUser
|
2019-07-05 07:02:14 +00:00
|
|
|
? store.state.instance.redirectRootLogin
|
|
|
|
: store.state.instance.redirectRootNoLogin) || '/main/all'
|
2018-12-03 18:36:59 +00:00
|
|
|
}
|
|
|
|
},
|
2018-12-25 17:43:52 +00:00
|
|
|
{ name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline },
|
|
|
|
{ name: 'public-timeline', path: '/main/public', component: PublicTimeline },
|
2019-07-24 00:54:15 +00:00
|
|
|
{ name: 'friends', path: '/main/friends', component: FriendsTimeline, beforeEnter: validateAuthenticatedRoute },
|
2018-12-25 17:43:52 +00:00
|
|
|
{ name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline },
|
2020-07-03 19:45:49 +00:00
|
|
|
{ name: 'bookmarks', path: '/bookmarks', component: BookmarkTimeline },
|
2018-12-25 17:43:52 +00:00
|
|
|
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
2019-11-08 22:27:25 +00:00
|
|
|
{ name: 'remote-user-profile-acct',
|
2022-03-22 17:20:12 +00:00
|
|
|
path: '/remote-users/:_(@)?:username([^/@]+)@:hostname([^/@]+)',
|
2019-11-08 22:27:25 +00:00
|
|
|
component: RemoteUserResolver,
|
|
|
|
beforeEnter: validateAuthenticatedRoute
|
|
|
|
},
|
|
|
|
{ name: 'remote-user-profile',
|
|
|
|
path: '/remote-users/:hostname/:username',
|
|
|
|
component: RemoteUserResolver,
|
|
|
|
beforeEnter: validateAuthenticatedRoute
|
|
|
|
},
|
2018-12-25 17:43:52 +00:00
|
|
|
{ name: 'external-user-profile', path: '/users/:id', component: UserProfile },
|
2019-07-24 00:54:15 +00:00
|
|
|
{ name: 'interactions', path: '/users/:username/interactions', component: Interactions, beforeEnter: validateAuthenticatedRoute },
|
|
|
|
{ name: 'dms', path: '/users/:username/dms', component: DMs, beforeEnter: validateAuthenticatedRoute },
|
2018-12-25 17:43:52 +00:00
|
|
|
{ name: 'registration', path: '/registration', component: Registration },
|
2019-10-16 10:00:26 +00:00
|
|
|
{ name: 'password-reset', path: '/password-reset', component: PasswordReset, props: true },
|
2019-01-27 09:13:32 +00:00
|
|
|
{ name: 'registration-token', path: '/registration/:token', component: Registration },
|
2019-07-24 00:54:15 +00:00
|
|
|
{ name: 'friend-requests', path: '/friend-requests', component: FollowRequests, beforeEnter: validateAuthenticatedRoute },
|
2022-06-07 13:52:03 +00:00
|
|
|
{ name: 'notifications', path: '/:username/notifications', component: Notifications, props: () => ({ disableTeleport: true }), beforeEnter: validateAuthenticatedRoute },
|
2019-06-12 20:16:55 +00:00
|
|
|
{ name: 'login', path: '/login', component: AuthForm },
|
2020-08-03 23:44:35 +00:00
|
|
|
{ name: 'shout-panel', path: '/shout-panel', component: ShoutPanel, props: () => ({ floating: false }) },
|
2018-12-25 17:43:52 +00:00
|
|
|
{ name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) },
|
2019-07-15 16:42:27 +00:00
|
|
|
{ name: 'search', path: '/search', component: Search, props: (route) => ({ query: route.query.query }) },
|
2019-07-24 01:52:24 +00:00
|
|
|
{ name: 'who-to-follow', path: '/who-to-follow', component: WhoToFollow, beforeEnter: validateAuthenticatedRoute },
|
2019-01-07 17:26:47 +00:00
|
|
|
{ name: 'about', path: '/about', component: About },
|
2022-03-18 11:32:36 +00:00
|
|
|
{ name: 'user-profile', path: '/:_(users)?/:name', component: UserProfile }
|
2018-12-03 18:36:59 +00:00
|
|
|
]
|
2020-05-07 13:10:53 +00:00
|
|
|
|
|
|
|
if (store.state.instance.pleromaChatMessagesAvailable) {
|
|
|
|
routes = routes.concat([
|
|
|
|
{ name: 'chat', path: '/users/:username/chats/:recipient_id', component: Chat, meta: { dontScroll: false }, beforeEnter: validateAuthenticatedRoute },
|
|
|
|
{ name: 'chats', path: '/users/:username/chats', component: ChatList, meta: { dontScroll: false }, beforeEnter: validateAuthenticatedRoute }
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
|
return routes
|
2018-12-03 18:36:59 +00:00
|
|
|
}
|