ユーザTLの余白をクリックして上部に戻れるように
This commit is contained in:
parent
2c0d72fc1b
commit
322f132da1
|
@ -710,6 +710,7 @@ function loadConversation() {
|
|||
.noteHeaderInstanceIcon {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.noteHeaderUsername {
|
||||
|
|
|
@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<a :href="`/@${user.username}`" target="_blank" rel="noopener noreferrer" :class="$style.avatarLink">
|
||||
<MkAvatar :class="$style.avatar" :user="user"/>
|
||||
</a>
|
||||
<div :class="$style.headerTitle">
|
||||
<div :class="$style.headerTitle" @click="top">
|
||||
<I18n :src="i18n.ts.noteOf" tag="div">
|
||||
<template #user>
|
||||
<a :href="`/@${user.username}`" target="_blank" rel="noopener noreferrer">
|
||||
|
@ -29,8 +29,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</a>
|
||||
</div>
|
||||
<MkNotes
|
||||
ref="notesEl"
|
||||
:class="$style.userTimelineNotes"
|
||||
:pagination="pagination"
|
||||
:disableAutoLoad="!normalizedEnableAutoLoad"
|
||||
:noGap="true"
|
||||
:ad="false"
|
||||
/>
|
||||
|
@ -40,7 +42,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref, computed, shallowRef } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import MkNotes from '@/components/MkNotes.vue';
|
||||
import XNotFound from '@/pages/not-found.vue';
|
||||
|
@ -49,14 +51,21 @@ import { misskeyApi } from '@/scripts/misskey-api.js';
|
|||
import { i18n } from '@/i18n.js';
|
||||
import { instance } from '@/instance.js';
|
||||
import { url, instanceName } from '@/config.js';
|
||||
import { scrollToTop } from '@/scripts/scroll.js';
|
||||
import { isLink } from '@/scripts/is-link.js';
|
||||
|
||||
const props = defineProps<{
|
||||
username: string;
|
||||
showHeader?: string;
|
||||
enableAutoLoad?: string;
|
||||
}>();
|
||||
|
||||
// デフォルト: true
|
||||
const normalizedShowHeader = computed(() => props.showHeader !== 'false');
|
||||
|
||||
// デフォルト: false
|
||||
const normalizedEnableAutoLoad = computed(() => props.enableAutoLoad === 'true');
|
||||
|
||||
const user = ref<Misskey.entities.UserLite | null>(null);
|
||||
const pagination = computed(() => ({
|
||||
endpoint: 'users/notes',
|
||||
|
@ -66,6 +75,17 @@ const pagination = computed(() => ({
|
|||
} as Paging));
|
||||
const loading = ref(true);
|
||||
|
||||
const notesEl = shallowRef<InstanceType<typeof MkNotes> | null>(null);
|
||||
|
||||
function top(ev: MouseEvent) {
|
||||
const target = ev.target as HTMLElement | null;
|
||||
if (target && isLink(target)) return;
|
||||
|
||||
if (notesEl.value) {
|
||||
scrollToTop(notesEl.value.$el as HTMLElement, { behavior: 'smooth' });
|
||||
}
|
||||
}
|
||||
|
||||
misskeyApi('users/show', {
|
||||
username: props.username,
|
||||
}).then(res => {
|
||||
|
@ -106,6 +126,7 @@ misskeyApi('users/show', {
|
|||
}
|
||||
|
||||
.headerTitle {
|
||||
flex-grow: 1;
|
||||
font-weight: 700;
|
||||
line-height: 1.1;
|
||||
|
||||
|
@ -117,6 +138,7 @@ misskeyApi('users/show', {
|
|||
}
|
||||
|
||||
.instanceIconLink {
|
||||
flex-shrink: 0;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
height: 24px;
|
||||
|
|
|
@ -563,6 +563,7 @@ const routes: RouteDef[] = [{
|
|||
component: page(() => import('@/pages/embed/user-timeline.vue')),
|
||||
query: {
|
||||
header: 'showHeader',
|
||||
autoload: 'enableAutoLoad',
|
||||
}
|
||||
}, {
|
||||
path: '/timeline',
|
||||
|
|
12
packages/frontend/src/scripts/is-link.ts
Normal file
12
packages/frontend/src/scripts/is-link.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export function isLink(el: HTMLElement) {
|
||||
if (el.tagName === 'A') return true;
|
||||
if (el.parentElement) {
|
||||
return isLink(el.parentElement);
|
||||
}
|
||||
return false;
|
||||
};
|
|
@ -10,6 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
$style.rootForEmbedPage,
|
||||
{
|
||||
[$style.rounded]: embedRounded,
|
||||
[$style.noBorder]: embedNoBorder,
|
||||
}
|
||||
]"
|
||||
:style="maxHeight > 0 ? { maxHeight: `${maxHeight}px`, '--embedMaxHeight': `${maxHeight}px` } : {}"
|
||||
|
@ -65,6 +66,7 @@ provide('EMBED_PAGE', true);
|
|||
//#region Embed Style
|
||||
const params = new URLSearchParams(location.search);
|
||||
const embedRounded = ref(params.get('rounded') !== 'false');
|
||||
const embedNoBorder = ref(params.get('border') === 'false');
|
||||
const maxHeight = ref(params.get('maxHeight') ? parseInt(params.get('maxHeight')!) : 0);
|
||||
//#endregion
|
||||
|
||||
|
@ -73,7 +75,7 @@ const rootEl = shallowRef<HTMLElement | null>(null);
|
|||
|
||||
let previousHeight = 0;
|
||||
const resizeObserver = new ResizeObserver(async () => {
|
||||
const height = rootEl.value!.scrollHeight + 2; // border 上下1px
|
||||
const height = rootEl.value!.scrollHeight + (embedNoBorder.value ? 0 : 2); // border 上下1px
|
||||
if (Math.abs(previousHeight - height) < 1) return; // 1px未満の変化は無視
|
||||
postMessageToParentWindow('misskey:embed:changeHeight', {
|
||||
height: (maxHeight.value > 0 && height > maxHeight.value) ? maxHeight.value : height,
|
||||
|
@ -106,6 +108,10 @@ if (_DEV_) document.documentElement.classList.add('embed');
|
|||
&.rounded {
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
&.noBorder {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.routerViewContainer {
|
||||
|
|
Loading…
Reference in a new issue