paricafe/packages/frontend/src/components/MkUserPopup.vue

240 lines
6.1 KiB
Vue
Raw Normal View History

<!--
2024-02-11 20:37:45 -06:00
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
2023-03-02 21:29:34 -06:00
<template>
<Transition
2023-05-18 23:58:09 -05:00
:enterActiveClass="defaultStore.state.animation ? $style.transition_popup_enterActive : ''"
:leaveActiveClass="defaultStore.state.animation ? $style.transition_popup_leaveActive : ''"
:enterFromClass="defaultStore.state.animation ? $style.transition_popup_enterFrom : ''"
:leaveToClass="defaultStore.state.animation ? $style.transition_popup_leaveTo : ''"
appear @afterLeave="emit('closed')"
2023-03-02 21:29:34 -06:00
>
<div v-if="showing" :class="$style.root" class="_popup _shadow" :style="{ zIndex, top: top + 'px', left: left + 'px' }" @mouseover="() => { emit('mouseover'); }" @mouseleave="() => { emit('mouseleave'); }">
<div v-if="user != null">
<div :class="$style.banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl})` : ''">
2023-04-01 00:01:57 -05:00
<span v-if="$i && $i.id != user.id && user.isFollowed" :class="$style.followed">{{ i18n.ts.followsYou }}</span>
2023-03-02 21:29:34 -06:00
</div>
<svg viewBox="0 0 128 128" :class="$style.avatarBack">
<g transform="matrix(1.6,0,0,1.6,-38.4,-51.2)">
<path d="M64,32C81.661,32 96,46.339 96,64C95.891,72.184 104,72 104,72C104,72 74.096,80 64,80C52.755,80 24,72 24,72C24,72 31.854,72.018 32,64C32,46.339 46.339,32 64,32Z" style="fill: var(--popup);"/>
</g>
</svg>
<MkAvatar :class="$style.avatar" :user="user" indicator/>
<div :class="$style.title">
<MkA :class="$style.name" :to="userPage(user)"><MkUserName :user="user" :nowrap="false"/></MkA>
<div :class="$style.username"><MkAcct :user="user"/></div>
</div>
<div :class="$style.description">
<Mfm v-if="user.description" :class="$style.mfm" :text="user.description" :author="user"/>
2023-03-02 21:29:34 -06:00
<div v-else style="opacity: 0.7;">{{ i18n.ts.noAccountDescription }}</div>
</div>
<div :class="$style.status">
<div :class="$style.statusItem">
2023-04-01 00:01:57 -05:00
<div :class="$style.statusItemLabel">{{ i18n.ts.notes }}</div>
2023-03-02 21:29:34 -06:00
<div>{{ number(user.notesCount) }}</div>
</div>
<div v-if="isFollowingVisibleForMe(user)" :class="$style.statusItem">
2023-04-01 00:01:57 -05:00
<div :class="$style.statusItemLabel">{{ i18n.ts.following }}</div>
2023-03-02 21:29:34 -06:00
<div>{{ number(user.followingCount) }}</div>
</div>
<div v-if="isFollowersVisibleForMe(user)" :class="$style.statusItem">
2023-04-01 00:01:57 -05:00
<div :class="$style.statusItemLabel">{{ i18n.ts.followers }}</div>
2023-03-02 21:29:34 -06:00
<div>{{ number(user.followersCount) }}</div>
</div>
</div>
<button class="_button" :class="$style.menu" @click="showMenu"><i class="ti ti-dots"></i></button>
新規にフォローした人のwithRepliesをtrueにする機能を追加 (#12048) * feat: add defaultWithReplies to MiUser * feat: use defaultWithReplies when creating MiFollowing * feat: update defaultWithReplies from API * feat: return defaultWithReplies as a part of $i * feat(frontend): configure defaultWithReplies * docs(changelog): 新規にフォローした人のをデフォルトでTL二追加できるように * fix: typo * style: fix lint failure * chore: improve UI text * chore: make optional params of UserFollowingService.follow() object * chore: UserFollowingService.follow() accept withReplies * chore: add withReplies to MiFollowRequest * chore: process withReplies for follow request * feat: accept withReplies on 'following/create' endpoint * feat: store defaultWithReplies in client store * Revert "feat: return defaultWithReplies as a part of $i" This reverts commit f2cc4fe6 * Revert "feat: update defaultWithReplies from API" This reverts commit 95e3cee6 * Revert "feat: add defaultWithReplies to MiUser" This reverts commit 9f5ab14d7063532de2b049bc2ed40a15658168f5. * feat: configuring withReplies in import-following * feat(frontend): configure withReplies * fix(frontend): incorrectly showRepliesToOthersInTimeline can be shown * fix(backend): withReplies of following/create not working * fix(frontend): importFollowing error * fix: withReplies is not working with follow import * fix(frontend): use v-model * style: fix lint --------- Co-authored-by: Sayamame-beans <61457993+sayamame-beans@users.noreply.github.com> Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
2023-10-17 06:56:17 -05:00
<MkFollowButton v-if="$i && user.id != $i.id" v-model:user="user" :class="$style.follow" mini/>
2023-03-02 21:29:34 -06:00
</div>
<div v-else>
<MkLoading/>
</div>
</div>
</Transition>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import * as Misskey from 'misskey-js';
2023-03-02 21:29:34 -06:00
import MkFollowButton from '@/components/MkFollowButton.vue';
2023-09-19 02:37:43 -05:00
import { userPage } from '@/filters/user.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
2023-09-19 02:37:43 -05:00
import { getUserMenu } from '@/scripts/get-user-menu.js';
import number from '@/filters/number.js';
import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store.js';
import { $i } from '@/account.js';
import { isFollowingVisibleForMe, isFollowersVisibleForMe } from '@/scripts/isFfVisibleForMe.js';
2023-03-02 21:29:34 -06:00
const props = defineProps<{
showing: boolean;
q: string;
source: HTMLElement;
}>();
const emit = defineEmits<{
(ev: 'closed'): void;
(ev: 'mouseover'): void;
(ev: 'mouseleave'): void;
}>();
const zIndex = os.claimZIndex('middle');
const user = ref<Misskey.entities.UserDetailed | null>(null);
const top = ref(0);
const left = ref(0);
2023-03-02 21:29:34 -06:00
function showMenu(ev: MouseEvent) {
refactor: frontendのcomponentsの型エラーを改善 (#12926) * add: safeFloatParserを追加 * fix: 欠けていた型を追加 * refactor: pageBlockTypesをjson-schemaに移植 * refactor: components/global内の型エラーが出ている箇所を修正 * lint: fix null check style * refactor: fix type error * refactor: fix some type errors * fix: 翻訳が抜けていた箇所を修正 * refactor: getJsonSchemaで正しいスキーマが返されるように修正 * fix: MkChartの型エラーとbytesオプションが機能していない問題を修正 * fix(misskey-js): `drive`->`folderUpdated`のpayloadの型が間違っていたのを修正 * refactor: fix some type errors * change: Captcha読み込み中の文言をLoadingに変更 * refactor(backend/misskey-js): MainEventの型を改善 * refactor: chartjs-plugin-gradientが二重でpluginに登録されていたのを修正 * update: misskey-js.api.md * refactor: fix some type errors * fix: backendのtypecheckが落ちていたのを修正 * update: misskey-js.api.md * add: json-schemaのnoteにpollの型定義を追加 * refactor: noteのjson-schemaの型を改善 * refactor: MkPoll * refactor: fix some type errors * change: UserLiteにisLockedを持たせるように * fix: notificationスキーマにroleが含まれていないのを修正 * Revert "change: UserLiteにisLockedを持たせるように" This reverts commit 1bb0c8e7a9b19a4e9f21bf7381712b98f27672a5. * fix: フォロー通知から鍵垢へのフォローを行うと処理中のまま止まってしまう問題を修正 * refactor: noteスキーマのvisibilityにenumを追加 * change: deepCloneのCloneableTypeにundefinedを追加 * refactor: fix some type errors * refactor: `allowEmpty: false`を使用していた箇所を`minLength: 1`に置き換え * enhance: API 'retension' のresponseの型を追加 * fix: Chart関連のtooltipが正しい位置に表示されない問題を修正 * refactor: fix some type errors * fix: 型情報が不足していたのを修正 * enhance: announcementスキーマにenumを追加 * enhance: ロールポリシーの型定義をRoleServiceからjson-schemaに移植 * refactor: policiesを`ref: RolePolicies`に統一 * fix: API `meta` のレスポンスの型にpoliciesが含まれていないのを修正 * refactor: fix some type errors * fix: backendのlintが落ちているのを修正 * fix: MkFoldableSectionの開閉時のanimationが適用されていない問題を修正 * fix: backendのtypecheckが落ちているのを修正 * update: run build-misskey-js-with-types * fix: MkDialogのmount時に文字数制限の判定が行われない問題を修正 * update: CHANGELOG.md * refactor: MkUserSelectDialogの型を改善 * fix: deepCloneでundefinedはcloneしないように (#9207) * change: frontendのcloneをbackend側にも反映 * update: CHANGELOG.md * fix: RoleServiceからPackを通して型RolePoliciesに依存させないように * Update packages/frontend/src/scripts/get-note-summary.ts * revert RoleService.ts changes * change: optional chaining -> non-null assertion * remove: unused import * fix: propsで渡されたuserがUserLiteの場合に意図しない動作になってしまうのを修正 * change: fix null check style * refactor: fix type error * change: fix null check style * Update packages/frontend/src/components/MkDrive.vue Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * refactor: css moduleでglobalを使わないように * refactor: roleのiconUrlは必ず存在するものとして扱うように * enhance: MenuButtonのactiveにcomputedを受け付けられるように * Update packages/frontend/src/components/MkNotePreview.vue * Update MkWindow.vue * refactor: notification.noteは必ず存在するものとして扱うように * Update packages/frontend/src/components/MkNotification.vue Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * fix: MkSignupDialogでdoneのemit時にresを含んでいなかったのを修正 * Update packages/frontend/src/scripts/clone.ts Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * refactor: 不要な返り値の型を削除 * refactor: 不要なnullチェックを削除 * update: misskey-js-autogen * update: clone.ts * refactor * Update MkNotification.vue * Update MkNotification.vue * :v: * Update MkNotification.vue * Update MkNotification.vue * Update MkNotification.vue * Update MkNotifications.vue * Update MkUserSetupDialog.Profile.vue * Update MkUserCardMini.vue * :v: * Update MkMenu.vue --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
2024-01-30 04:53:53 -06:00
if (user.value == null) return;
const { menu, cleanup } = getUserMenu(user.value);
os.popupMenu(menu, ev.currentTarget ?? ev.target).finally(cleanup);
2023-03-02 21:29:34 -06:00
}
onMounted(() => {
if (typeof props.q === 'object') {
user.value = props.q;
2023-03-02 21:29:34 -06:00
} else {
const query = props.q.startsWith('@') ?
Misskey.acct.parse(props.q.substring(1)) :
2023-03-02 21:29:34 -06:00
{ userId: props.q };
misskeyApi('users/show', query).then(res => {
2023-03-02 21:29:34 -06:00
if (!props.showing) return;
user.value = res;
2023-03-02 21:29:34 -06:00
});
}
const rect = props.source.getBoundingClientRect();
const x = ((rect.left + (props.source.offsetWidth / 2)) - (300 / 2)) + window.pageXOffset;
const y = rect.top + props.source.offsetHeight + window.pageYOffset;
top.value = y;
left.value = x;
2023-03-02 21:29:34 -06:00
});
</script>
<style lang="scss" module>
.transition_popup_enterActive,
.transition_popup_leaveActive {
transition: opacity 0.15s, transform 0.15s !important;
}
.transition_popup_enterFrom,
.transition_popup_leaveTo {
opacity: 0;
transform: scale(0.9);
}
.root {
position: absolute;
width: 300px;
overflow: clip;
transform-origin: center top;
}
.banner {
height: 78px;
background-color: rgba(0, 0, 0, 0.1);
background-size: cover;
background-position: center;
}
.followed {
position: absolute;
top: 12px;
left: 12px;
padding: 4px 8px;
color: #fff;
background: rgba(0, 0, 0, 0.7);
font-size: 0.7em;
border-radius: 6px;
}
.avatarBack {
width: 100px;
position: absolute;
top: 28px;
left: 0;
right: 0;
margin: 0 auto;
}
.avatar {
display: block;
position: absolute;
top: 38px;
left: 0;
right: 0;
margin: 0 auto;
z-index: 2;
width: 58px;
height: 58px;
}
.title {
position: relative;
z-index: 3;
display: block;
padding: 8px 26px 16px 26px;
margin-top: 16px;
text-align: center;
}
.name {
display: inline-block;
font-weight: bold;
word-break: break-all;
}
.username {
display: block;
font-size: 0.8em;
opacity: 0.7;
}
.description {
padding: 16px 26px;
font-size: 0.8em;
text-align: center;
border-top: solid 1px var(--divider);
border-bottom: solid 1px var(--divider);
}
.mfm {
display: -webkit-box;
-webkit-line-clamp: 5;
-webkit-box-orient: vertical;
overflow: hidden;
}
2023-03-02 21:29:34 -06:00
.status {
padding: 16px 26px 16px 26px;
}
.statusItem {
display: inline-block;
width: 33%;
text-align: center;
}
.statusItemLabel {
font-size: 0.7em;
color: var(--fgTransparentWeak);
}
.menu {
position: absolute;
top: 8px;
right: 44px;
padding: 6px;
background: var(--panel);
border-radius: 999px;
}
.follow {
2023-03-02 23:55:56 -06:00
position: absolute !important;
2023-03-02 21:29:34 -06:00
top: 8px;
right: 8px;
}
</style>