Dualside print update realisation + add backend versioning

This commit is contained in:
2026-09-18 03:07:25 +03:00
parent 10b78d5d81
commit 0bfeeadeb1
4 changed files with 59 additions and 37 deletions

View File

@ -1,4 +1,6 @@
<script>
import { onMount } from 'svelte';
/** @type {Array<{ id: 'print' | 'scan' | 'photo' | 'access', label: string, grad: string, glow: string, icon: string }>} */
const actions = [
{
@ -31,10 +33,30 @@
}
];
/** @param {'print' | 'scan' | 'photo' | 'access'} id */
export let onAction = (id) => {
/**
* @type {{ onAction?: (id: 'print' | 'scan' | 'photo' | 'access') => void }}
*/
let { onAction = (id) => {
console.log('Выбрано действие:', id);
};
} } = $props();
let backendVersion = $state('—');
onMount(async () => {
try {
const res = await fetch('/api/version');
if (!res.ok) throw new Error('HTTP ' + res.status);
const text = await res.text();
try {
const json = JSON.parse(text);
backendVersion = json.version ?? json.data ?? text;
} catch {
backendVersion = text;
}
} catch (e) {
backendVersion = 'offline';
}
});
</script>
<div class="menu-container">
@ -64,8 +86,6 @@
</div>
<style>
/* Стили остаются здесь, но убираем глобальные сбросы body/html */
.menu-container {
width: 100%;
min-height: 100vh;
@ -93,14 +113,12 @@
color: #8b93a1;
}
/* Сетка 2×2 */
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
}
/* Карточка-кнопка в стиле мобильного UI */
.card {
display: flex;
flex-direction: column;
@ -128,12 +146,10 @@
}
}
/* Эффект нажатия, как в мобильных приложениях */
.card:active {
transform: scale(0.96);
}
/* Иконка с градиентом и свечением */
.icon {
width: 58px;
height: 58px;
@ -152,7 +168,6 @@
text-align: center;
}
/* «Домашняя» полоска внизу, как на iPhone */
.footer {
margin-top: auto;
padding: 32px 0 8px;
@ -166,4 +181,29 @@
border-radius: 999px;
background: rgba(255, 255, 255, 0.22);
}
.version {
position: fixed;
bottom: 8px;
left: 8px;
display: flex;
flex-direction: column;
gap: 2px;
font-size: 8px;
line-height: 1.1;
color: rgba(245, 247, 250, 0.35);
user-select: none;
pointer-events: none;
z-index: 10;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.version span:first-child {
color: rgba(245, 247, 250, 0.25);
}
</style>
<div class="version">
<span>v{backendVersion}</span>
<span>v1.0.4</span>
</div>