diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-07-14 15:27:52 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-14 15:27:52 +0900 |
| commit | 3c032dd5b917c97bf8fb1b87a69f36d56537f493 (patch) | |
| tree | dacd9e664ed11cc77a351a81d48c52c6f7116c61 /packages/frontend/src/pages | |
| parent | enhance(frontend): サーバー情報・お問い合わせページを改修 ... (diff) | |
| download | misskey-3c032dd5b917c97bf8fb1b87a69f36d56537f493.tar.gz misskey-3c032dd5b917c97bf8fb1b87a69f36d56537f493.tar.bz2 misskey-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/pages')
| -rw-r--r-- | packages/frontend/src/pages/flash/flash.vue | 3 | ||||
| -rw-r--r-- | packages/frontend/src/pages/follow.vue | 71 | ||||
| -rw-r--r-- | packages/frontend/src/pages/lookup.vue | 97 | ||||
| -rw-r--r-- | packages/frontend/src/pages/user/home.vue | 4 |
4 files changed, 102 insertions, 73 deletions
diff --git a/packages/frontend/src/pages/flash/flash.vue b/packages/frontend/src/pages/flash/flash.vue index 40499fde0e..8a63176d00 100644 --- a/packages/frontend/src/pages/flash/flash.vue +++ b/packages/frontend/src/pages/flash/flash.vue @@ -79,6 +79,7 @@ import { defaultStore } from '@/store.js'; import { $i } from '@/account.js'; import { isSupportShare } from '@/scripts/navigator.js'; import copyToClipboard from '@/scripts/copy-to-clipboard.js'; +import { pleaseLogin } from '@/scripts/please-login.js'; const props = defineProps<{ id: string; @@ -143,6 +144,7 @@ function shareWithNote() { function like() { if (!flash.value) return; + pleaseLogin(); os.apiWithDialog('flash/like', { flashId: flash.value.id, @@ -154,6 +156,7 @@ function like() { async function unlike() { if (!flash.value) return; + pleaseLogin(); const confirm = await os.confirm({ type: 'warning', diff --git a/packages/frontend/src/pages/follow.vue b/packages/frontend/src/pages/follow.vue deleted file mode 100644 index 247b0ac639..0000000000 --- a/packages/frontend/src/pages/follow.vue +++ /dev/null @@ -1,71 +0,0 @@ -<!-- -SPDX-FileCopyrightText: syuilo and misskey-project -SPDX-License-Identifier: AGPL-3.0-only ---> - -<template> -<div> -</div> -</template> - -<script lang="ts" setup> -import { } from 'vue'; -import * as Misskey from 'misskey-js'; -import * as os from '@/os.js'; -import { misskeyApi } from '@/scripts/misskey-api.js'; -import { i18n } from '@/i18n.js'; -import { defaultStore } from '@/store.js'; -import { mainRouter } from '@/router/main.js'; - -async function follow(user): Promise<void> { - const { canceled } = await os.confirm({ - type: 'question', - text: i18n.tsx.followConfirm({ name: user.name || user.username }), - }); - - if (canceled) { - window.close(); - return; - } - - os.apiWithDialog('following/create', { - userId: user.id, - withReplies: defaultStore.state.defaultWithReplies, - }); - user.withReplies = defaultStore.state.defaultWithReplies; -} - -const acct = new URL(location.href).searchParams.get('acct'); -if (acct == null) { - throw new Error('acct required'); -} - -let promise; - -if (acct.startsWith('https://')) { - promise = misskeyApi('ap/show', { - uri: acct, - }); - promise.then(res => { - if (res.type === 'User') { - follow(res.object); - } else if (res.type === 'Note') { - mainRouter.push(`/notes/${res.object.id}`); - } else { - os.alert({ - type: 'error', - text: 'Not a user', - }).then(() => { - window.close(); - }); - } - }); -} else { - promise = misskeyApi('users/show', Misskey.acct.parse(acct)); - promise.then(user => { - follow(user); - }); -} - -os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); -</script> diff --git a/packages/frontend/src/pages/lookup.vue b/packages/frontend/src/pages/lookup.vue new file mode 100644 index 0000000000..3233953942 --- /dev/null +++ b/packages/frontend/src/pages/lookup.vue @@ -0,0 +1,97 @@ +<!-- +SPDX-FileCopyrightText: syuilo and other misskey contributors +SPDX-License-Identifier: AGPL-3.0-only +--> + +<template> +<MkStickyContainer> + <template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template> + <MkSpacer :contentMax="800"> + <div v-if="state === 'done'" class="_buttonsCenter"> + <MkButton @click="close">{{ i18n.ts.close }}</MkButton> + <MkButton @click="goToMisskey">{{ i18n.ts.goToMisskey }}</MkButton> + </div> + <div v-else class="_fullInfo"> + <MkLoading/> + </div> + </MkSpacer> +</MkStickyContainer> +</template> + +<script lang="ts" setup> +import { computed, ref } from 'vue'; +import * as Misskey from 'misskey-js'; +import * as os from '@/os.js'; +import { misskeyApi } from '@/scripts/misskey-api.js'; +import { i18n } from '@/i18n.js'; +import { definePageMetadata } from '@/scripts/page-metadata.js'; +import { mainRouter } from '@/router/main.js'; +import MkButton from '@/components/MkButton.vue'; + +const state = ref<'fetching' | 'done'>('fetching'); + +function fetch() { + const params = new URL(location.href).searchParams; + + // acctのほうはdeprecated + let uri = params.get('uri') ?? params.get('acct'); + if (uri == null) { + state.value = 'done'; + return; + } + + let promise: Promise<any>; + + if (uri.startsWith('https://')) { + promise = misskeyApi('ap/show', { + uri, + }); + promise.then(res => { + if (res.type === 'User') { + mainRouter.replace(res.object.host ? `/@${res.object.username}@${res.object.host}` : `/@${res.object.username}`); + } else if (res.type === 'Note') { + mainRouter.replace(`/notes/${res.object.id}`); + } else { + os.alert({ + type: 'error', + text: 'Not a user', + }); + } + }); + } else { + if (uri.startsWith('acct:')) { + uri = uri.slice(5); + } + promise = misskeyApi('users/show', Misskey.acct.parse(uri)); + promise.then(user => { + mainRouter.replace(user.host ? `/@${user.username}@${user.host}` : `/@${user.username}`); + }); + } + + os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); +} + +function close(): void { + window.close(); + + // 閉じなければ100ms後タイムラインに + window.setTimeout(() => { + location.href = '/'; + }, 100); +} + +function goToMisskey(): void { + location.href = '/'; +} + +fetch(); + +const headerActions = computed(() => []); + +const headerTabs = computed(() => []); + +definePageMetadata({ + title: i18n.ts.lookup, + icon: 'ti ti-world-search', +}); +</script> diff --git a/packages/frontend/src/pages/user/home.vue b/packages/frontend/src/pages/user/home.vue index 834d799072..d67990e9a2 100644 --- a/packages/frontend/src/pages/user/home.vue +++ b/packages/frontend/src/pages/user/home.vue @@ -32,9 +32,9 @@ SPDX-License-Identifier: AGPL-3.0-only </div> </div> <span v-if="$i && $i.id != user.id && user.isFollowed" class="followed">{{ i18n.ts.followsYou }}</span> - <div v-if="$i" class="actions"> + <div class="actions"> <button class="menu _button" @click="menu"><i class="ti ti-dots"></i></button> - <MkFollowButton v-if="$i.id != user.id" v-model:user="user" :inline="true" :transparent="false" :full="true" class="koudoku"/> + <MkFollowButton v-if="$i?.id != user.id" v-model:user="user" :inline="true" :transparent="false" :full="true" class="koudoku"/> </div> </div> <MkAvatar class="avatar" :user="user" indicator/> |