2022-04-17 22:43:58 +00:00
|
|
|
<script setup lang="ts">
|
2022-07-04 22:52:53 +00:00
|
|
|
import type { Track } from '~/types'
|
|
|
|
|
2022-04-23 07:37:43 +00:00
|
|
|
import AudioPlayer from '~/components/audio/Player.vue'
|
|
|
|
import Queue from '~/components/Queue.vue'
|
|
|
|
import PlaylistModal from '~/components/playlists/PlaylistModal.vue'
|
|
|
|
import ChannelUploadModal from '~/components/channels/UploadModal.vue'
|
|
|
|
import Sidebar from '~/components/Sidebar.vue'
|
|
|
|
import ServiceMessages from '~/components/ServiceMessages.vue'
|
|
|
|
import SetInstanceModal from '~/components/SetInstanceModal.vue'
|
|
|
|
import ShortcutsModal from '~/components/ShortcutsModal.vue'
|
|
|
|
import FilterModal from '~/components/moderation/FilterModal.vue'
|
|
|
|
import ReportModal from '~/components/moderation/ReportModal.vue'
|
2022-04-19 18:51:23 +00:00
|
|
|
import { useIntervalFn, useToggle, useWindowSize } from '@vueuse/core'
|
2022-04-17 22:43:58 +00:00
|
|
|
|
2022-04-18 08:24:47 +00:00
|
|
|
import { computed, nextTick, onMounted, ref, watchEffect } from 'vue'
|
2022-04-19 18:51:23 +00:00
|
|
|
import onKeyboardShortcut from '~/composables/onKeyboardShortcut'
|
2022-07-03 21:36:27 +00:00
|
|
|
import useQueue from '~/composables/audio/useQueue'
|
2022-05-03 00:30:43 +00:00
|
|
|
import { useStore } from '~/store'
|
|
|
|
|
|
|
|
const store = useStore()
|
2022-04-17 22:43:58 +00:00
|
|
|
|
|
|
|
// Tracks
|
2022-07-03 18:12:09 +00:00
|
|
|
const { currentTrack } = useQueue()
|
2022-04-17 22:43:58 +00:00
|
|
|
const getTrackInformationText = (track: Track | undefined) => {
|
|
|
|
if (!track) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
const artist = track.artist ?? track.album?.artist
|
|
|
|
return `♫ ${track.title} – ${artist?.name} ♫`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update title
|
|
|
|
const initialTitle = document.title
|
|
|
|
watchEffect(() => {
|
|
|
|
const parts = [
|
|
|
|
getTrackInformationText(currentTrack.value),
|
|
|
|
store.state.ui.pageTitle,
|
|
|
|
initialTitle || 'Funkwhale'
|
|
|
|
]
|
|
|
|
|
|
|
|
document.title = parts.filter(i => i).join(' – ')
|
|
|
|
})
|
|
|
|
|
|
|
|
// Styles
|
|
|
|
const customStylesheets = computed(() => {
|
2022-05-03 00:30:43 +00:00
|
|
|
return store.state.instance.frontSettings.additionalStylesheets ?? []
|
2022-04-17 22:43:58 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// Fake content
|
|
|
|
onMounted(async () => {
|
|
|
|
await nextTick()
|
|
|
|
document.getElementById('fake-content')?.classList.add('loaded')
|
|
|
|
})
|
|
|
|
|
|
|
|
// Time ago
|
2022-04-19 18:51:23 +00:00
|
|
|
// TODO (wvffle): Migrate to useTimeAgo
|
2022-04-17 22:43:58 +00:00
|
|
|
useIntervalFn(() => {
|
|
|
|
// used to redraw ago dates every minute
|
|
|
|
store.commit('ui/computeLastDate')
|
|
|
|
}, 1000 * 60)
|
|
|
|
|
2022-04-19 18:51:23 +00:00
|
|
|
// Shortcuts
|
|
|
|
const [showShortcutsModal, toggleShortcutsModal] = useToggle(false)
|
|
|
|
onKeyboardShortcut('h', () => toggleShortcutsModal())
|
|
|
|
|
2022-04-17 22:43:58 +00:00
|
|
|
const { width } = useWindowSize()
|
|
|
|
const showSetInstanceModal = ref(false)
|
2022-07-21 23:19:16 +00:00
|
|
|
|
|
|
|
// Fetch user data on startup
|
|
|
|
if (store.state.auth.authenticated) {
|
|
|
|
store.dispatch('auth/fetchUser')
|
|
|
|
}
|
2022-04-17 22:43:58 +00:00
|
|
|
</script>
|
|
|
|
|
2017-06-23 21:00:42 +00:00
|
|
|
<template>
|
2021-11-26 11:01:58 +00:00
|
|
|
<div
|
2022-04-17 22:43:58 +00:00
|
|
|
:key="String(store.state.instance.instanceUrl)"
|
|
|
|
:class="[store.state.ui.queueFocused ? 'queue-focused' : '',
|
|
|
|
{'has-bottom-player': store.state.queue.tracks.length > 0}]"
|
2021-11-26 11:01:58 +00:00
|
|
|
>
|
2018-07-26 17:51:55 +00:00
|
|
|
<!-- here, we display custom stylesheets, if any -->
|
2018-12-04 14:13:37 +00:00
|
|
|
<link
|
|
|
|
v-for="url in customStylesheets"
|
2021-11-26 11:01:58 +00:00
|
|
|
:key="url"
|
2018-12-04 14:13:37 +00:00
|
|
|
rel="stylesheet"
|
|
|
|
property="stylesheet"
|
|
|
|
:href="url"
|
|
|
|
>
|
2022-05-01 11:45:07 +00:00
|
|
|
|
2021-11-26 11:01:58 +00:00
|
|
|
<sidebar
|
|
|
|
:width="width"
|
|
|
|
@show:set-instance-modal="showSetInstanceModal = !showSetInstanceModal"
|
2022-04-19 18:51:23 +00:00
|
|
|
@show:shortcuts-modal="toggleShortcutsModal"
|
2021-11-26 11:01:58 +00:00
|
|
|
/>
|
2022-05-01 11:45:07 +00:00
|
|
|
<set-instance-modal v-model:show="showSetInstanceModal" />
|
2021-11-26 11:01:58 +00:00
|
|
|
<service-messages />
|
|
|
|
<transition name="queue">
|
2022-07-22 03:02:53 +00:00
|
|
|
<queue v-show="store.state.ui.queueFocused" />
|
2021-11-26 11:01:58 +00:00
|
|
|
</transition>
|
2022-04-18 16:17:51 +00:00
|
|
|
|
2022-05-01 13:11:50 +00:00
|
|
|
<router-view v-slot="{ Component }">
|
2022-05-01 11:45:07 +00:00
|
|
|
<template v-if="Component">
|
2022-05-01 13:11:50 +00:00
|
|
|
<keep-alive :max="1">
|
2022-07-22 03:02:53 +00:00
|
|
|
<Suspense>
|
2022-07-24 20:51:13 +00:00
|
|
|
<component :is="Component" />
|
2022-05-01 13:11:50 +00:00
|
|
|
<template #fallback>
|
|
|
|
<!-- TODO (wvffle): Add loader -->
|
|
|
|
Loading...
|
|
|
|
</template>
|
|
|
|
</Suspense>
|
|
|
|
</keep-alive>
|
2022-05-01 11:45:07 +00:00
|
|
|
</template>
|
2022-04-18 16:17:51 +00:00
|
|
|
</router-view>
|
|
|
|
|
2022-07-03 23:57:14 +00:00
|
|
|
<audio-player />
|
2022-04-17 22:43:58 +00:00
|
|
|
<playlist-modal v-if="store.state.auth.authenticated" />
|
|
|
|
<channel-upload-modal v-if="store.state.auth.authenticated" />
|
|
|
|
<filter-modal v-if="store.state.auth.authenticated" />
|
2021-11-26 11:01:58 +00:00
|
|
|
<report-modal />
|
2022-05-01 11:45:07 +00:00
|
|
|
<shortcuts-modal v-model:show="showShortcutsModal" />
|
2017-06-23 21:00:42 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2018-12-19 21:04:35 +00:00
|
|
|
@import "style/_main";
|
2017-06-23 21:00:42 +00:00
|
|
|
</style>
|