Files
misskey/packages/frontend/src/scripts/please-login.ts
かっこかり 5445b023e5 enhance: 連合モードにあわせてフロントエンドを変化させるように (#15112)
* enhance(backend): metaにfederation modeに関する情報を公開

* enhance(frontend): 登録画面の注意書きを追加

* enhance(frontend): aboutページ・サーバー情報

* enhance(frontend): サーバー統計

* enhance(frontend): みつけるページ

* enhance(frontend): 検索

* enhance(frontend): ユーザー選択

* enhance(frontend): 設定画面

* enhance(frontend): ウィジェット

* enhance(frontend): リモートで開くオプション

* Update Changelog

* enhance(frontend): ステータスバー

* i18n

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
2025-01-14 11:08:54 +00:00

77 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defineAsyncComponent } from 'vue';
import { $i } from '@/account.js';
import { instance } from '@/instance.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;
let _openOnRemote: OpenOnRemoteOptions | undefined = undefined;
// 連合できる場合と、(連合ができなくても)共有する場合は外部連携オプションを設定
if (opts.openOnRemote != null && (instance.federation !== 'none' || opts.openOnRemote.type === 'share')) {
_openOnRemote = opts.openOnRemote;
}
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {
autoSet: true,
message: opts.message ?? (_openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired),
openOnRemote: _openOnRemote,
}, {
cancelled: () => {
if (opts.path) {
window.location.href = opts.path;
}
},
closed: () => dispose(),
});
throw new Error('signin required');
}