forked from EduCraft/curriculum-project-hub
72 lines
2.6 KiB
Svelte
72 lines
2.6 KiB
Svelte
<script lang="ts">
|
|
/** 老师端。未登录显示登录卡片;登录后是带左栏导航的文件库(ADR-0031)。 */
|
|
import { onMount } from "svelte";
|
|
import { me, authChecked } from "$lib/stores.js";
|
|
import { loadSession, logout } from "$lib/session.js";
|
|
import LoginView from "$lib/LoginView.svelte";
|
|
import GridLibraryView from "$lib/GridLibraryView.svelte";
|
|
import BinView from "$lib/BinView.svelte";
|
|
import Icon from "$lib/Icon.svelte";
|
|
|
|
onMount(loadSession);
|
|
|
|
type View = "library" | "bin";
|
|
let view = $state<View>("library");
|
|
|
|
const tabs: ReadonlyArray<readonly [View, string, "layers" | "trash"]> = [
|
|
["library", "文件库", "layers"],
|
|
["bin", "回收站", "trash"],
|
|
];
|
|
|
|
const initial = $derived(($me?.displayName ?? $me?.userId ?? "U").slice(0, 1).toUpperCase());
|
|
</script>
|
|
|
|
<svelte:head><title>教研数据库</title></svelte:head>
|
|
|
|
{#if !$authChecked}
|
|
<div class="flex h-full items-center justify-center text-ink-3">加载中…</div>
|
|
{:else if $me}
|
|
<div class="flex h-full">
|
|
<!-- 左栏导航(ADR-0031) -->
|
|
<nav class="flex w-[240px] shrink-0 flex-col border-r border-line-soft bg-sidebar px-3 py-4">
|
|
<!-- 标题 -->
|
|
<div class="mb-3 px-1 text-[15px] font-bold text-ink">教研数据库</div>
|
|
<div class="mb-2 border-t border-line-soft"></div>
|
|
|
|
<!-- 导航项 -->
|
|
<div class="flex flex-1 flex-col gap-0.5">
|
|
{#each tabs as [id, label, icon] (id)}
|
|
<button
|
|
class="flex items-center gap-2.5 rounded-lg px-3 py-2 text-left text-[13px] transition {view === id
|
|
? 'bg-selected font-semibold text-ink'
|
|
: 'text-ink-2 hover:bg-hover'}"
|
|
onclick={() => (view = id)}
|
|
>
|
|
<span class="text-ink-3"><Icon name={icon} size={15} /></span>
|
|
{label}
|
|
</button>
|
|
{/each}
|
|
</div>
|
|
|
|
<!-- 底部:用户身份 + 退出 -->
|
|
<div class="mt-auto flex items-center gap-2 border-t border-line-soft pt-3">
|
|
<span class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-accent text-[11px] font-semibold text-white">{initial}</span>
|
|
<span class="min-w-0 flex-1 truncate text-[12.5px] text-ink">{$me?.displayName ?? $me?.userId ?? ""}</span>
|
|
<button
|
|
class="rounded-lg border border-line-soft px-2 py-1 text-[11.5px] text-ink-3 transition hover:bg-hover hover:text-ink"
|
|
onclick={logout}
|
|
title="退出登录"
|
|
>退出</button>
|
|
</div>
|
|
</nav>
|
|
|
|
{#if view === "library"}
|
|
<GridLibraryView />
|
|
{:else}
|
|
<BinView />
|
|
{/if}
|
|
</div>
|
|
{:else}
|
|
<LoginView />
|
|
{/if}
|