The first pass only proved the Tauri capture pipeline against the
default landing view ("About"). All 24 real sidebar sections are wired
up now (every id in lib/sidebar.ts has a real component in
lib/views/registry.ts — no Placeholder fallbacks to skip).
Since there's no URL/route per section (activePage is plain Svelte
$state, switched by the sidebar's own click handler), the frontend now
also listens for a screenshot-set-view Tauri event in +page.svelte's
onMount and sets activePage from its payload — the same effect a real
sidebar click has, just driven from the Rust side. screenshot.rs emits
that event after the initial page-load settle delay, then waits a
second settle delay for the newly-active view's own Tauri-command data
fetch to land before capturing (each section fetches its own state on
mount, same as the About page's system-info fetch needed 2s in the
first pass).
71 lines
1.5 KiB
Svelte
71 lines
1.5 KiB
Svelte
<script lang="ts">
|
|
import { onMount } from "svelte";
|
|
import { listen } from "@tauri-apps/api/event";
|
|
import Sidebar from "$lib/components/Sidebar.svelte";
|
|
import Placeholder from "$lib/components/Placeholder.svelte";
|
|
import { DEFAULT_PAGE } from "$lib/sidebar";
|
|
import { initTheme } from "$lib/theme";
|
|
import { VIEWS } from "$lib/views/registry";
|
|
|
|
let activePage = $state(DEFAULT_PAGE);
|
|
let ActiveView = $derived(VIEWS[activePage]);
|
|
|
|
onMount(() => {
|
|
initTheme();
|
|
// Screenshot mode only (src-tauri's screenshot.rs) — lets the Rust
|
|
// core drive which sidebar section is showing for a capture without
|
|
// a real user ever clicking the sidebar.
|
|
const unlisten = listen<string>("screenshot-set-view", (event) => {
|
|
activePage = event.payload;
|
|
});
|
|
return () => {
|
|
unlisten.then((f) => f());
|
|
};
|
|
});
|
|
</script>
|
|
|
|
<div class="shell">
|
|
<Sidebar bind:activePage />
|
|
<main class="content">
|
|
{#if ActiveView}
|
|
<ActiveView />
|
|
{:else}
|
|
<Placeholder page={activePage} />
|
|
{/if}
|
|
</main>
|
|
</div>
|
|
|
|
<style>
|
|
:global(*) {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
:global(html, body) {
|
|
margin: 0;
|
|
border: none;
|
|
outline: none;
|
|
height: 100%;
|
|
color-scheme: dark;
|
|
background-color: var(--bg, #0c0c0c);
|
|
color: var(--fg);
|
|
font-family: var(--font-family, sans-serif);
|
|
font-size: var(--font-size-base, 14px);
|
|
}
|
|
|
|
:global(#svelte) {
|
|
height: 100%;
|
|
}
|
|
|
|
.shell {
|
|
display: flex;
|
|
height: 100vh;
|
|
background-color: var(--bg, #0c0c0c);
|
|
}
|
|
|
|
.content {
|
|
flex: 1;
|
|
min-width: 0;
|
|
overflow-y: auto;
|
|
overscroll-behavior: contain;
|
|
}
|
|
</style>
|