feat(prototype): add upload manager and docker ci

- add prototype upload, list, view, and delete api routes
- add prototype manager ui with search, modal, and theme toggle
- add filesystem-backed zip extraction and serving logic
- switch project to pnpm with updated lockfile and tooling
- add multi-stage dockerfile with standalone next.js output
- add github actions to lint, build, and publish docker images
This commit is contained in:
siujamo committed 2026-08-31 13:43:59 +08:00
1 parent 0c592225e4
commit ed72045f5e
30 files changed
+5369 -6899

No files matched your search

@@ -0,0 +1,36 @@
import { NextResponse } from "next/server"
import { readPrototypeFile } from "@/lib/store"
export const runtime = "nodejs"
interface RouteContext {
params: Promise<{
id: string
path?: string[]
}>
}
function decodePathSegments(segments: string[] = []) {
return segments.map((segment) => decodeURIComponent(segment)).join("/")
}
export async function GET(_request: Request, context: RouteContext) {
const { id, path } = await context.params
const relativePath = decodePathSegments(path)
const file = await readPrototypeFile(id, relativePath || undefined)
if (!file) {
return NextResponse.json({ error: "文件不存在" }, { status: 404 })
}
return new NextResponse(file.content, {
headers: {
"content-type": file.mimeType,
"content-length": String(file.size),
"last-modified": file.lastModified,
"cache-control": "no-store",
"x-content-type-options": "nosniff",
},
})
}
+21
View File
@@ -0,0 +1,21 @@
import { NextResponse } from "next/server"
import { deletePrototype } from "@/lib/store"
export const runtime = "nodejs"
interface RouteContext {
params: Promise<{
id: string
}>
}
export async function DELETE(_request: Request, context: RouteContext) {
const { id } = await context.params
const deleted = await deletePrototype(id)
if (!deleted) {
return NextResponse.json({ error: "原型不存在" }, { status: 404 })
}
return NextResponse.json({ ok: true })
}
+44
View File
@@ -0,0 +1,44 @@
import { NextResponse } from "next/server"
import { createPrototypeFromZip, listPrototypes } from "@/lib/store"
export const runtime = "nodejs"
export async function GET() {
const prototypes = await listPrototypes()
return NextResponse.json({ data: prototypes })
}
export async function POST(request: Request) {
try {
const formData = await request.formData()
const name = `${formData.get("name") ?? ""}`
const description = `${formData.get("description") ?? ""}`
const file = formData.get("file")
if (!(file instanceof File)) {
return NextResponse.json({ error: "请上传 ZIP 文件" }, { status: 400 })
}
const buffer = Buffer.from(await file.arrayBuffer())
const created = await createPrototypeFromZip({
name,
description,
zipBuffer: buffer,
zipFileName: file.name,
})
return NextResponse.json({ data: created }, { status: 201 })
} catch (error) {
const message = error instanceof Error ? error.message : "上传失败"
const status =
message.includes("为空") ||
message.includes("不") ||
message.includes("非法") ||
message.includes("过大") ||
message.includes("未找到")
? 400
: 500
return NextResponse.json({ error: message }, { status })
}
}
+7 -9
View File
@@ -1,8 +1,8 @@
@import "tailwindcss";
:root {
--background: #ffffff;
--foreground: #171717;
--background: #f8fafc;
--foreground: #1e293b;
}
@theme inline {
@@ -12,15 +12,13 @@
--font-mono: var(--font-geist-mono);
}
@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
.dark {
--background: #020617;
--foreground: #f8fafc;
}
body {
background: var(--background);
background-color: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
font-family: var(--font-geist-sans), "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
+10 -13
View File
@@ -1,29 +1,26 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import type { Metadata } from "next"
import { Geist, Geist_Mono } from "next/font/google"
import "./globals.css"
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
})
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});
})
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
title: "原型导航 | Prototype Navigation",
description: "Axure 原型管理系统",
}
export default function RootLayout({ children }: LayoutProps<"/">) {
return (
<html
lang="en"
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
>
<html lang="zh-CN" className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}>
<body className="min-h-full flex flex-col">{children}</body>
</html>
);
)
}
+8 -67
View File
@@ -1,69 +1,10 @@
import Image from "next/image";
import { PrototypeManagerPage } from "@/components/PrototypeManagerPage";
import { listPrototypes } from "@/lib/store";
export default function Home() {
return (
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
<Image
className="dark:invert h-5 w-[100px]"
src="/next.svg"
alt="Next.js logo"
width={100}
height={20}
priority
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the{" "}
<code className="rounded bg-black/[.06] px-1.5 py-0.5 font-mono text-[0.9em] dark:bg-white/[.08]">
page.tsx
</code>{" "}
file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Templates
</a>{" "}
or the{" "}
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Learning
</a>{" "}
center.
</p>
</div>
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
<a
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert h-[14px] w-4"
src="/vercel.svg"
alt="Vercel logomark"
width={16}
height={14}
/>
Deploy Now
</a>
<a
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Documentation
</a>
</div>
</main>
</div>
);
export const dynamic = "force-dynamic";
export default async function Home() {
const initialPrototypes = await listPrototypes();
return <PrototypeManagerPage initialPrototypes={initialPrototypes} />;
}