2020-08-18 13:44:21 +00:00
|
|
|
<template>
|
2022-06-20 08:38:49 +00:00
|
|
|
<MkStickyContainer>
|
2023-02-25 09:26:35 +00:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-03-04 01:50:21 +00:00
|
|
|
<MkSpacer :content-max="700" :class="$style.main">
|
|
|
|
<div v-if="channel && tab === 'overview'" class="_gaps">
|
|
|
|
<div class="_panel" :class="$style.bannerContainer">
|
|
|
|
<XChannelFollowButton :channel="channel" :full="true" :class="$style.subscribe"/>
|
|
|
|
<div :style="{ backgroundImage: channel.bannerUrl ? `url(${channel.bannerUrl})` : null }" :class="$style.banner">
|
|
|
|
<div :class="$style.bannerStatus">
|
2022-12-19 10:01:30 +00:00
|
|
|
<div><i class="ti ti-users ti-fw"></i><I18n :src="i18n.ts._channel.usersCount" tag="span" style="margin-left: 4px;"><template #n><b>{{ channel.usersCount }}</b></template></I18n></div>
|
|
|
|
<div><i class="ti ti-pencil ti-fw"></i><I18n :src="i18n.ts._channel.notesCount" tag="span" style="margin-left: 4px;"><template #n><b>{{ channel.notesCount }}</b></template></I18n></div>
|
2022-06-20 08:38:49 +00:00
|
|
|
</div>
|
2023-03-04 01:50:21 +00:00
|
|
|
<div :class="$style.bannerFade"></div>
|
2022-06-20 08:38:49 +00:00
|
|
|
</div>
|
2023-03-04 01:50:21 +00:00
|
|
|
<div v-if="channel.description" :class="$style.description">
|
2022-06-20 08:38:49 +00:00
|
|
|
<Mfm :text="channel.description" :is-note="false" :i="$i"/>
|
2021-12-23 07:10:13 +00:00
|
|
|
</div>
|
2020-08-18 13:44:21 +00:00
|
|
|
</div>
|
2023-03-04 01:50:21 +00:00
|
|
|
</div>
|
|
|
|
<div v-if="channel && tab === 'timeline'" class="_gaps">
|
2023-02-24 01:31:21 +00:00
|
|
|
<!-- スマホ・タブレットの場合、キーボードが表示されると投稿が見づらくなるので、デスクトップ場合のみ自動でフォーカスを当てる -->
|
2023-03-04 01:34:54 +00:00
|
|
|
<MkPostForm v-if="$i && defaultStore.reactiveState.showFixedPostFormInChannel.value" :channel="channel" class="post-form _panel" fixed :autofocus="deviceKind === 'desktop'"/>
|
2020-08-18 13:44:21 +00:00
|
|
|
|
2023-02-25 09:26:35 +00:00
|
|
|
<MkTimeline :key="channelId" src="channel" :channel="channelId" @before="before" @after="after"/>
|
|
|
|
</div>
|
|
|
|
<div v-else-if="tab === 'featured'">
|
|
|
|
<MkNotes :pagination="featuredPagination"/>
|
2022-06-20 08:38:49 +00:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
2023-03-04 01:34:54 +00:00
|
|
|
<template #footer>
|
|
|
|
<div :class="$style.footer">
|
|
|
|
<MkSpacer :content-max="700" :margin-min="16" :margin-max="16">
|
|
|
|
<div class="_buttonsCenter">
|
|
|
|
<MkButton inline rounded primary gradate @click="openPostForm()"><i class="ti ti-pencil"></i> {{ i18n.ts.postToTheChannel }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-06-20 08:38:49 +00:00
|
|
|
</MkStickyContainer>
|
2020-08-18 13:44:21 +00:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
<script lang="ts" setup>
|
2023-02-16 14:09:41 +00:00
|
|
|
import { computed, watch } from 'vue';
|
2023-02-09 01:35:28 +00:00
|
|
|
import MkPostForm from '@/components/MkPostForm.vue';
|
2023-02-22 02:00:34 +00:00
|
|
|
import MkTimeline from '@/components/MkTimeline.vue';
|
2022-08-30 15:24:33 +00:00
|
|
|
import XChannelFollowButton from '@/components/MkChannelFollowButton.vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
2022-06-20 08:38:49 +00:00
|
|
|
import { useRouter } from '@/router';
|
2023-03-08 22:58:53 +00:00
|
|
|
import { $i, iAmModerator } from '@/account';
|
2022-06-20 08:38:49 +00:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2023-02-24 01:31:21 +00:00
|
|
|
import { deviceKind } from '@/scripts/device-kind';
|
2023-02-25 09:26:35 +00:00
|
|
|
import MkNotes from '@/components/MkNotes.vue';
|
2023-03-04 01:17:45 +00:00
|
|
|
import { url } from '@/config';
|
2023-03-04 01:34:54 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
|
|
|
import { defaultStore } from '@/store';
|
2020-08-18 13:44:21 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
const router = useRouter();
|
2020-08-18 13:44:21 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
const props = defineProps<{
|
|
|
|
channelId: string;
|
|
|
|
}>();
|
2020-08-18 13:44:21 +00:00
|
|
|
|
2023-02-25 09:26:35 +00:00
|
|
|
let tab = $ref('timeline');
|
2022-06-20 08:38:49 +00:00
|
|
|
let channel = $ref(null);
|
2023-02-25 09:26:35 +00:00
|
|
|
const featuredPagination = $computed(() => ({
|
|
|
|
endpoint: 'notes/featured' as const,
|
2022-06-20 08:38:49 +00:00
|
|
|
limit: 10,
|
2023-02-25 09:26:35 +00:00
|
|
|
offsetMode: true,
|
|
|
|
params: {
|
2022-06-20 08:38:49 +00:00
|
|
|
channelId: props.channelId,
|
2023-02-25 09:26:35 +00:00
|
|
|
},
|
|
|
|
}));
|
2020-08-18 13:44:21 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
watch(() => props.channelId, async () => {
|
|
|
|
channel = await os.api('channels/show', {
|
|
|
|
channelId: props.channelId,
|
|
|
|
});
|
|
|
|
}, { immediate: true });
|
2020-08-18 13:44:21 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
function edit() {
|
|
|
|
router.push(`/channels/${channel.id}/edit`);
|
|
|
|
}
|
|
|
|
|
2023-03-04 01:34:54 +00:00
|
|
|
function openPostForm() {
|
|
|
|
os.post({
|
|
|
|
channel: {
|
2023-03-05 11:48:46 +00:00
|
|
|
id: channel.id,
|
2023-03-04 01:34:54 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-03-08 22:58:53 +00:00
|
|
|
const headerActions = $computed(() => {
|
|
|
|
if (channel && channel.userId) {
|
|
|
|
const share = {
|
|
|
|
icon: 'ti ti-share',
|
|
|
|
text: i18n.ts.share,
|
|
|
|
handler: async (): Promise<void> => {
|
|
|
|
navigator.share({
|
|
|
|
title: channel.name,
|
|
|
|
text: channel.description,
|
|
|
|
url: `${url}/channels/${channel.id}`,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const canEdit = ($i && $i.id === channel.userId) || iAmModerator;
|
|
|
|
return canEdit ? [share, {
|
|
|
|
icon: 'ti ti-settings',
|
|
|
|
text: i18n.ts.edit,
|
|
|
|
handler: edit,
|
|
|
|
}] : [share];
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
});
|
2022-06-20 08:38:49 +00:00
|
|
|
|
2023-02-25 09:26:35 +00:00
|
|
|
const headerTabs = $computed(() => [{
|
2023-03-04 01:50:21 +00:00
|
|
|
key: 'overview',
|
|
|
|
title: i18n.ts.overview,
|
|
|
|
icon: 'ti ti-info-circle',
|
|
|
|
}, {
|
2023-02-25 09:26:35 +00:00
|
|
|
key: 'timeline',
|
|
|
|
title: i18n.ts.timeline,
|
|
|
|
icon: 'ti ti-home',
|
|
|
|
}, {
|
|
|
|
key: 'featured',
|
|
|
|
title: i18n.ts.featured,
|
|
|
|
icon: 'ti ti-bolt',
|
|
|
|
}]);
|
2022-06-20 08:38:49 +00:00
|
|
|
|
|
|
|
definePageMetadata(computed(() => channel ? {
|
|
|
|
title: channel.name,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-device-tv',
|
2022-06-20 08:38:49 +00:00
|
|
|
} : null));
|
2020-08-18 13:44:21 +00:00
|
|
|
</script>
|
|
|
|
|
2023-03-04 01:34:54 +00:00
|
|
|
<style lang="scss" module>
|
2023-03-04 01:50:21 +00:00
|
|
|
.main {
|
|
|
|
min-height: calc(var(--containerHeight) - (var(--stickyTop, 0px) + var(--stickyBottom, 0px)));
|
|
|
|
}
|
|
|
|
|
2023-03-04 01:34:54 +00:00
|
|
|
.footer {
|
|
|
|
-webkit-backdrop-filter: var(--blur, blur(15px));
|
|
|
|
backdrop-filter: var(--blur, blur(15px));
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
}
|
|
|
|
|
2023-03-04 01:50:21 +00:00
|
|
|
.bannerContainer {
|
2020-10-18 03:16:42 +00:00
|
|
|
position: relative;
|
2023-03-04 01:50:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.subscribe {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
top: 16px;
|
|
|
|
left: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.banner {
|
|
|
|
position: relative;
|
|
|
|
height: 200px;
|
|
|
|
background-position: center;
|
|
|
|
background-size: cover;
|
|
|
|
}
|
|
|
|
|
|
|
|
.bannerFade {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 64px;
|
|
|
|
background: linear-gradient(0deg, var(--panel), var(--X15));
|
|
|
|
}
|
|
|
|
|
|
|
|
.bannerStatus {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
bottom: 16px;
|
|
|
|
right: 16px;
|
|
|
|
padding: 8px 12px;
|
|
|
|
font-size: 80%;
|
|
|
|
background: rgba(0, 0, 0, 0.7);
|
|
|
|
border-radius: 6px;
|
|
|
|
color: #fff;
|
|
|
|
}
|
2020-10-18 03:16:42 +00:00
|
|
|
|
2023-03-04 01:50:21 +00:00
|
|
|
.description {
|
|
|
|
padding: 16px;
|
2020-08-18 13:44:21 +00:00
|
|
|
}
|
|
|
|
</style>
|