1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-23 19:18:44 +09:00
MisskeyIO/packages/frontend/src/pages/user/home.vue

631 lines
15 KiB
Vue
Raw Normal View History

2022-07-01 18:55:45 +09:00
<template>
<MkSpacer :content-max="narrow ? 800 : 1100">
2022-12-28 13:19:56 +09:00
<div ref="rootEl" class="ftskorzw" :class="{ wide: !narrow }" style="container-type: inline-size;">
2023-01-06 13:40:17 +09:00
<div class="main _gaps">
2022-07-01 18:55:45 +09:00
<!-- TODO -->
<!-- <div class="punished" v-if="user.isSuspended"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userSuspended }}</div> -->
<!-- <div class="punished" v-if="user.isSilenced"><i class="ti ti-alert-triangle" style="margin-right: 8px;"></i> {{ i18n.ts.userSilenced }}</div> -->
2022-07-01 18:55:45 +09:00
2023-01-06 13:40:17 +09:00
<div class="profile _gaps">
enhance: account migration (#10592) * copy block and mute then create follow and unfollow jobs * copy block and mute and update lists when detecting an account has moved * no need to care promise orders * refactor updating actor and target * automatically accept if a locked account had accepted an old account * fix exception format * prevent the old account from calling some endpoints * do not unfollow when moving * adjust following and follower counts * check movedToUri when receiving a follow request * skip if no need to adjust * Revert "disable account migration" This reverts commit 2321214c98591bcfe1385c1ab5bf0ff7b471ae1d. * fix translation specifier * fix checking alsoKnownAs and uri * fix updating account * fix refollowing locked account * decrease followersCount if followed by the old account * adjust following and followers counts when unfollowing * fix copying mutings * prohibit moved account from moving again * fix move service * allow app creation after moving * fix lint * remove unnecessary field * fix cache update * add e2e test * add e2e test of accepting the new account automatically * force follow if any error happens * remove unnecessary joins * use Array.map instead of for const of * ユーザーリストの移行は追加のみを行う * nanka iroiro * fix misskey-js? * :v: * 移行を行ったアカウントからのフォローリクエストの自動許可を調整 * newUriを外に出す * newUriを外に出す2 * clean up * fix newUri * prevent moving if the destination account has already moved * set alsoKnownAs via /i/update * fix database initialization * add return type * prohibit updating alsoKnownAs after moving * skip to add to alsoKnownAs if toUrl is known * skip adding to the list if it already has * use Acct.parse instead * rename error code * :art: * 制限を5から10に緩和 * movedTo(Uri), alsoKnownAsはユーザーidを返すように * test api res * fix * 元アカウントはミュートし続ける * :art: * unfollow * fix * getUserUriをUserEntityServiceに * ? * job! * :art: * instance => server * accountMovedShort, forbiddenBecauseYouAreMigrated * accountMovedShort * fix test * import, pin禁止 * 実績を凍結する * clean up * :v: * change message * ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに * Revert "ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに" This reverts commit 3bd7be35d8aa455cb01ae58f8172a71a50485db1. * validateAlsoKnownAs * 移行後2時間以内はインポート可能なファイルサイズを拡大 * clean up * どうせactorをupdatePersonで更新するならupdatePersonしか移行処理を発行しないことにする * handle error? * リモートからの移行処理の条件を是正 * log, port * fix * fix * enhance(dev): non-production環境でhttpサーバー間でもユーザー、ノートの連合が可能なように * refactor (use checkHttps) * MISSKEY_WEBFINGER_USE_HTTP * Environment Variable readme * NEVER USE IN PRODUCTION * fix punyHost * fix indent * fix * experimental --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
2023-04-30 00:09:29 +09:00
<MkAccountMoved v-if="user.movedTo" :movedTo="user.movedTo" />
<MkRemoteCaution v-if="user.host != null" :href="user.url ?? user.uri!" class="warn"/>
2022-07-01 18:55:45 +09:00
2023-01-06 09:56:33 +09:00
<div :key="user.id" class="main _panel">
2022-07-01 18:55:45 +09:00
<div class="banner-container" :style="style">
<div ref="bannerEl" class="banner" :style="style"></div>
<div class="fade"></div>
<div class="title">
2023-02-08 20:07:19 +09:00
<MkUserName class="name" :user="user" :nowrap="true"/>
2022-07-01 18:55:45 +09:00
<div class="bottom">
<span class="username"><MkAcct :user="user" :detail="true"/></span>
2022-12-20 15:24:31 +09:00
<span v-if="user.isAdmin" :title="i18n.ts.isAdmin" style="color: var(--badge);"><i class="ti ti-shield"></i></span>
<span v-if="user.isLocked" :title="i18n.ts.isLocked"><i class="ti ti-lock"></i></span>
2022-12-20 15:24:31 +09:00
<span v-if="user.isBot" :title="i18n.ts.isBot"><i class="ti ti-robot"></i></span>
<button v-if="!isEditingMemo && !memoDraft" class="_button add-note-button" @click="showMemoTextarea">
<i class="ti ti-edit"/> {{ i18n.ts.addMemo }}
</button>
2022-07-01 18:55:45 +09:00
</div>
</div>
2022-07-20 22:24:26 +09:00
<span v-if="$i && $i.id != user.id && user.isFollowed" class="followed">{{ i18n.ts.followsYou }}</span>
2022-07-01 18:55:45 +09:00
<div v-if="$i" class="actions">
<button class="menu _button" @click="menu"><i class="ti ti-dots"></i></button>
2022-07-01 18:55:45 +09:00
<MkFollowButton v-if="$i.id != user.id" :user="user" :inline="true" :transparent="false" :full="true" class="koudoku"/>
</div>
</div>
2023-01-16 14:18:11 +09:00
<MkAvatar class="avatar" :user="user" indicator/>
2022-07-01 18:55:45 +09:00
<div class="title">
2023-02-08 20:07:19 +09:00
<MkUserName :user="user" :nowrap="false" class="name"/>
2022-07-01 18:55:45 +09:00
<div class="bottom">
<span class="username"><MkAcct :user="user" :detail="true"/></span>
2022-12-20 15:24:31 +09:00
<span v-if="user.isAdmin" :title="i18n.ts.isAdmin" style="color: var(--badge);"><i class="ti ti-shield"></i></span>
<span v-if="user.isLocked" :title="i18n.ts.isLocked"><i class="ti ti-lock"></i></span>
2022-12-20 15:24:31 +09:00
<span v-if="user.isBot" :title="i18n.ts.isBot"><i class="ti ti-robot"></i></span>
2022-07-01 18:55:45 +09:00
</div>
</div>
<div v-if="isEditingMemo || memoDraft" class="memo" :class="{'no-memo': !memoDraft}">
<div class="heading" v-text="i18n.ts.memo"/>
<textarea
ref="memoTextareaEl"
v-model="memoDraft"
rows="1"
@focus="isEditingMemo = true"
@blur="updateMemo"
@input="adjustMemoTextarea"
/>
</div>
<div v-if="user.roles.length > 0" class="roles">
<span v-for="role in user.roles" :key="role.id" v-tooltip="role.description" class="role" :style="{ '--color': role.color }">
<img v-if="role.iconUrl" style="height: 1.3em; vertical-align: -22%;" :src="role.iconUrl"/>
{{ role.name }}
</span>
</div>
2022-07-01 18:55:45 +09:00
<div class="description">
<MkOmit>
<Mfm v-if="user.description" :text="user.description" :is-note="false" :author="user" :i="$i"/>
<p v-else class="empty">{{ i18n.ts.noAccountDescription }}</p>
</MkOmit>
2022-07-01 18:55:45 +09:00
</div>
<div class="fields system">
<dl v-if="user.location" class="field">
2022-12-20 15:24:31 +09:00
<dt class="name"><i class="ti ti-map-pin ti-fw"></i> {{ i18n.ts.location }}</dt>
2022-07-01 18:55:45 +09:00
<dd class="value">{{ user.location }}</dd>
</dl>
<dl v-if="user.birthday" class="field">
2022-12-20 15:24:31 +09:00
<dt class="name"><i class="ti ti-cake ti-fw"></i> {{ i18n.ts.birthday }}</dt>
2023-04-01 14:01:57 +09:00
<dd class="value">{{ user.birthday.replace('-', '/').replace('-', '/') }} ({{ i18n.t('yearsOld', { age }) }})</dd>
2022-07-01 18:55:45 +09:00
</dl>
<dl class="field">
2022-12-20 15:24:31 +09:00
<dt class="name"><i class="ti ti-calendar ti-fw"></i> {{ i18n.ts.registeredDate }}</dt>
<dd class="value">{{ dateString(user.createdAt) }} (<MkTime :time="user.createdAt"/>)</dd>
2022-07-01 18:55:45 +09:00
</dl>
</div>
<div v-if="user.fields.length > 0" class="fields">
<dl v-for="(field, i) in user.fields" :key="i" class="field">
<dt class="name">
<Mfm :text="field.name" :plain="true" :colored="false"/>
2022-07-01 18:55:45 +09:00
</dt>
<dd class="value">
<Mfm :text="field.value" :author="user" :i="$i" :colored="false"/>
2022-07-01 18:55:45 +09:00
</dd>
</dl>
</div>
<div class="status">
2023-02-12 11:06:26 +09:00
<MkA v-click-anime :to="userPage(user)">
2022-07-01 18:55:45 +09:00
<b>{{ number(user.notesCount) }}</b>
2022-07-20 22:24:26 +09:00
<span>{{ i18n.ts.notes }}</span>
2022-07-01 18:55:45 +09:00
</MkA>
2023-02-12 11:06:26 +09:00
<MkA v-click-anime :to="userPage(user, 'following')">
2022-07-01 18:55:45 +09:00
<b>{{ number(user.followingCount) }}</b>
2022-07-20 22:24:26 +09:00
<span>{{ i18n.ts.following }}</span>
2022-07-01 18:55:45 +09:00
</MkA>
2023-02-12 11:06:26 +09:00
<MkA v-click-anime :to="userPage(user, 'followers')">
2022-07-01 18:55:45 +09:00
<b>{{ number(user.followersCount) }}</b>
2022-07-20 22:24:26 +09:00
<span>{{ i18n.ts.followers }}</span>
2022-07-01 18:55:45 +09:00
</MkA>
</div>
</div>
</div>
2023-01-06 13:40:17 +09:00
<div class="contents _gaps">
<div v-if="user.pinnedNotes.length > 0" class="_gaps">
2023-03-31 14:14:30 +09:00
<MkNote v-for="note in user.pinnedNotes" :key="note.id" class="note _panel" :note="note" :pinned="true"/>
2022-07-01 18:55:45 +09:00
</div>
2022-07-20 22:24:26 +09:00
<MkInfo v-else-if="$i && $i.id === user.id">{{ i18n.ts.userPagePinTip }}</MkInfo>
2022-07-01 18:55:45 +09:00
<template v-if="narrow">
<XPhotos :key="user.id" :user="user"/>
2023-01-06 13:40:17 +09:00
<XActivity :key="user.id" :user="user"/>
2022-07-01 18:55:45 +09:00
</template>
<MkNotes v-if="!disableNotes" :class="$style.tl" :no-gap="true" :pagination="pagination"/>
2022-07-01 18:55:45 +09:00
</div>
</div>
2023-01-06 13:40:17 +09:00
<div v-if="!narrow" class="sub _gaps" style="container-type: inline-size;">
2022-07-01 18:55:45 +09:00
<XPhotos :key="user.id" :user="user"/>
2023-01-06 13:40:17 +09:00
<XActivity :key="user.id" :user="user"/>
2022-07-01 18:55:45 +09:00
</div>
</div>
</MkSpacer>
</template>
<script lang="ts" setup>
import { defineAsyncComponent, computed, onMounted, onUnmounted, nextTick, watch } from 'vue';
2022-07-01 18:55:45 +09:00
import calcAge from 's-age';
import * as misskey from 'misskey-js';
2023-03-31 14:14:30 +09:00
import MkNote from '@/components/MkNote.vue';
import MkFollowButton from '@/components/MkFollowButton.vue';
import MkAccountMoved from '@/components/MkAccountMoved.vue';
import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
import MkOmit from '@/components/MkOmit.vue';
import MkInfo from '@/components/MkInfo.vue';
2022-07-01 18:55:45 +09:00
import { getScrollPosition } from '@/scripts/scroll';
import { getUserMenu } from '@/scripts/get-user-menu';
import number from '@/filters/number';
import { userPage } from '@/filters/user';
2022-07-01 18:55:45 +09:00
import * as os from '@/os';
import { useRouter } from '@/router';
import { i18n } from '@/i18n';
import { $i } from '@/account';
import { dateString } from '@/filters/date';
import { confetti } from '@/scripts/confetti';
import MkNotes from '@/components/MkNotes.vue';
import { api } from '@/os';
2022-07-01 18:55:45 +09:00
const XPhotos = defineAsyncComponent(() => import('./index.photos.vue'));
const XActivity = defineAsyncComponent(() => import('./index.activity.vue'));
const props = withDefaults(defineProps<{
user: misskey.entities.UserDetailed;
/** Test only; MkNotes currently causes problems in vitest */
disableNotes: boolean;
2022-07-01 18:55:45 +09:00
}>(), {
disableNotes: false,
2022-07-01 18:55:45 +09:00
});
const router = useRouter();
let parallaxAnimationId = $ref<null | number>(null);
let narrow = $ref<null | boolean>(null);
let rootEl = $ref<null | HTMLElement>(null);
let bannerEl = $ref<null | HTMLElement>(null);
let memoTextareaEl = $ref<null | HTMLElement>(null);
let memoDraft = $ref(props.user.memo);
let isEditingMemo = $ref(false);
2022-07-01 18:55:45 +09:00
const pagination = {
endpoint: 'users/notes' as const,
limit: 10,
params: computed(() => ({
userId: props.user.id,
})),
};
2022-07-01 18:55:45 +09:00
const style = $computed(() => {
if (props.user.bannerUrl == null) return {};
return {
backgroundImage: `url(${ props.user.bannerUrl })`,
};
});
const age = $computed(() => {
return calcAge(props.user.birthday);
});
function menu(ev) {
2022-07-16 16:52:12 +09:00
os.popupMenu(getUserMenu(props.user, router), ev.currentTarget ?? ev.target);
2022-07-01 18:55:45 +09:00
}
function parallaxLoop() {
parallaxAnimationId = window.requestAnimationFrame(parallaxLoop);
parallax();
}
function parallax() {
const banner = bannerEl as any;
if (banner == null) return;
const top = getScrollPosition(rootEl);
if (top < 0) return;
const z = 1.75; // 奥行き(小さいほど奥)
const pos = -(top / z);
banner.style.backgroundPosition = `center calc(50% - ${pos}px)`;
}
function showMemoTextarea() {
isEditingMemo = true;
nextTick(() => {
memoTextareaEl?.focus();
});
}
function adjustMemoTextarea() {
if (!memoTextareaEl) return;
memoTextareaEl.style.height = '0px';
memoTextareaEl.style.height = `${memoTextareaEl.scrollHeight}px`;
}
async function updateMemo() {
await api('users/update-memo', {
memo: memoDraft,
userId: props.user.id,
});
isEditingMemo = false;
}
watch([props.user], () => {
memoDraft = props.user.memo;
});
2022-07-01 18:55:45 +09:00
onMounted(() => {
window.requestAnimationFrame(parallaxLoop);
narrow = rootEl!.clientWidth < 1000;
if (props.user.birthday) {
const m = new Date().getMonth() + 1;
const d = new Date().getDate();
const bm = parseInt(props.user.birthday.split('-')[1]);
const bd = parseInt(props.user.birthday.split('-')[2]);
if (m === bm && d === bd) {
2023-01-06 20:25:08 +09:00
confetti({
duration: 1000 * 4,
2023-01-06 20:25:08 +09:00
});
}
}
nextTick(() => {
adjustMemoTextarea();
});
2022-07-01 18:55:45 +09:00
});
onUnmounted(() => {
if (parallaxAnimationId) {
window.cancelAnimationFrame(parallaxAnimationId);
}
});
</script>
<style lang="scss" scoped>
2022-07-01 18:55:45 +09:00
.ftskorzw {
> .main {
> .punished {
font-size: 0.8em;
padding: 16px;
}
> .profile {
> .main {
position: relative;
overflow: clip;
2022-07-01 18:55:45 +09:00
> .banner-container {
position: relative;
height: 250px;
overflow: clip;
2022-07-01 18:55:45 +09:00
background-size: cover;
background-position: center;
> .banner {
height: 100%;
background-color: #4c5e6d;
background-size: cover;
background-position: center;
box-shadow: 0 0 128px rgba(0, 0, 0, 0.5) inset;
will-change: background-position;
}
> .fade {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 78px;
background: linear-gradient(transparent, rgba(#000, 0.7));
}
> .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;
}
> .actions {
position: absolute;
top: 12px;
right: 12px;
-webkit-backdrop-filter: var(--blur, blur(8px));
backdrop-filter: var(--blur, blur(8px));
background: rgba(0, 0, 0, 0.2);
padding: 8px;
border-radius: 24px;
> .menu {
vertical-align: bottom;
height: 31px;
width: 31px;
color: #fff;
text-shadow: 0 0 8px #000;
font-size: 16px;
}
> .koudoku {
margin-left: 4px;
vertical-align: bottom;
}
}
> .title {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 0 0 8px 154px;
box-sizing: border-box;
color: #fff;
> .name {
display: block;
margin: 0;
line-height: 32px;
font-weight: bold;
font-size: 1.8em;
text-shadow: 0 0 8px #000;
}
> .bottom {
> * {
display: inline-block;
margin-right: 16px;
line-height: 20px;
opacity: 0.8;
&.username {
font-weight: bold;
}
}
> .add-note-button {
background: rgba(0, 0, 0, 0.2);
color: #fff;
-webkit-backdrop-filter: var(--blur, blur(8px));
backdrop-filter: var(--blur, blur(8px));
border-radius: 24px;
padding: 4px 8px;
font-size: 80%;
}
2022-07-01 18:55:45 +09:00
}
}
}
> .title {
display: none;
text-align: center;
padding: 50px 8px 16px 8px;
font-weight: bold;
border-bottom: solid 0.5px var(--divider);
> .bottom {
> * {
display: inline-block;
margin-right: 8px;
opacity: 0.8;
}
}
}
> .avatar {
display: block;
position: absolute;
top: 170px;
left: 16px;
z-index: 2;
width: 120px;
height: 120px;
box-shadow: 1px 1px 3px rgba(#000, 0.2);
}
> .roles {
padding: 24px 24px 0 154px;
font-size: 0.95em;
display: flex;
flex-wrap: wrap;
gap: 8px;
> .role {
border: solid 1px var(--color, var(--divider));
border-radius: 999px;
margin-right: 4px;
padding: 3px 8px;
}
}
> .memo {
margin: 12px 24px 0 154px;
background: transparent;
color: var(--fg);
border: 1px solid var(--divider);
border-radius: 8px;
padding: 8px;
line-height: 0;
> .heading {
text-align: left;
color: var(--fgTransparent);
line-height: 1.5;
}
textarea {
margin: 0;
padding: 0;
resize: none;
border: none;
outline: none;
width: 100%;
height: auto;
min-height: 0;
line-height: 1.5;
color: var(--fg);
overflow: hidden;
background: transparent;
font-family: inherit;
}
}
2022-07-01 18:55:45 +09:00
> .description {
padding: 24px 24px 24px 154px;
font-size: 0.95em;
> .empty {
margin: 0;
opacity: 0.5;
}
}
> .fields {
padding: 24px;
font-size: 0.9em;
border-top: solid 0.5px var(--divider);
> .field {
display: flex;
padding: 0;
margin: 0;
align-items: center;
&:not(:last-child) {
margin-bottom: 8px;
}
> .name {
width: 30%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-weight: bold;
text-align: center;
}
> .value {
width: 70%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0;
}
}
&.system > .field > .name {
}
}
> .status {
display: flex;
padding: 24px;
border-top: solid 0.5px var(--divider);
> a {
flex: 1;
text-align: center;
&.active {
color: var(--accent);
}
&:hover {
text-decoration: none;
}
> b {
display: block;
line-height: 16px;
}
> span {
font-size: 70%;
}
}
}
}
}
> .contents {
> .content {
margin-bottom: var(--margin);
}
}
}
&.wide {
display: flex;
width: 100%;
> .main {
width: 100%;
min-width: 0;
}
> .sub {
max-width: 350px;
min-width: 350px;
margin-left: var(--margin);
}
}
}
@container (max-width: 500px) {
.ftskorzw {
> .main {
> .profile > .main {
> .banner-container {
height: 140px;
> .fade {
display: none;
}
> .title {
display: none;
}
}
> .title {
display: block;
}
> .avatar {
top: 90px;
left: 0;
right: 0;
width: 92px;
height: 92px;
margin: auto;
}
> .roles {
padding: 16px 16px 0 16px;
justify-content: center;
}
> .memo {
margin: 16px 16px 0 16px;
}
> .description {
padding: 16px;
text-align: center;
}
> .fields {
padding: 16px;
}
> .status {
padding: 16px;
}
}
> .contents {
> .nav {
font-size: 80%;
}
}
}
}
}
2022-07-01 18:55:45 +09:00
</style>
2023-02-12 17:42:34 +09:00
<style lang="scss" module>
.tl {
background: var(--bg);
border-radius: var(--radius);
overflow: clip;
}
</style>