slides: add /screensaver route for the shopfloor slide surface
TVDashboard hardcoded surface=lobby, so only the lobby display was reachable. Read the surface from route meta (/screensaver -> shopfloor) or a ?surface= query, defaulting to lobby. Adds a /screensaver toplevel route so the shopfloor screensaver surface can be displayed on a kiosk.
This commit is contained in:
@@ -13,6 +13,12 @@ export const toplevel = [
|
||||
path: '/tv',
|
||||
name: 'tv',
|
||||
component: () => import('./views/TVDashboard.vue'),
|
||||
meta: { plugin: 'slides' }
|
||||
meta: { plugin: 'slides', surface: 'lobby' }
|
||||
},
|
||||
{
|
||||
path: '/screensaver',
|
||||
name: 'screensaver',
|
||||
component: () => import('./views/TVDashboard.vue'),
|
||||
meta: { plugin: 'slides', surface: 'shopfloor' }
|
||||
}
|
||||
]
|
||||
|
||||
@@ -27,9 +27,18 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import api from '@/api'
|
||||
import { withBase } from '@/utils/basePath'
|
||||
|
||||
// Which slide surface this display renders: 'lobby' (default) or 'shopfloor'
|
||||
// (the screensaver). Set by the route meta (/screensaver) or a ?surface= query.
|
||||
const route = useRoute()
|
||||
const VALID_SURFACES = ['lobby', 'shopfloor']
|
||||
const surface = (VALID_SURFACES.includes(route.meta?.surface) && route.meta.surface)
|
||||
|| (VALID_SURFACES.includes(route.query?.surface) && route.query.surface)
|
||||
|| 'lobby'
|
||||
|
||||
const INTERVAL = 10 // seconds between slides
|
||||
|
||||
const slides = ref([])
|
||||
@@ -68,12 +77,12 @@ onUnmounted(() => {
|
||||
async function fetchSlides() {
|
||||
try {
|
||||
// Flat feed shape: { success, surface, basepath, interval, slides:[...] }
|
||||
const response = await api.get('/slides/feed', { params: { surface: 'lobby' } })
|
||||
const response = await api.get('/slides/feed', { params: { surface } })
|
||||
const data = response.data
|
||||
|
||||
if (data.success && data.slides?.length > 0) {
|
||||
slides.value = data.slides
|
||||
basePath.value = data.basepath || '/api/slides/img/lobby/'
|
||||
basePath.value = data.basepath || `/api/slides/img/${surface}/`
|
||||
error.value = ''
|
||||
|
||||
// Restart slideshow if slides changed
|
||||
|
||||
Reference in New Issue
Block a user