2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header>
|
|
|
|
<MkPageHeader
|
|
|
|
v-model:tab="src"
|
|
|
|
:actions="headerActions"
|
|
|
|
:tabs="headerTabs"
|
|
|
|
:display-my-avatar="true"
|
2024-02-29 14:21:19 +01:00
|
|
|
:class="{ isMobile: 'xytnxiau' }"
|
2022-08-16 09:00:36 +02:00
|
|
|
/>
|
2023-04-08 02:01:42 +02:00
|
|
|
</template>
|
2024-02-29 14:21:19 +01:00
|
|
|
<MkSpacer :content-max="800" :class="{ isMobile: 'upsvvhaz' }">
|
2023-04-08 02:01:42 +02:00
|
|
|
<div ref="rootEl" v-hotkey.global="keymap" class="cmuxhskf">
|
|
|
|
<XPostForm
|
2023-10-17 03:57:20 +02:00
|
|
|
v-if="defaultStore.reactiveState.showFixedPostForm.value"
|
2023-04-08 02:01:42 +02:00
|
|
|
class="post-form _block"
|
|
|
|
fixed
|
|
|
|
/>
|
|
|
|
<!-- <div v-if="!isMobile" class="tl _block">
|
2022-08-16 09:00:36 +02:00
|
|
|
<XTimeline
|
|
|
|
ref="tl"
|
|
|
|
:key="src"
|
|
|
|
class="tl"
|
|
|
|
:src="src"
|
|
|
|
:sound="true"
|
|
|
|
@queue="queueUpdated"
|
2022-08-16 04:18:54 +02:00
|
|
|
/>
|
2022-09-06 03:13:17 +02:00
|
|
|
</div> *v-else on next div* -->
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="tl _block">
|
2023-05-26 04:47:10 +02:00
|
|
|
<swiper
|
2023-05-26 23:02:17 +02:00
|
|
|
:round-lengths="true"
|
2023-05-26 04:47:10 +02:00
|
|
|
:touch-angle="25"
|
|
|
|
:threshold="10"
|
2023-09-02 01:27:33 +02:00
|
|
|
:centered-slides="true"
|
2023-04-08 02:01:42 +02:00
|
|
|
:modules="[Virtual]"
|
|
|
|
:space-between="20"
|
|
|
|
:virtual="true"
|
2023-06-26 21:47:05 +02:00
|
|
|
:allow-touch-move="
|
|
|
|
defaultStore.state.swipeOnMobile &&
|
|
|
|
(deviceKind !== 'desktop' ||
|
|
|
|
defaultStore.state.swipeOnDesktop)
|
|
|
|
"
|
2023-04-08 02:01:42 +02:00
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
2022-08-28 00:49:10 +02:00
|
|
|
>
|
2023-04-08 02:01:42 +02:00
|
|
|
<swiper-slide
|
|
|
|
v-for="index in timelines"
|
|
|
|
:key="index"
|
|
|
|
:virtual-index="index"
|
|
|
|
>
|
|
|
|
<XTimeline
|
2023-05-26 01:32:56 +02:00
|
|
|
v-if="index == timelines[swiperRef.activeIndex]"
|
2023-04-08 02:01:42 +02:00
|
|
|
ref="tl"
|
|
|
|
:key="src"
|
|
|
|
class="tl"
|
|
|
|
:src="src"
|
|
|
|
:sound="true"
|
|
|
|
/>
|
|
|
|
</swiper-slide>
|
|
|
|
</swiper>
|
|
|
|
</div>
|
2022-08-23 07:31:00 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-16 07:02:15 +01:00
|
|
|
<script lang="ts" setup>
|
2023-09-02 01:27:33 +02:00
|
|
|
import { computed, onMounted, ref } from "vue";
|
2023-07-11 06:16:56 +02:00
|
|
|
import { Virtual } from "swiper/modules";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { Swiper, SwiperSlide } from "swiper/vue";
|
|
|
|
import XTutorial from "@/components/MkTutorialDialog.vue";
|
|
|
|
import XTimeline from "@/components/MkTimeline.vue";
|
|
|
|
import XPostForm from "@/components/MkPostForm.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { defaultStore } from "@/store";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { instance } from "@/instance";
|
2024-03-01 16:19:05 +01:00
|
|
|
import { isModerator, isSignedIn } from "@/reactiveAccount";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
|
|
|
import { deviceKind } from "@/scripts/device-kind";
|
2023-10-17 03:57:20 +02:00
|
|
|
import icon from "@/scripts/icon";
|
2023-04-08 02:01:42 +02:00
|
|
|
import "swiper/scss";
|
|
|
|
import "swiper/scss/virtual";
|
2022-08-16 03:43:17 +02:00
|
|
|
|
2024-01-11 02:21:21 +01:00
|
|
|
if (isSignedIn && defaultStore.reactiveState.tutorial.value !== -1) {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.popup(XTutorial, {}, {}, "closed");
|
2022-11-09 08:51:59 +01:00
|
|
|
}
|
2022-01-16 07:02:15 +01:00
|
|
|
|
2024-03-01 16:19:05 +01:00
|
|
|
const isHomeTimelineAvailable = isSignedIn;
|
2022-08-16 04:18:54 +02:00
|
|
|
const isLocalTimelineAvailable =
|
2024-01-11 02:21:21 +01:00
|
|
|
(!instance.disableLocalTimeline &&
|
|
|
|
(isSignedIn || instance.enableGuestTimeline)) ||
|
|
|
|
isModerator;
|
|
|
|
const isSocialTimelineAvailable = isLocalTimelineAvailable && isSignedIn;
|
|
|
|
const isRecommendedTimelineAvailable =
|
|
|
|
!instance.disableRecommendedTimeline && isSignedIn;
|
2022-08-16 04:18:54 +02:00
|
|
|
const isGlobalTimelineAvailable =
|
2024-01-11 02:21:21 +01:00
|
|
|
(!instance.disableGlobalTimeline &&
|
|
|
|
(isSignedIn || instance.enableGuestTimeline)) ||
|
|
|
|
isModerator;
|
2022-01-16 07:02:15 +01:00
|
|
|
const keymap = {
|
2022-08-16 04:18:54 +02:00
|
|
|
t: focus,
|
2022-01-16 07:02:15 +01:00
|
|
|
};
|
|
|
|
|
2024-03-01 16:19:05 +01:00
|
|
|
const timelines = [];
|
2022-09-06 03:42:01 +02:00
|
|
|
|
2024-03-01 16:19:05 +01:00
|
|
|
if (isHomeTimelineAvailable) {
|
|
|
|
timelines.push("home");
|
2022-09-06 03:42:01 +02:00
|
|
|
}
|
2024-03-01 16:19:05 +01:00
|
|
|
if (isSocialTimelineAvailable) {
|
2023-05-15 00:20:26 +02:00
|
|
|
timelines.push("social");
|
2023-05-15 00:18:18 +02:00
|
|
|
}
|
2023-06-01 00:24:49 +02:00
|
|
|
if (isRecommendedTimelineAvailable) {
|
|
|
|
timelines.push("recommended");
|
|
|
|
}
|
2024-03-01 16:19:05 +01:00
|
|
|
if (isLocalTimelineAvailable) {
|
|
|
|
timelines.push("local");
|
|
|
|
}
|
2022-09-06 03:42:01 +02:00
|
|
|
if (isGlobalTimelineAvailable) {
|
2023-04-08 02:01:42 +02:00
|
|
|
timelines.push("global");
|
2022-09-06 03:42:01 +02:00
|
|
|
}
|
|
|
|
|
2022-08-16 03:43:17 +02:00
|
|
|
const MOBILE_THRESHOLD = 500;
|
|
|
|
|
|
|
|
// デスクトップでウィンドウを狭くしたときモバイルUIが表示されて欲しいことはあるので deviceKind === 'desktop' の判定は行わない
|
2022-08-16 04:18:54 +02:00
|
|
|
const isMobile = ref(
|
2023-07-06 03:28:27 +02:00
|
|
|
deviceKind === "smartphone" || window.innerWidth <= MOBILE_THRESHOLD,
|
2022-08-16 04:18:54 +02:00
|
|
|
);
|
2023-04-08 02:01:42 +02:00
|
|
|
window.addEventListener("resize", () => {
|
2022-08-16 04:18:54 +02:00
|
|
|
isMobile.value =
|
2023-04-08 02:01:42 +02:00
|
|
|
deviceKind === "smartphone" || window.innerWidth <= MOBILE_THRESHOLD;
|
2022-08-16 03:43:17 +02:00
|
|
|
});
|
|
|
|
|
2023-08-12 02:44:46 +02:00
|
|
|
const tlComponent = ref<InstanceType<typeof XTimeline>>();
|
|
|
|
const rootEl = ref<HTMLElement>();
|
2022-01-16 07:02:15 +01:00
|
|
|
|
2024-03-01 16:19:05 +01:00
|
|
|
const timelineIndex = (timeline: string): number => {
|
|
|
|
const index = timelines.indexOf(timeline);
|
|
|
|
return index === -1 ? 0 : index;
|
|
|
|
};
|
|
|
|
|
2023-08-12 02:44:46 +02:00
|
|
|
const src = computed({
|
2022-09-09 22:47:19 +02:00
|
|
|
get: () => defaultStore.reactiveState.tl.value.src,
|
2022-09-06 03:34:48 +02:00
|
|
|
set: (x) => {
|
|
|
|
saveSrc(x);
|
2024-03-01 16:19:05 +01:00
|
|
|
syncSlide(timelineIndex(x));
|
2022-09-06 03:34:48 +02:00
|
|
|
},
|
2022-08-16 04:18:54 +02:00
|
|
|
});
|
2022-02-04 00:39:20 +01:00
|
|
|
|
2023-06-06 02:15:17 +02:00
|
|
|
async function chooseList(ev: MouseEvent) {
|
2024-03-01 16:19:05 +01:00
|
|
|
await os.api("users/lists/list").then((res) => {
|
2023-06-06 02:15:17 +02:00
|
|
|
const items = [
|
|
|
|
{
|
|
|
|
type: "link" as const,
|
|
|
|
text: i18n.ts.manageLists,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-faders-horizontal")}`,
|
2023-06-06 02:15:17 +02:00
|
|
|
to: "/my/lists",
|
|
|
|
},
|
|
|
|
].concat(
|
|
|
|
res.map((list) => ({
|
|
|
|
type: "link" as const,
|
|
|
|
text: list.name,
|
|
|
|
icon: "",
|
|
|
|
to: `/timeline/list/${list.id}`,
|
2023-07-06 03:28:27 +02:00
|
|
|
})),
|
2023-06-06 02:15:17 +02:00
|
|
|
);
|
|
|
|
os.popupMenu(items, ev.currentTarget ?? ev.target);
|
|
|
|
});
|
2022-01-16 07:02:15 +01:00
|
|
|
}
|
|
|
|
|
2023-06-06 02:15:17 +02:00
|
|
|
async function chooseAntenna(ev: MouseEvent) {
|
2024-03-01 16:19:05 +01:00
|
|
|
await os.api("antennas/list").then((res) => {
|
2023-06-06 02:15:17 +02:00
|
|
|
const items = [
|
|
|
|
{
|
|
|
|
type: "link" as const,
|
|
|
|
indicate: false,
|
|
|
|
text: i18n.ts.manageAntennas,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-faders-horizontal")}`,
|
2023-06-06 02:15:17 +02:00
|
|
|
to: "/my/antennas",
|
|
|
|
},
|
|
|
|
].concat(
|
|
|
|
res.map((antenna) => ({
|
|
|
|
type: "link" as const,
|
|
|
|
text: antenna.name,
|
|
|
|
icon: "",
|
|
|
|
indicate: antenna.hasUnreadNote,
|
|
|
|
to: `/timeline/antenna/${antenna.id}`,
|
2023-07-06 03:28:27 +02:00
|
|
|
})),
|
2023-06-06 02:15:17 +02:00
|
|
|
);
|
|
|
|
os.popupMenu(items, ev.currentTarget ?? ev.target);
|
|
|
|
});
|
2022-01-16 07:02:15 +01:00
|
|
|
}
|
|
|
|
|
2022-08-16 04:18:54 +02:00
|
|
|
function saveSrc(
|
2023-07-06 03:28:27 +02:00
|
|
|
newSrc: "home" | "local" | "social" | "recommended" | "global",
|
2022-08-16 04:18:54 +02:00
|
|
|
): void {
|
2023-04-08 02:01:42 +02:00
|
|
|
defaultStore.set("tl", {
|
2022-02-04 00:39:20 +01:00
|
|
|
...defaultStore.state.tl,
|
|
|
|
src: newSrc,
|
2022-01-16 07:02:15 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function focus(): void {
|
2023-08-12 02:44:46 +02:00
|
|
|
tlComponent.value.focus();
|
2022-01-16 07:02:15 +01:00
|
|
|
}
|
|
|
|
|
2024-03-01 16:19:05 +01:00
|
|
|
const headerActions = computed(() =>
|
|
|
|
isSignedIn
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
icon: `${icon("ph-list-bullets")}`,
|
|
|
|
title: i18n.ts.lists,
|
|
|
|
text: i18n.ts.lists,
|
|
|
|
iconOnly: true,
|
|
|
|
handler: chooseList,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: `${icon("ph-flying-saucer")}`,
|
|
|
|
title: i18n.ts.antennas,
|
|
|
|
text: i18n.ts.antennas,
|
|
|
|
iconOnly: true,
|
|
|
|
handler: chooseAntenna,
|
|
|
|
} /* **TODO: fix timetravel** {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon('ph-calendar-blank')}`,
|
2022-07-26 23:29:52 +02:00
|
|
|
title: i18n.ts.jumpToSpecifiedDate,
|
|
|
|
iconOnly: true,
|
2022-07-26 23:35:12 +02:00
|
|
|
handler: timetravel,
|
2023-09-02 01:27:33 +02:00
|
|
|
} */,
|
2024-03-01 16:19:05 +01:00
|
|
|
]
|
|
|
|
: [],
|
|
|
|
);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-08-12 02:44:46 +02:00
|
|
|
const headerTabs = computed(() => [
|
2024-03-01 16:19:05 +01:00
|
|
|
...(isHomeTimelineAvailable
|
2022-08-16 04:18:54 +02:00
|
|
|
? [
|
2023-04-08 02:01:42 +02:00
|
|
|
{
|
2024-03-01 16:19:05 +01:00
|
|
|
key: "home",
|
|
|
|
title: i18n.ts._timelines.home,
|
|
|
|
icon: `${icon("ph-house")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
iconOnly: true,
|
|
|
|
},
|
2024-02-11 18:50:57 +01:00
|
|
|
]
|
2022-08-16 04:18:54 +02:00
|
|
|
: []),
|
2024-03-01 16:19:05 +01:00
|
|
|
...(isSocialTimelineAvailable
|
2023-03-23 17:02:37 +01:00
|
|
|
? [
|
2023-04-08 02:01:42 +02:00
|
|
|
{
|
2023-06-01 00:24:49 +02:00
|
|
|
key: "social",
|
|
|
|
title: i18n.ts._timelines.social,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-handshake")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
iconOnly: true,
|
|
|
|
},
|
2024-02-11 18:50:57 +01:00
|
|
|
]
|
2023-03-23 17:02:37 +01:00
|
|
|
: []),
|
2023-06-01 00:24:49 +02:00
|
|
|
...(isRecommendedTimelineAvailable
|
2023-05-15 00:18:18 +02:00
|
|
|
? [
|
2023-05-15 00:20:26 +02:00
|
|
|
{
|
2023-06-01 00:24:49 +02:00
|
|
|
key: "recommended",
|
|
|
|
title: i18n.ts._timelines.recommended,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-thumbs-up")}`,
|
2023-05-15 00:20:26 +02:00
|
|
|
iconOnly: true,
|
|
|
|
},
|
2024-02-11 18:50:57 +01:00
|
|
|
]
|
2023-05-15 00:18:18 +02:00
|
|
|
: []),
|
2024-03-01 16:19:05 +01:00
|
|
|
...(isLocalTimelineAvailable
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
key: "local",
|
|
|
|
title: i18n.ts._timelines.local,
|
|
|
|
icon: `${icon("ph-users")}`,
|
|
|
|
iconOnly: true,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []),
|
2022-08-16 04:18:54 +02:00
|
|
|
...(isGlobalTimelineAvailable
|
|
|
|
? [
|
2023-04-08 02:01:42 +02:00
|
|
|
{
|
|
|
|
key: "global",
|
|
|
|
title: i18n.ts._timelines.global,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-planet")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
iconOnly: true,
|
|
|
|
},
|
2024-02-11 18:50:57 +01:00
|
|
|
]
|
2022-08-16 04:18:54 +02:00
|
|
|
: []),
|
|
|
|
]);
|
2022-07-16 17:42:02 +02:00
|
|
|
|
2022-08-16 04:18:54 +02:00
|
|
|
definePageMetadata(
|
|
|
|
computed(() => ({
|
|
|
|
title: i18n.ts.timeline,
|
|
|
|
icon:
|
2023-08-12 02:44:46 +02:00
|
|
|
src.value === "local"
|
2023-10-17 03:57:20 +02:00
|
|
|
? "ph-users ph-lg"
|
2023-08-12 02:44:46 +02:00
|
|
|
: src.value === "social"
|
2024-02-11 18:50:57 +01:00
|
|
|
? "ph-handshake ph-lg"
|
|
|
|
: src.value === "recommended"
|
|
|
|
? "ph-thumbs-up ph-lg"
|
|
|
|
: src.value === "global"
|
|
|
|
? "ph-planet ph-lg"
|
|
|
|
: "ph-house ph-lg",
|
2023-07-06 03:28:27 +02:00
|
|
|
})),
|
2022-08-16 04:18:54 +02:00
|
|
|
);
|
2022-08-28 00:49:10 +02:00
|
|
|
|
2022-11-10 01:58:35 +01:00
|
|
|
let swiperRef: any = null;
|
2022-08-28 00:49:10 +02:00
|
|
|
|
2022-09-06 03:13:17 +02:00
|
|
|
function setSwiperRef(swiper) {
|
2022-08-28 00:49:10 +02:00
|
|
|
swiperRef = swiper;
|
2024-03-01 16:19:05 +01:00
|
|
|
syncSlide(timelineIndex(src.value));
|
2022-09-06 03:13:17 +02:00
|
|
|
}
|
2022-08-28 00:49:10 +02:00
|
|
|
|
2022-09-06 03:13:17 +02:00
|
|
|
function onSlideChange() {
|
2022-09-06 03:34:48 +02:00
|
|
|
saveSrc(timelines[swiperRef.activeIndex]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function syncSlide(index) {
|
|
|
|
swiperRef.slideTo(index);
|
2022-09-06 03:13:17 +02:00
|
|
|
}
|
2022-08-28 00:49:10 +02:00
|
|
|
|
2022-11-10 01:56:33 +01:00
|
|
|
onMounted(() => {
|
2024-03-01 16:19:05 +01:00
|
|
|
syncSlide(timelineIndex(swiperRef.activeIndex));
|
2022-11-10 01:58:35 +01:00
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
2020-02-09 13:31:17 +01:00
|
|
|
<style lang="scss" scoped>
|
2024-02-29 14:21:19 +01:00
|
|
|
.xytnxiau {
|
|
|
|
overflow-y: hidden;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.upsvvhaz {
|
|
|
|
padding-top: 67px;
|
|
|
|
}
|
|
|
|
|
2020-12-29 03:33:21 +01:00
|
|
|
.cmuxhskf {
|
2022-08-23 08:23:19 +02:00
|
|
|
--swiper-theme-color: var(--accent);
|
2021-09-17 15:39:15 +02:00
|
|
|
> .tl {
|
2023-05-12 02:38:54 +02:00
|
|
|
background: none;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|