From 49beee532b82972333e49da3647b6451f1a138a0 Mon Sep 17 00:00:00 2001 From: futchitwo <74236683+futchitwo@users.noreply.github.com> Date: Sat, 2 Jul 2022 20:08:31 +0900 Subject: [PATCH] feature(client): Timeline page for non-login users --- packages/client/src/components/global/page-header.vue | 3 +++ packages/client/src/pages/timeline.vue | 11 +++++++++-- packages/client/src/router.ts | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/client/src/components/global/page-header.vue b/packages/client/src/components/global/page-header.vue index 5395a8796..9109436bd 100644 --- a/packages/client/src/components/global/page-header.vue +++ b/packages/client/src/components/global/page-header.vue @@ -39,6 +39,7 @@ import tinycolor from 'tinycolor2'; import { popupMenu } from '@/os'; import { scrollToTop } from '@/scripts/scroll'; import { i18n } from '@/i18n'; +import { $i } from '@/account'; import { globalEvents } from '@/events'; import { injectPageMetadata } from '@/scripts/page-metadata'; @@ -47,6 +48,7 @@ type Tab = { title: string; icon?: string; iconOnly?: boolean; + loginRequired?: boolean; onClick?: (ev: MouseEvent) => void; }; @@ -71,6 +73,7 @@ const hideTitle = inject('shouldOmitHeaderTitle', false); const thin_ = props.thin || inject('shouldHeaderThin', false); const el = $ref(null); +const tabs = $i ? props.tabs : props.tabs?.filter(tab => !tab.loginRequired); const tabRefs = {}; const tabHighlightEl = $ref(null); const bg = ref(null); diff --git a/packages/client/src/pages/timeline.vue b/packages/client/src/pages/timeline.vue index 40eb85ff4..09de90199 100644 --- a/packages/client/src/pages/timeline.vue +++ b/packages/client/src/pages/timeline.vue @@ -3,7 +3,7 @@
- +
@@ -45,7 +45,8 @@ const tlComponent = $ref>(); const rootEl = $ref(); let queue = $ref(0); -const src = $computed({ get: () => defaultStore.reactiveState.tl.value.src, set: (x) => saveSrc(x) }); +const src = $computed({ get: () => ($i ? defaultStore.reactiveState.tl.value.src : logoutSrc), set: (x) => saveSrc(x) }); +let logoutSrc = $ref(isLocalTimelineAvailable ? 'local' : 'global'); watch ($$(src), () => queue = 0); @@ -94,6 +95,7 @@ function saveSrc(newSrc: 'home' | 'local' | 'social' | 'global'): void { ...defaultStore.state.tl, src: newSrc, }); + logoutSrc = newSrc ; } async function timetravel(): Promise { @@ -116,6 +118,7 @@ const headerTabs = $computed(() => [{ title: i18n.ts._timelines.home, icon: 'fas fa-home', iconOnly: true, + loginRequired: true, }, ...(isLocalTimelineAvailable ? [{ key: 'local', title: i18n.ts._timelines.local, @@ -126,6 +129,7 @@ const headerTabs = $computed(() => [{ title: i18n.ts._timelines.social, icon: 'fas fa-share-alt', iconOnly: true, + loginRequired: true, }] : []), ...(isGlobalTimelineAvailable ? [{ key: 'global', title: i18n.ts._timelines.global, @@ -135,16 +139,19 @@ const headerTabs = $computed(() => [{ icon: 'fas fa-list-ul', title: i18n.ts.lists, iconOnly: true, + loginRequired: true, onClick: chooseList, }, { icon: 'fas fa-satellite', title: i18n.ts.antennas, iconOnly: true, + loginRequired: true, onClick: chooseAntenna, }, { icon: 'fas fa-satellite-dish', title: i18n.ts.channel, iconOnly: true, + loginRequired: true, onClick: chooseChannel, }]); diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index b3baad188..f5c433264 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -224,6 +224,9 @@ export const routes = [{ path: '/timeline/antenna/:antennaId', component: page(() => import('./pages/antenna-timeline.vue')), loginRequired: true, +}, { + path: '/timeline', + component: page(() => import('./pages/timeline.vue')), }, { name: 'index', path: '/',