feat: 全局设置系统 — settings 表、CRUD 路由、主题偏好持久化
This commit is contained in:
@@ -18,6 +18,12 @@ function createMockHandler(overrides?: { status?: "active" | "archived" }) {
|
||||
const project = { ...MOCK_PROJECT, ...overrides };
|
||||
const handler = (input: RequestInfo | URL) => {
|
||||
const url = input instanceof Request ? input.url : typeof input === "string" ? input : input.toString();
|
||||
if (url.includes("/api/settings")) {
|
||||
return new Response(JSON.stringify({ theme: "system" }), {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
status: 200,
|
||||
});
|
||||
}
|
||||
if (url.includes("/api/meta")) {
|
||||
return new Response(
|
||||
JSON.stringify({ ok: true, service: "test-app", timestamp: new Date().toISOString(), version: "0.1.0" }),
|
||||
@@ -38,7 +44,8 @@ function createMockHandler(overrides?: { status?: "active" | "archived" }) {
|
||||
}
|
||||
return new Response(JSON.stringify({ error: "Not Found" }), { status: 404 });
|
||||
};
|
||||
const mocked = handler as unknown as typeof fetch;
|
||||
const mocked = ((input: RequestInfo | URL, _init?: RequestInit) =>
|
||||
Promise.resolve(handler(input))) as unknown as typeof fetch;
|
||||
globalThis.fetch = mocked;
|
||||
window.fetch = mocked;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user