forked from mirror/misskey

* do not throw error when navigating * enhance: add loginRequired to router This allows client pages to require logging in before displaying the page, useful for example for user settings pages. * add login requirements Co-authored-by: Andreas Nedbal <git@pixelde.su>
22 lines
482 B
TypeScript
22 lines
482 B
TypeScript
import { defineAsyncComponent } from 'vue';
|
|
import { $i } from '@/account';
|
|
import { i18n } from '@/i18n';
|
|
import { popup } from '@/os';
|
|
|
|
export function pleaseLogin(path?: string) {
|
|
if ($i) return;
|
|
|
|
popup(defineAsyncComponent(() => import('@/components/signin-dialog.vue')), {
|
|
autoSet: true,
|
|
message: i18n.ts.signinRequired
|
|
}, {
|
|
cancelled: () => {
|
|
if (path) {
|
|
window.location.href = path;
|
|
}
|
|
},
|
|
}, 'closed');
|
|
|
|
if (!path) throw new Error('signin required');
|
|
}
|