fix(frontend): support HTTP UUID fallback and bundle Inter fonts

This commit is contained in:
Winnie
2026-08-03 13:30:03 +08:00
parent 76a572af0d
commit fd5ea4d33e
6 changed files with 142 additions and 15 deletions
+16
View File
@@ -1,3 +1,19 @@
@font-face {
font-family: "Inter";
src: url("/fonts/Inter-Variable.ttf") format("truetype");
font-style: normal;
font-weight: 100 900;
font-display: swap;
}
@font-face {
font-family: "Inter";
src: url("/fonts/Inter-Variable-Italic.ttf") format("truetype");
font-style: italic;
font-weight: 100 900;
font-display: swap;
}
:root {
font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
color: #1f354b;
+1 -12
View File
@@ -10,18 +10,7 @@ import {
import type { Route } from "./+types/root";
import "./app.css";
export const links: Route.LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
{
rel: "preconnect",
href: "https://fonts.gstatic.com",
crossOrigin: "anonymous",
},
{
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
];
export const links: Route.LinksFunction = () => [];
export function Layout({ children }: { children: React.ReactNode }) {
return (
+32 -3
View File
@@ -11,6 +11,35 @@ export type DemoWorkspace = {
workspaceName: string;
};
export function createUuid(): string {
const cryptoApi = globalThis.crypto;
if (typeof cryptoApi?.randomUUID === "function") {
return cryptoApi.randomUUID();
}
const bytes = new Uint8Array(16);
if (typeof cryptoApi?.getRandomValues === "function") {
cryptoApi.getRandomValues(bytes);
} else {
for (let index = 0; index < bytes.length; index += 1) {
bytes[index] = Math.floor(Math.random() * 256);
}
}
bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;
bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;
const hex = Array.from(bytes, (value) =>
value.toString(16).padStart(2, "0"),
).join("");
return [
hex.slice(0, 8),
hex.slice(8, 12),
hex.slice(12, 16),
hex.slice(16, 20),
hex.slice(20),
].join("-");
}
export const demoUsers: DemoUser[] = [
{ userId: "0000000000RF6FG1SDBXG59S13", userName: "张三", username: "admin-zhang", roleCode: "admin", roleName: "管理员" },
{ userId: "0000000000H2QYCGPCWQM1JSGS", userName: "李四", username: "admin-li", roleCode: "admin", roleName: "管理员" },
@@ -143,7 +172,7 @@ async function apiRequest<T>(
headers: {
"X-User-ID": demoContext.userId,
"X-Workspace-ID": demoContext.workspaceId,
"X-Request-ID": crypto.randomUUID().replaceAll("-", ""),
"X-Request-ID": createUuid().replaceAll("-", ""),
...(init.body ? { "Content-Type": "application/json" } : {}),
...init.headers,
},
@@ -362,7 +391,7 @@ export async function acquireFileLock(
): Promise<ActiveEditSession> {
const now = Date.now();
return {
edit_session_id: crypto.randomUUID().replaceAll("-", ""),
edit_session_id: createUuid().replaceAll("-", ""),
workspace_id: script.workspace_id,
storage_object_id: script.current_object_id,
user_id: demoContext.userId,
@@ -826,7 +855,7 @@ export async function runScheduleNow(
{
method: "POST",
headers: {
"Idempotency-Key": crypto.randomUUID(),
"Idempotency-Key": createUuid(),
},
body: JSON.stringify({ reason: "manual_run" }),
},