add PWA update from change version
This commit is contained in:
111
src/App.svelte
111
src/App.svelte
@ -1,62 +1,71 @@
|
||||
<script>
|
||||
import MainMenu from '$lib/pages/main/MainMenu.svelte';
|
||||
import PrintMenu from '$lib/pages/print/PrintMenu.svelte';
|
||||
import ScanPage from '$lib/pages/scan/ScanPage.svelte';
|
||||
import MainMenu from '$lib/pages/main/MainMenu.svelte';
|
||||
import PrintMenu from '$lib/pages/print/PrintMenu.svelte';
|
||||
import ScanPage from '$lib/pages/scan/ScanPage.svelte';
|
||||
import UpdateBanner from '$lib/common/ui/UpdateBanner.svelte';
|
||||
import { useUpdateCheck } from '$lib/common/hooks/useUpdateCheck.svelte.js';
|
||||
|
||||
/** @type {'main' | 'print' | 'scan'} */
|
||||
let page = $state('main');
|
||||
/** @type {'main' | 'print' | 'scan'} */
|
||||
let page = $state('main');
|
||||
|
||||
/** @param {'print' | 'scan' | 'photo' | 'access'} id */
|
||||
function handleAction(id) {
|
||||
if (id === 'print') {
|
||||
page = 'print';
|
||||
} else if (id === 'scan') {
|
||||
page = 'scan';
|
||||
} else {
|
||||
console.log('Выбрано действие:', id);
|
||||
}
|
||||
}
|
||||
const { needRefresh, doUpdate } = useUpdateCheck();
|
||||
|
||||
function handleBack() {
|
||||
page = 'main';
|
||||
}
|
||||
/** @param {'print' | 'scan' | 'photo' | 'access'} id */
|
||||
function handleAction(id) {
|
||||
if (id === 'print') {
|
||||
page = 'print';
|
||||
} else if (id === 'scan') {
|
||||
page = 'scan';
|
||||
} else {
|
||||
console.log('Выбрано действие:', id);
|
||||
}
|
||||
}
|
||||
|
||||
function handleBack() {
|
||||
page = 'main';
|
||||
}
|
||||
|
||||
function handleDismiss() {
|
||||
// Пользователь нажал "Позже", баннер скроется
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
:global(html),
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #0b0d11;
|
||||
}
|
||||
|
||||
:global(body) {
|
||||
display: block;
|
||||
place-items: initial;
|
||||
min-width: 0;
|
||||
color: #f5f7fa;
|
||||
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.app-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.app-wrapper {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
:global(html),
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #0b0d11;
|
||||
}
|
||||
:global(body) {
|
||||
display: block;
|
||||
place-items: initial;
|
||||
min-width: 0;
|
||||
color: #f5f7fa;
|
||||
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
.app-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.app-wrapper {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if needRefresh}
|
||||
<UpdateBanner onUpdate={doUpdate} onDismiss={handleDismiss} />
|
||||
{/if}
|
||||
|
||||
<main class="app-wrapper">
|
||||
{#if page === 'main'}
|
||||
<MainMenu onAction={handleAction} />
|
||||
{:else if page === 'print'}
|
||||
<PrintMenu onBack={handleBack} />
|
||||
{:else if page === 'scan'}
|
||||
<ScanPage onBack={handleBack} />
|
||||
{/if}
|
||||
{#if page === 'main'}
|
||||
<MainMenu onAction={handleAction} />
|
||||
{:else if page === 'print'}
|
||||
<PrintMenu onBack={handleBack} />
|
||||
{:else if page === 'scan'}
|
||||
<ScanPage onBack={handleBack} />
|
||||
{/if}
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user