0
0

Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop

This commit is contained in:
syuilo 2022-06-29 21:22:18 +09:00
commit 3f6e04697a
3 changed files with 34 additions and 1 deletions

View File

@ -2,11 +2,13 @@
import { EventEmitter } from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import { Ref, Component, ref, shallowRef, ShallowRef } from 'vue'; import { Ref, Component, ref, shallowRef, ShallowRef } from 'vue';
import { pleaseLogin } from '@/scripts/please-login';
type RouteDef = { type RouteDef = {
path: string; path: string;
component: Component; component: Component;
query?: Record<string, string>; query?: Record<string, string>;
loginRequired?: boolean;
name?: string; name?: string;
hash?: string; hash?: string;
globalCacheKey?: string; globalCacheKey?: string;
@ -169,6 +171,10 @@ export class Router extends EventEmitter<{
throw new Error('no route found for: ' + path); throw new Error('no route found for: ' + path);
} }
if (res.route.loginRequired) {
pleaseLogin('/');
}
const isSamePath = beforePath === path; const isSamePath = beforePath === path;
if (isSamePath && key == null) key = this.currentKey; if (isSamePath && key == null) key = this.currentKey;
this.currentComponent = res.route.component; this.currentComponent = res.route.component;

View File

@ -38,6 +38,7 @@ export const routes = [{
name: 'settings', name: 'settings',
path: '/settings/:initialPage(*)?', path: '/settings/:initialPage(*)?',
component: page(() => import('./pages/settings/index.vue')), component: page(() => import('./pages/settings/index.vue')),
loginRequired: true,
}, { }, {
path: '/reset-password/:token?', path: '/reset-password/:token?',
component: page(() => import('./pages/reset-password.vue')), component: page(() => import('./pages/reset-password.vue')),
@ -60,6 +61,7 @@ export const routes = [{
}, { }, {
path: '/theme-editor', path: '/theme-editor',
component: page(() => import('./pages/theme-editor.vue')), component: page(() => import('./pages/theme-editor.vue')),
loginRequired: true,
}, { }, {
path: '/explore/tags/:tag', path: '/explore/tags/:tag',
component: page(() => import('./pages/explore.vue')), component: page(() => import('./pages/explore.vue')),
@ -76,12 +78,15 @@ export const routes = [{
}, { }, {
path: '/authorize-follow', path: '/authorize-follow',
component: page(() => import('./pages/follow.vue')), component: page(() => import('./pages/follow.vue')),
loginRequired: true,
}, { }, {
path: '/share', path: '/share',
component: page(() => import('./pages/share.vue')), component: page(() => import('./pages/share.vue')),
loginRequired: true,
}, { }, {
path: '/api-console', path: '/api-console',
component: page(() => import('./pages/api-console.vue')), component: page(() => import('./pages/api-console.vue')),
loginRequired: true,
}, { }, {
path: '/mfm-cheat-sheet', path: '/mfm-cheat-sheet',
component: page(() => import('./pages/mfm-cheat-sheet.vue')), component: page(() => import('./pages/mfm-cheat-sheet.vue')),
@ -109,18 +114,22 @@ export const routes = [{
}, { }, {
path: '/pages/new', path: '/pages/new',
component: page(() => import('./pages/page-editor/page-editor.vue')), component: page(() => import('./pages/page-editor/page-editor.vue')),
loginRequired: true,
}, { }, {
path: '/pages/edit/:initPageId', path: '/pages/edit/:initPageId',
component: page(() => import('./pages/page-editor/page-editor.vue')), component: page(() => import('./pages/page-editor/page-editor.vue')),
loginRequired: true,
}, { }, {
path: '/pages', path: '/pages',
component: page(() => import('./pages/pages.vue')), component: page(() => import('./pages/pages.vue')),
}, { }, {
path: '/gallery/:postId/edit', path: '/gallery/:postId/edit',
component: page(() => import('./pages/gallery/edit.vue')), component: page(() => import('./pages/gallery/edit.vue')),
loginRequired: true,
}, { }, {
path: '/gallery/new', path: '/gallery/new',
component: page(() => import('./pages/gallery/edit.vue')), component: page(() => import('./pages/gallery/edit.vue')),
loginRequired: true,
}, { }, {
path: '/gallery/:postId', path: '/gallery/:postId',
component: page(() => import('./pages/gallery/post.vue')), component: page(() => import('./pages/gallery/post.vue')),
@ -130,9 +139,11 @@ export const routes = [{
}, { }, {
path: '/channels/:channelId/edit', path: '/channels/:channelId/edit',
component: page(() => import('./pages/channel-editor.vue')), component: page(() => import('./pages/channel-editor.vue')),
loginRequired: true,
}, { }, {
path: '/channels/new', path: '/channels/new',
component: page(() => import('./pages/channel-editor.vue')), component: page(() => import('./pages/channel-editor.vue')),
loginRequired: true,
}, { }, {
path: '/channels/:channelId', path: '/channels/:channelId',
component: page(() => import('./pages/channel.vue')), component: page(() => import('./pages/channel.vue')),
@ -148,52 +159,68 @@ export const routes = [{
}, { }, {
path: '/my/notifications', path: '/my/notifications',
component: page(() => import('./pages/notifications.vue')), component: page(() => import('./pages/notifications.vue')),
loginRequired: true,
}, { }, {
path: '/my/favorites', path: '/my/favorites',
component: page(() => import('./pages/favorites.vue')), component: page(() => import('./pages/favorites.vue')),
loginRequired: true,
}, { }, {
name: 'messaging', name: 'messaging',
path: '/my/messaging', path: '/my/messaging',
component: page(() => import('./pages/messaging/index.vue')), component: page(() => import('./pages/messaging/index.vue')),
loginRequired: true,
}, { }, {
path: '/my/messaging/:userAcct', path: '/my/messaging/:userAcct',
component: page(() => import('./pages/messaging/messaging-room.vue')), component: page(() => import('./pages/messaging/messaging-room.vue')),
loginRequired: true,
}, { }, {
path: '/my/messaging/group/:groupId', path: '/my/messaging/group/:groupId',
component: page(() => import('./pages/messaging/messaging-room.vue')), component: page(() => import('./pages/messaging/messaging-room.vue')),
loginRequired: true,
}, { }, {
path: '/my/drive/folder/:folder', path: '/my/drive/folder/:folder',
component: page(() => import('./pages/drive.vue')), component: page(() => import('./pages/drive.vue')),
loginRequired: true,
}, { }, {
path: '/my/drive', path: '/my/drive',
component: page(() => import('./pages/drive.vue')), component: page(() => import('./pages/drive.vue')),
loginRequired: true,
}, { }, {
path: '/my/follow-requests', path: '/my/follow-requests',
component: page(() => import('./pages/follow-requests.vue')), component: page(() => import('./pages/follow-requests.vue')),
loginRequired: true,
}, { }, {
path: '/my/lists/:listId', path: '/my/lists/:listId',
component: page(() => import('./pages/my-lists/list.vue')), component: page(() => import('./pages/my-lists/list.vue')),
loginRequired: true,
}, { }, {
path: '/my/lists', path: '/my/lists',
component: page(() => import('./pages/my-lists/index.vue')), component: page(() => import('./pages/my-lists/index.vue')),
loginRequired: true,
}, { }, {
path: '/my/clips', path: '/my/clips',
component: page(() => import('./pages/my-clips/index.vue')), component: page(() => import('./pages/my-clips/index.vue')),
loginRequired: true,
}, { }, {
path: '/my/antennas/create', path: '/my/antennas/create',
component: page(() => import('./pages/my-antennas/create.vue')), component: page(() => import('./pages/my-antennas/create.vue')),
loginRequired: true,
}, { }, {
path: '/my/antennas/:antennaId', path: '/my/antennas/:antennaId',
component: page(() => import('./pages/my-antennas/edit.vue')), component: page(() => import('./pages/my-antennas/edit.vue')),
loginRequired: true,
}, { }, {
path: '/my/antennas', path: '/my/antennas',
component: page(() => import('./pages/my-antennas/index.vue')), component: page(() => import('./pages/my-antennas/index.vue')),
loginRequired: true,
}, { }, {
path: '/timeline/list/:listId', path: '/timeline/list/:listId',
component: page(() => import('./pages/user-list-timeline.vue')), component: page(() => import('./pages/user-list-timeline.vue')),
loginRequired: true,
}, { }, {
path: '/timeline/antenna/:antennaId', path: '/timeline/antenna/:antennaId',
component: page(() => import('./pages/antenna-timeline.vue')), component: page(() => import('./pages/antenna-timeline.vue')),
loginRequired: true,
}, { }, {
name: 'index', name: 'index',
path: '/', path: '/',

View File

@ -17,5 +17,5 @@ export function pleaseLogin(path?: string) {
}, },
}, 'closed'); }, 'closed');
throw new Error('signin required'); if (!path) throw new Error('signin required');
} }