forked from bai/curriculum-project-hub
build(filelib-web): 从 Svelte+Vite 改为 SvelteKit(adapter-static)
纯 SPA:adapter-static + fallback index.html,不做 SSR/预渲染。
index.html / main.ts / App.svelte 由 app.html + src/routes/ 取代。
两项配置是承重的(ADR-0029),不是风格选择:
appDir: '_filelib' 默认 _app 会与 admin-web 在根上注册的 /_app/*
撞成 Fastify 重复路由,启动即抛错。
paths.relative: false 同一份 index.html 会在 /app 和
/database/dashboard/users 等不同深度送出,
相对资源路径会解析到错的 base。
dev 代理表列出后端拥有的全部路径:JSON API、免鉴权 bootstrap
(/database/config)、OAuth、以及 DEV 一键登录端点 —— 后者不代理会被
SPA 回退吃掉。
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { api, UnauthenticatedError } from "./lib/api.js";
|
||||
import { me, authChecked } from "./lib/stores.js";
|
||||
import type { MeResponse } from "./lib/types.js";
|
||||
import LoginView from "./lib/LoginView.svelte";
|
||||
import BrowserShell from "./lib/BrowserShell.svelte";
|
||||
import Toasts from "./lib/Toasts.svelte";
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
me.set(await api<MeResponse>("/database/api/me"));
|
||||
} catch (e) {
|
||||
if (!(e instanceof UnauthenticatedError)) console.error(e);
|
||||
me.set(null);
|
||||
} finally {
|
||||
authChecked.set(true);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if !$authChecked}
|
||||
<div class="flex h-full items-center justify-center text-ink-3">加载中…</div>
|
||||
{:else if $me}
|
||||
<BrowserShell />
|
||||
{:else}
|
||||
<LoginView />
|
||||
{/if}
|
||||
|
||||
<Toasts />
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// See https://svelte.dev/docs/kit/types#app
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover" style="height: 100%">
|
||||
<div style="display: contents; height: 100%">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +0,0 @@
|
||||
import { mount } from "svelte";
|
||||
import App from "./App.svelte";
|
||||
import "./app.css";
|
||||
|
||||
export default mount(App, { target: document.getElementById("app")! });
|
||||
Reference in New Issue
Block a user