blob: 43dcf1193674ad514eaab082f7e6cd6c96ec16ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defineAsyncComponent } from 'vue';
import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { popup } from '@/os.js';
export type OpenOnRemoteOptions = {
/**
* 外部のMisskey Webで特定のパスを開く
*/
type: 'web';
/**
* 内部パス(例: `/settings`)
*/
path: string;
} | {
/**
* 外部のMisskey Webで照会する
*/
type: 'lookup';
/**
* 照会したいエンティティのURL
*
* (例: `https://misskey.example.com/notes/abcdexxxxyz`)
*/
url: string;
} | {
/**
* 外部のMisskeyでノートする
*/
type: 'share';
/**
* `/share` ページに渡すクエリストリング
*
* @see https://go.misskey-hub.net/spec/share/
*/
params: Record<string, string>;
};
export function pleaseLogin(opts: {
path?: string;
message?: string;
openOnRemote?: OpenOnRemoteOptions;
} = {}) {
if ($i) return;
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {
autoSet: true,
message: opts.message ?? (opts.openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired),
openOnRemote: opts.openOnRemote,
}, {
cancelled: () => {
if (opts.path) {
window.location.href = opts.path;
}
},
closed: () => dispose(),
});
throw new Error('signin required');
}
|