summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/please-login.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/scripts/please-login.ts')
-rw-r--r--packages/frontend/src/scripts/please-login.ts46
1 files changed, 42 insertions, 4 deletions
diff --git a/packages/frontend/src/scripts/please-login.ts b/packages/frontend/src/scripts/please-login.ts
index 9e51272791..18f05bc7f4 100644
--- a/packages/frontend/src/scripts/please-login.ts
+++ b/packages/frontend/src/scripts/please-login.ts
@@ -8,19 +8,57 @@ import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { popup } from '@/os.js';
-export function pleaseLogin(path?: string) {
+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(path?: string, openOnRemote?: OpenOnRemoteOptions) {
if ($i) return;
- popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {
+ const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {
autoSet: true,
- message: i18n.ts.signinRequired,
+ message: openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired,
+ openOnRemote,
}, {
cancelled: () => {
if (path) {
window.location.href = path;
}
},
- }, 'closed');
+ closed: () => dispose(),
+ });
throw new Error('signin required');
}