forked from EduCraft/curriculum-project-hub
feat(filelib-web): 把 /database 各页从后端 HTML 拼接迁到 SvelteKit 路由
登录页、后台外壳与六个 tab 全部成为客户端路由: /database/admin 登录(迁自 renderLoginPage) /database/dashboard 概览(迁自 renderDashboard) .../library .../users .../groups .../search .../settings 六个 tab 是真 URL,不再是 location.hash + display:none —— 刷新不丢 位置,链接可分享。 BrowserShell 拆成 LibraryView,加 showUserFooter:老师端 /app 显示 身份/登出页脚,后台的文件库 tab 不显示(外层已有身份区)。 bootstrap 走 /database/config 而非 /database/api/login-info:后者由 teacherApp 在 silo org 查找成功后才注册,前者无条件注册,登录页在 org 未就绪时也必须能拿到配置。 后端拥有的链接(OAuth、DEV 一键登录)标 data-sveltekit-reload, 否则被客户端路由拦下。
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<script lang="ts">
|
||||
/**
|
||||
* 管理后台登录页(迁自后端 renderLoginPage)。
|
||||
* 已登录直接跳 dashboard —— 与旧后端路由 /database/admin 的行为一致。
|
||||
*/
|
||||
import { onMount } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import { me, authChecked } from "$lib/stores.js";
|
||||
import { loadSession } from "$lib/session.js";
|
||||
import { loadConfig, type AppConfig } from "$lib/config.js";
|
||||
|
||||
let info = $state<AppConfig | null>(null);
|
||||
let loadFailed = $state(false);
|
||||
|
||||
onMount(async () => {
|
||||
await loadSession();
|
||||
if ($me !== null) {
|
||||
void goto("/database/dashboard", { replaceState: true });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
info = await loadConfig();
|
||||
} catch {
|
||||
loadFailed = true;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Database Admin · 登录</title></svelte:head>
|
||||
|
||||
<div class="flex min-h-full items-center justify-center p-6">
|
||||
<div class="w-full max-w-[380px] rounded-2xl border border-line-soft bg-panel p-9 shadow-[0_4px_20px_rgba(26,26,24,.07)]">
|
||||
<div class="text-center text-[26px] font-semibold text-ink">Database Admin</div>
|
||||
<p class="mt-2.5 mb-8 text-center text-[13px] text-ink-3">使用飞书登录以管理数据库</p>
|
||||
|
||||
{#if !$authChecked}
|
||||
<p class="text-center text-[12.5px] text-ink-3">加载中…</p>
|
||||
{:else if info}
|
||||
<a
|
||||
href="/auth/feishu/{encodeURIComponent(info.orgSlug)}"
|
||||
data-sveltekit-reload
|
||||
class="flex w-full items-center justify-center rounded-lg bg-accent px-4 py-3 text-sm font-medium text-white transition hover:bg-accent-hover"
|
||||
>使用飞书登录</a>
|
||||
|
||||
{#if info.devLoginEnabled}
|
||||
<div class="my-5 flex items-center gap-2.5 text-[11px] text-ink-3">
|
||||
<span class="flex-1 border-t border-line-soft"></span>开发模式
|
||||
<span class="flex-1 border-t border-line-soft"></span>
|
||||
</div>
|
||||
<a
|
||||
href="/database/dev-login"
|
||||
data-sveltekit-reload
|
||||
class="flex w-full items-center justify-center rounded-lg border border-line bg-panel px-4 py-2 text-[12.5px] font-medium text-ink transition hover:bg-hover"
|
||||
>⚡ 一键登录管理员</a>
|
||||
<p class="mt-2.5 text-center text-[11px] text-ink-3">仅开发环境可见 · 跳过飞书 OAuth</p>
|
||||
{/if}
|
||||
{:else if loadFailed}
|
||||
<p class="text-center text-[12.5px] text-danger">无法加载登录配置,请稍后重试</p>
|
||||
{:else}
|
||||
<p class="text-center text-[12.5px] text-ink-3">加载中…</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user