chore(filelib-web): 左栏加「教研数据库」标题,用户身份+退出移至栏底,顶栏去掉身份区

This commit is contained in:
ymy
2026-07-31 14:57:01 +08:00
parent e173aa18e0
commit 672f05c66a
2 changed files with 32 additions and 25 deletions
@@ -11,7 +11,6 @@
import { onMount } from "svelte"; import { onMount } from "svelte";
import { api } from "./api.js"; import { api } from "./api.js";
import { me, toastErr, toastOk } from "./stores.js"; import { me, toastErr, toastOk } from "./stores.js";
import { logout } from "./session.js";
import { selectedFilePath, clearSelectedFile } from "./browser.js"; import { selectedFilePath, clearSelectedFile } from "./browser.js";
import { ROLE_LABEL } from "./labels.js"; import { ROLE_LABEL } from "./labels.js";
import type { FileEntry, NodeChild, NodeDetail, Role } from "./types.js"; import type { FileEntry, NodeChild, NodeDetail, Role } from "./types.js";
@@ -61,7 +60,6 @@
currentFolder === null ? ($me?.isWebsiteAdmin ?? false) : atLeast(currentFolder.role, "EDIT"), currentFolder === null ? ($me?.isWebsiteAdmin ?? false) : atLeast(currentFolder.role, "EDIT"),
); );
const projectCanEdit = $derived(projectNode !== null && projectNode.role !== "VIEW"); const projectCanEdit = $derived(projectNode !== null && projectNode.role !== "VIEW");
const initial = $derived(($me?.displayName ?? $me?.userId ?? "U").slice(0, 1).toUpperCase());
/* ------------------------------------------------------------ 数据加载 */ /* ------------------------------------------------------------ 数据加载 */
@@ -387,16 +385,6 @@
</button> </button>
{/if} {/if}
<button class="btn btn-sm" onclick={refresh} title="刷新"><Icon name="refresh" size={13} /></button> <button class="btn btn-sm" onclick={refresh} title="刷新"><Icon name="refresh" size={13} /></button>
<div class="ml-1 flex shrink-0 items-center gap-2 border-l border-line-soft pl-3">
<span class="flex h-6 w-6 items-center justify-center rounded-full bg-accent text-[11px] font-semibold text-white">{initial}</span>
<span class="max-w-[120px] 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>
</header> </header>
<!-- 主体:网格 + 文件预览栏 --> <!-- 主体:网格 + 文件预览栏 -->
+22 -3
View File
@@ -2,7 +2,7 @@
/** 老师端。未登录显示登录卡片;登录后是带左栏导航的文件库(ADR-0031)。 */ /** 老师端。未登录显示登录卡片;登录后是带左栏导航的文件库(ADR-0031)。 */
import { onMount } from "svelte"; import { onMount } from "svelte";
import { me, authChecked } from "$lib/stores.js"; import { me, authChecked } from "$lib/stores.js";
import { loadSession } from "$lib/session.js"; import { loadSession, logout } from "$lib/session.js";
import LoginView from "$lib/LoginView.svelte"; import LoginView from "$lib/LoginView.svelte";
import GridLibraryView from "$lib/GridLibraryView.svelte"; import GridLibraryView from "$lib/GridLibraryView.svelte";
import BinView from "$lib/BinView.svelte"; import BinView from "$lib/BinView.svelte";
@@ -17,16 +17,23 @@
["library", "文件库", "layers"], ["library", "文件库", "layers"],
["bin", "回收站", "trash"], ["bin", "回收站", "trash"],
]; ];
const initial = $derived(($me?.displayName ?? $me?.userId ?? "U").slice(0, 1).toUpperCase());
</script> </script>
<svelte:head><title>文件</title></svelte:head> <svelte:head><title>教研数据</title></svelte:head>
{#if !$authChecked} {#if !$authChecked}
<div class="flex h-full items-center justify-center text-ink-3">加载中…</div> <div class="flex h-full items-center justify-center text-ink-3">加载中…</div>
{:else if $me} {:else if $me}
<div class="flex h-full"> <div class="flex h-full">
<!-- 左栏导航(ADR-0031) --> <!-- 左栏导航(ADR-0031) -->
<nav class="flex w-[168px] shrink-0 flex-col gap-0.5 border-r border-line-soft bg-sidebar px-2.5 py-3.5"> <nav class="flex w-[168px] shrink-0 flex-col border-r border-line-soft bg-sidebar px-2.5 py-3.5">
<!-- 标题 -->
<div class="mb-3 px-2 text-[15px] font-bold text-ink">教研数据库</div>
<!-- 导航项 -->
<div class="flex flex-1 flex-col gap-0.5">
{#each tabs as [id, label, icon] (id)} {#each tabs as [id, label, icon] (id)}
<button <button
class="flex items-center gap-2.5 rounded-lg px-3 py-2 text-left text-[13px] transition {view === id class="flex items-center gap-2.5 rounded-lg px-3 py-2 text-left text-[13px] transition {view === id
@@ -38,6 +45,18 @@
{label} {label}
</button> </button>
{/each} {/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> </nav>
{#if view === "library"} {#if view === "library"}