summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts
diff options
context:
space:
mode:
authorかっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>2024-07-14 15:27:52 +0900
committerGitHub <noreply@github.com>2024-07-14 15:27:52 +0900
commit3c032dd5b917c97bf8fb1b87a69f36d56537f493 (patch)
treedacd9e664ed11cc77a351a81d48c52c6f7116c61 /packages/frontend/src/scripts
parentenhance(frontend): サーバー情報・お問い合わせページを改修 ... (diff)
downloadsharkey-3c032dd5b917c97bf8fb1b87a69f36d56537f493.tar.gz
sharkey-3c032dd5b917c97bf8fb1b87a69f36d56537f493.tar.bz2
sharkey-3c032dd5b917c97bf8fb1b87a69f36d56537f493.zip
enhance: 非ログイン時には別サーバーに遷移できるように (#13089)
* enhance: 非ログイン時にはMisskey Hub経由で別サーバーに遷移できるように * fix * サーバーサイド照会を削除 * クライアント側の照会動作 * hubを経由せずにリモートで続行できるように * fix と pleaseLogin誘導箇所の追加 * fix * fix * Update CHANGELOG.md --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/scripts')
-rw-r--r--packages/frontend/src/scripts/get-user-menu.ts4
-rw-r--r--packages/frontend/src/scripts/please-login.ts16
-rw-r--r--packages/frontend/src/scripts/url.ts5
3 files changed, 21 insertions, 4 deletions
diff --git a/packages/frontend/src/scripts/get-user-menu.ts b/packages/frontend/src/scripts/get-user-menu.ts
index ac8774fad0..2d1fea8ea4 100644
--- a/packages/frontend/src/scripts/get-user-menu.ts
+++ b/packages/frontend/src/scripts/get-user-menu.ts
@@ -186,7 +186,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
const canonical = user.host === null ? `@${user.username}` : `@${user.username}@${toUnicode(user.host)}`;
copyToClipboard(`${url}/${canonical}`);
},
- }, {
+ }, ...($i ? [{
icon: 'ti ti-mail',
text: i18n.ts.sendMessage,
action: () => {
@@ -259,7 +259,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
},
}));
},
- }] as any;
+ }] : [])] as any;
if ($i && meId !== user.id) {
if (iAmModerator) {
diff --git a/packages/frontend/src/scripts/please-login.ts b/packages/frontend/src/scripts/please-login.ts
index 363da5f633..b04062a58a 100644
--- a/packages/frontend/src/scripts/please-login.ts
+++ b/packages/frontend/src/scripts/please-login.ts
@@ -8,12 +8,24 @@ import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { popup } from '@/os.js';
-export function pleaseLogin(path?: string) {
+export type OpenOnRemoteOptions = {
+ type: 'web';
+ path: string;
+} | {
+ type: 'lookup';
+ path: string;
+} | {
+ type: 'share';
+ params: Record<string, string>;
+};
+
+export function pleaseLogin(path?: string, openOnRemote?: OpenOnRemoteOptions) {
if ($i) return;
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) {
diff --git a/packages/frontend/src/scripts/url.ts b/packages/frontend/src/scripts/url.ts
index e3072b3b7d..c477fb5506 100644
--- a/packages/frontend/src/scripts/url.ts
+++ b/packages/frontend/src/scripts/url.ts
@@ -21,3 +21,8 @@ export function query(obj: Record<string, any>): string {
export function appendQuery(url: string, query: string): string {
return `${url}${/\?/.test(url) ? url.endsWith('?') ? '' : '&' : '?'}${query}`;
}
+
+export function extractDomain(url: string) {
+ const match = url.match(/^(https)?:?\/{0,2}([^\/]+)/);
+ return match ? match[2] : null;
+}