create-next-imagicma 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -13
- package/bin/create-next-imagicma.mjs +138 -22
- package/package.json +2 -1
- package/template/app/globals.css +331 -0
- package/template/app/layout.tsx +4 -6
- package/template/app/page.tsx +18 -40
- package/template/package.json +1 -1
- package/template/public/imagicma-picker-bridge.js +374 -0
- package/template-hono/.env.example +8 -0
- package/template-hono/.imagicma/AGENTS.md +7 -0
- package/template-hono/.imagicma/port.json +5 -0
- package/template-hono/AGENTS.md +39 -0
- package/template-hono/README.md +48 -0
- package/template-hono/client/src/App.tsx +13 -0
- package/template-hono/client/src/components/ErrorBoundary.tsx +74 -0
- package/template-hono/client/src/components/HelloClient.tsx +69 -0
- package/template-hono/client/src/globals.css +767 -0
- package/template-hono/client/src/main.tsx +24 -0
- package/template-hono/client/src/pages/HelloPage.tsx +22 -0
- package/template-hono/client/src/pages/HomePage.tsx +30 -0
- package/template-hono/client/src/providers.tsx +21 -0
- package/template-hono/components/ui/accordion.tsx +58 -0
- package/template-hono/components/ui/alert-dialog.tsx +141 -0
- package/template-hono/components/ui/alert.tsx +61 -0
- package/template-hono/components/ui/aspect-ratio.tsx +7 -0
- package/template-hono/components/ui/avatar.tsx +51 -0
- package/template-hono/components/ui/badge.tsx +40 -0
- package/template-hono/components/ui/breadcrumb.tsx +117 -0
- package/template-hono/components/ui/button.tsx +64 -0
- package/template-hono/components/ui/calendar.tsx +72 -0
- package/template-hono/components/ui/card.tsx +87 -0
- package/template-hono/components/ui/carousel.tsx +262 -0
- package/template-hono/components/ui/chart.tsx +365 -0
- package/template-hono/components/ui/checkbox.tsx +30 -0
- package/template-hono/components/ui/collapsible.tsx +11 -0
- package/template-hono/components/ui/command.tsx +153 -0
- package/template-hono/components/ui/context-menu.tsx +200 -0
- package/template-hono/components/ui/dialog.tsx +122 -0
- package/template-hono/components/ui/drawer.tsx +118 -0
- package/template-hono/components/ui/dropdown-menu.tsx +200 -0
- package/template-hono/components/ui/form.tsx +178 -0
- package/template-hono/components/ui/hover-card.tsx +29 -0
- package/template-hono/components/ui/input-otp.tsx +71 -0
- package/template-hono/components/ui/input.tsx +25 -0
- package/template-hono/components/ui/label.tsx +26 -0
- package/template-hono/components/ui/menubar.tsx +256 -0
- package/template-hono/components/ui/navigation-menu.tsx +130 -0
- package/template-hono/components/ui/pagination.tsx +119 -0
- package/template-hono/components/ui/popover.tsx +31 -0
- package/template-hono/components/ui/progress.tsx +28 -0
- package/template-hono/components/ui/radio-group.tsx +44 -0
- package/template-hono/components/ui/resizable.tsx +45 -0
- package/template-hono/components/ui/scroll-area.tsx +48 -0
- package/template-hono/components/ui/select.tsx +160 -0
- package/template-hono/components/ui/separator.tsx +31 -0
- package/template-hono/components/ui/sheet.tsx +140 -0
- package/template-hono/components/ui/sidebar.tsx +732 -0
- package/template-hono/components/ui/skeleton.tsx +17 -0
- package/template-hono/components/ui/slider.tsx +28 -0
- package/template-hono/components/ui/switch.tsx +29 -0
- package/template-hono/components/ui/table.tsx +119 -0
- package/template-hono/components/ui/tabs.tsx +55 -0
- package/template-hono/components/ui/textarea.tsx +24 -0
- package/template-hono/components/ui/toast.tsx +129 -0
- package/template-hono/components/ui/toaster.tsx +35 -0
- package/template-hono/components/ui/toggle-group.tsx +61 -0
- package/template-hono/components/ui/toggle.tsx +45 -0
- package/template-hono/components/ui/tooltip.tsx +30 -0
- package/template-hono/drizzle.config.ts +50 -0
- package/template-hono/eslint.config.mjs +13 -0
- package/template-hono/gitignore +40 -0
- package/template-hono/hooks/use-greeting.ts +15 -0
- package/template-hono/hooks/use-mobile.ts +21 -0
- package/template-hono/hooks/use-toast.ts +194 -0
- package/template-hono/index.html +13 -0
- package/template-hono/lib/queryClient.ts +59 -0
- package/template-hono/lib/theme/default-theme.ts +11 -0
- package/template-hono/lib/utils.ts +6 -0
- package/template-hono/package.json +82 -0
- package/template-hono/pnpm-lock.yaml +5162 -0
- package/template-hono/postcss.config.mjs +7 -0
- package/template-hono/process-compose.yaml +13 -0
- package/template-hono/public/favicon.ico +0 -0
- package/template-hono/public/file.svg +1 -0
- package/template-hono/public/globe.svg +1 -0
- package/template-hono/public/imagicma-picker-bridge.js +374 -0
- package/template-hono/public/next.svg +1 -0
- package/template-hono/public/vercel.svg +1 -0
- package/template-hono/public/window.svg +1 -0
- package/template-hono/scripts/imagicma-common.mjs +118 -0
- package/template-hono/scripts/imagicma-dev.mjs +29 -0
- package/template-hono/scripts/imagicma-guard.mjs +17 -0
- package/template-hono/scripts/imagicma-start.mjs +24 -0
- package/template-hono/server/app.ts +40 -0
- package/template-hono/server/db.ts +22 -0
- package/template-hono/server/dev-app.ts +5 -0
- package/template-hono/server/index.ts +94 -0
- package/template-hono/server/routes/greeting.ts +25 -0
- package/template-hono/server/storage.ts +39 -0
- package/template-hono/shared/routes.ts +13 -0
- package/template-hono/shared/schema.ts +17 -0
- package/template-hono/tailwind.config.mjs +97 -0
- package/template-hono/tsconfig.json +39 -0
- package/template-hono/tsconfig.server.json +15 -0
- package/template-hono/types/pg.d.ts +19 -0
- package/template-hono/vite.config.ts +125 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Badge } from "@/components/ui/badge";
|
|
3
|
+
import { Button } from "@/components/ui/button";
|
|
4
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
5
|
+
import { useGreeting } from "@/hooks/use-greeting";
|
|
6
|
+
import { toast } from "@/hooks/use-toast";
|
|
7
|
+
|
|
8
|
+
export function HelloClient() {
|
|
9
|
+
const { data, isLoading, error, refetch, isFetching } = useGreeting();
|
|
10
|
+
|
|
11
|
+
const status = isLoading ? "loading" : error ? "error" : "ready";
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Card>
|
|
15
|
+
<CardHeader>
|
|
16
|
+
<div className="flex items-center justify-between gap-4">
|
|
17
|
+
<div className="space-y-1">
|
|
18
|
+
<CardTitle>GET /api/greeting</CardTitle>
|
|
19
|
+
<CardDescription>响应会被 Zod 校验,并展示到 UI 中。</CardDescription>
|
|
20
|
+
</div>
|
|
21
|
+
<Badge variant={status === "error" ? "destructive" : "secondary"}>{status}</Badge>
|
|
22
|
+
</div>
|
|
23
|
+
</CardHeader>
|
|
24
|
+
<CardContent className="space-y-4">
|
|
25
|
+
<div className="rounded-lg border bg-card p-4">
|
|
26
|
+
{isLoading ? (
|
|
27
|
+
<p className="text-sm text-muted-foreground">加载中…</p>
|
|
28
|
+
) : error ? (
|
|
29
|
+
<p className="text-sm text-destructive">
|
|
30
|
+
{error instanceof Error ? error.message : "请求失败"}
|
|
31
|
+
</p>
|
|
32
|
+
) : (
|
|
33
|
+
<p className="text-lg leading-7">“{data?.message}”</p>
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div className="flex flex-wrap gap-2">
|
|
38
|
+
<Button type="button" onClick={() => refetch()} disabled={isFetching}>
|
|
39
|
+
{isFetching ? "刷新中…" : "刷新"}
|
|
40
|
+
</Button>
|
|
41
|
+
<Button
|
|
42
|
+
type="button"
|
|
43
|
+
variant="outline"
|
|
44
|
+
onClick={() =>
|
|
45
|
+
toast({
|
|
46
|
+
title: "Toast 正常工作",
|
|
47
|
+
description: "如果你能看到我,说明 shadcn/toast 已接入。",
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
触发 Toast
|
|
52
|
+
</Button>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<EnvHint />
|
|
56
|
+
</CardContent>
|
|
57
|
+
</Card>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function EnvHint() {
|
|
62
|
+
return (
|
|
63
|
+
<div className="text-sm text-muted-foreground">
|
|
64
|
+
<p>
|
|
65
|
+
若 API 报错请检查:是否已在 <code>.env.local</code> 设置 <code>DATABASE_URL</code>,并执行 <code>npm run db:push</code>。
|
|
66
|
+
</p>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|