@lark-apaas/coding-templates 0.1.11 → 0.1.14
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/meta.json +6 -0
- package/package.json +2 -1
- package/template-apex/README.md +294 -0
- package/template-apex/_env.local.example +1 -0
- package/template-apex/_gitignore +27 -0
- package/template-apex/client/index.html +20 -0
- package/template-apex/client/public/favicon.svg +1 -0
- package/template-apex/client/public/icons.svg +24 -0
- package/template-apex/client/src/api/index.ts +39 -0
- package/template-apex/client/src/app.tsx +21 -0
- package/template-apex/client/src/components/layout.tsx +11 -0
- package/template-apex/client/src/components/ui/accordion.tsx +66 -0
- package/template-apex/client/src/components/ui/alert-dialog.tsx +157 -0
- package/template-apex/client/src/components/ui/alert.tsx +71 -0
- package/template-apex/client/src/components/ui/aspect-ratio.tsx +11 -0
- package/template-apex/client/src/components/ui/avatar.tsx +53 -0
- package/template-apex/client/src/components/ui/badge.tsx +42 -0
- package/template-apex/client/src/components/ui/breadcrumb.tsx +109 -0
- package/template-apex/client/src/components/ui/button-group.tsx +83 -0
- package/template-apex/client/src/components/ui/button.tsx +69 -0
- package/template-apex/client/src/components/ui/calendar.tsx +213 -0
- package/template-apex/client/src/components/ui/card.tsx +82 -0
- package/template-apex/client/src/components/ui/carousel.tsx +241 -0
- package/template-apex/client/src/components/ui/chart.tsx +357 -0
- package/template-apex/client/src/components/ui/checkbox.tsx +32 -0
- package/template-apex/client/src/components/ui/collapsible.tsx +33 -0
- package/template-apex/client/src/components/ui/command.tsx +208 -0
- package/template-apex/client/src/components/ui/context-menu.tsx +324 -0
- package/template-apex/client/src/components/ui/dialog.tsx +143 -0
- package/template-apex/client/src/components/ui/drawer.tsx +135 -0
- package/template-apex/client/src/components/ui/dropdown-menu.tsx +329 -0
- package/template-apex/client/src/components/ui/empty.tsx +104 -0
- package/template-apex/client/src/components/ui/field.tsx +248 -0
- package/template-apex/client/src/components/ui/form.tsx +167 -0
- package/template-apex/client/src/components/ui/hover-card.tsx +44 -0
- package/template-apex/client/src/components/ui/image.tsx +183 -0
- package/template-apex/client/src/components/ui/input-group.tsx +166 -0
- package/template-apex/client/src/components/ui/input-otp.tsx +77 -0
- package/template-apex/client/src/components/ui/input.tsx +21 -0
- package/template-apex/client/src/components/ui/item.tsx +193 -0
- package/template-apex/client/src/components/ui/kbd.tsx +28 -0
- package/template-apex/client/src/components/ui/label.tsx +24 -0
- package/template-apex/client/src/components/ui/menubar.tsx +348 -0
- package/template-apex/client/src/components/ui/native-select.tsx +48 -0
- package/template-apex/client/src/components/ui/navigation-menu.tsx +168 -0
- package/template-apex/client/src/components/ui/pagination.tsx +127 -0
- package/template-apex/client/src/components/ui/popover.tsx +48 -0
- package/template-apex/client/src/components/ui/progress.tsx +31 -0
- package/template-apex/client/src/components/ui/radio-group.tsx +45 -0
- package/template-apex/client/src/components/ui/resizable.tsx +56 -0
- package/template-apex/client/src/components/ui/scroll-area.tsx +58 -0
- package/template-apex/client/src/components/ui/select.tsx +243 -0
- package/template-apex/client/src/components/ui/separator.tsx +28 -0
- package/template-apex/client/src/components/ui/sheet.tsx +139 -0
- package/template-apex/client/src/components/ui/sidebar.tsx +727 -0
- package/template-apex/client/src/components/ui/skeleton.tsx +13 -0
- package/template-apex/client/src/components/ui/slider.tsx +87 -0
- package/template-apex/client/src/components/ui/sonner.tsx +67 -0
- package/template-apex/client/src/components/ui/spinner.tsx +16 -0
- package/template-apex/client/src/components/ui/switch.tsx +31 -0
- package/template-apex/client/src/components/ui/table.tsx +116 -0
- package/template-apex/client/src/components/ui/tabs.tsx +66 -0
- package/template-apex/client/src/components/ui/textarea.tsx +18 -0
- package/template-apex/client/src/components/ui/toggle-group.tsx +83 -0
- package/template-apex/client/src/components/ui/toggle.tsx +47 -0
- package/template-apex/client/src/components/ui/tooltip.tsx +61 -0
- package/template-apex/client/src/hooks/use-mobile.ts +19 -0
- package/template-apex/client/src/index.css +131 -0
- package/template-apex/client/src/lib/utils.ts +6 -0
- package/template-apex/client/src/main.tsx +10 -0
- package/template-apex/client/src/pages/home/index.tsx +20 -0
- package/template-apex/client/src/pages/todos/components/todo-form.tsx +40 -0
- package/template-apex/client/src/pages/todos/components/todo-list.tsx +43 -0
- package/template-apex/client/src/pages/todos/index.tsx +47 -0
- package/template-apex/components.json +21 -0
- package/template-apex/eslint.config.js +54 -0
- package/template-apex/package.json +91 -0
- package/template-apex/scripts/build.sh +51 -0
- package/template-apex/server/db/index.ts +8 -0
- package/template-apex/server/db/schema.ts +8 -0
- package/template-apex/server/index.ts +34 -0
- package/template-apex/server/routes/index.ts +6 -0
- package/template-apex/server/routes/todos.ts +53 -0
- package/template-apex/server/types.d.ts +4 -0
- package/template-apex/shared/api.interface.ts +23 -0
- package/template-apex/shared/types.ts +9 -0
- package/template-apex/tsconfig.app.json +33 -0
- package/template-apex/tsconfig.json +14 -0
- package/template-apex/tsconfig.node.json +31 -0
- package/template-apex/tsconfig.server.json +19 -0
- package/template-apex/vite.config.ts +18 -0
- package/template-vite-react/README.md +23 -8
- package/template-vite-react/client/src/app.tsx +2 -2
- package/template-vite-react/client/src/components/layout.tsx +2 -4
- package/template-vite-react/client/src/lib/utils.ts +3 -3
- package/template-vite-react/client/src/pages/{home/index.tsx → HomePage/HomePage.tsx} +1 -1
- package/template-vite-react/client/src/pages/NotFoundPage/NotFoundPage.tsx +11 -0
- /package/{template-vite-react → template-apex}/client/src/pages/not-found/index.tsx +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@import "tw-animate-css";
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
--button-outline: rgba(0,0,0, .10);
|
|
6
|
+
--badge-outline: rgba(0,0,0, .05);
|
|
7
|
+
--opaque-button-border-intensity: -8;
|
|
8
|
+
--elevate-1: rgba(0,0,0, .03);
|
|
9
|
+
--elevate-2: rgba(0,0,0, .08);
|
|
10
|
+
|
|
11
|
+
--background: hsl(0 0% 100%);
|
|
12
|
+
--foreground: hsl(220 14% 14%);
|
|
13
|
+
--card: hsl(0 0% 100%);
|
|
14
|
+
--card-foreground: hsl(220 14% 14%);
|
|
15
|
+
--popover: hsl(0 0% 100%);
|
|
16
|
+
--popover-foreground: hsl(220 14% 14%);
|
|
17
|
+
--primary: hsl(221 83% 53%);
|
|
18
|
+
--primary-foreground: hsl(220 14% 98%);
|
|
19
|
+
--secondary: hsl(220 14% 96%);
|
|
20
|
+
--secondary-foreground: hsl(220 14% 14%);
|
|
21
|
+
--muted: hsl(220 14% 96%);
|
|
22
|
+
--muted-foreground: hsl(218 7% 59%);
|
|
23
|
+
--accent: hsl(220 14% 96%);
|
|
24
|
+
--accent-foreground: hsl(220 14% 14%);
|
|
25
|
+
--info: hsl(221 83% 53%);
|
|
26
|
+
--info-foreground: hsl(230 100% 98%);
|
|
27
|
+
--destructive: hsl(2 84% 62%);
|
|
28
|
+
--destructive-foreground: hsl(0 0% 100%);
|
|
29
|
+
--success: hsl(130 54% 42%);
|
|
30
|
+
--success-foreground: hsl(115 77% 97%);
|
|
31
|
+
--warning: hsl(26 90% 49%);
|
|
32
|
+
--warning-foreground: hsl(33 100% 96%);
|
|
33
|
+
--border: hsl(220 14% 89%);
|
|
34
|
+
--input: hsl(220 14% 89%);
|
|
35
|
+
--ring: hsl(221 83% 53%);
|
|
36
|
+
--chart-1: hsl(222 82% 56%);
|
|
37
|
+
--chart-2: hsl(174 77% 46%);
|
|
38
|
+
--chart-3: hsl(46 100% 52%);
|
|
39
|
+
--chart-4: hsl(27 92% 49%);
|
|
40
|
+
--chart-5: hsl(292 54% 76%);
|
|
41
|
+
--sidebar: hsl(220 14% 96%);
|
|
42
|
+
--sidebar-foreground: hsl(220 14% 14%);
|
|
43
|
+
--sidebar-primary: hsl(221 83% 53%);
|
|
44
|
+
--sidebar-primary-foreground: hsl(220 14% 98%);
|
|
45
|
+
--sidebar-accent: hsl(222 100% 94%);
|
|
46
|
+
--sidebar-accent-foreground: hsl(221 83% 53%);
|
|
47
|
+
--sidebar-border: hsl(220 14% 89%);
|
|
48
|
+
--sidebar-ring: hsl(221 83% 53%);
|
|
49
|
+
|
|
50
|
+
--primary-border: hsl(from hsl(221 83% 53%) h s calc(l + var(--opaque-button-border-intensity)));
|
|
51
|
+
--secondary-border: hsl(from hsl(220 14% 96%) h s calc(l + var(--opaque-button-border-intensity)));
|
|
52
|
+
--destructive-border: hsl(from hsl(2 84% 62%) h s calc(l + var(--opaque-button-border-intensity)));
|
|
53
|
+
--accent-border: hsl(from hsl(220 14% 96%) h s calc(l + var(--opaque-button-border-intensity)));
|
|
54
|
+
--muted-border: hsl(from hsl(220 14% 96%) h s calc(l + var(--opaque-button-border-intensity)));
|
|
55
|
+
|
|
56
|
+
--font-sans:
|
|
57
|
+
-apple-system, BlinkMacSystemFont, 'Helvetica Neue', Tahoma, 'PingFang SC',
|
|
58
|
+
'Microsoft Yahei', Arial, 'Hiragino Sans GB', sans-serif,
|
|
59
|
+
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
60
|
+
--font-mono: Source Code Pro, monospace;
|
|
61
|
+
--radius: 0.5rem;
|
|
62
|
+
--spacing: 0.25rem;
|
|
63
|
+
|
|
64
|
+
--shadow-2xs: 0px 2px 12px 0px hsl(0 0% 0% / 0.01);
|
|
65
|
+
--shadow-xs: 0px 2px 12px 0px hsl(0 0% 0% / 0.01);
|
|
66
|
+
--shadow-sm: 0px 2px 12px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
|
|
67
|
+
--shadow: 0px 2px 12px 0px hsl(0 0% 0% / 0.02), 0px 1px 2px -1px hsl(0 0% 0% / 0.02);
|
|
68
|
+
--shadow-md: 0px 2px 12px 0px hsl(0 0% 0% / 0.02), 0px 2px 4px -1px hsl(0 0% 0% / 0.02);
|
|
69
|
+
--shadow-lg: 0px 2px 12px 0px hsl(0 0% 0% / 0.02), 0px 4px 6px -1px hsl(0 0% 0% / 0.02);
|
|
70
|
+
--shadow-xl: 0px 2px 12px 0px hsl(0 0% 0% / 0.02), 0px 8px 10px -1px hsl(0 0% 0% / 0.02);
|
|
71
|
+
--shadow-2xl: 0px 2px 12px 0px hsl(0 0% 0% / 0.05);
|
|
72
|
+
--tracking-normal: 0em;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@theme inline {
|
|
76
|
+
--color-background: var(--background);
|
|
77
|
+
--color-foreground: var(--foreground);
|
|
78
|
+
--color-card: var(--card);
|
|
79
|
+
--color-card-foreground: var(--card-foreground);
|
|
80
|
+
--color-popover: var(--popover);
|
|
81
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
82
|
+
--color-primary: var(--primary);
|
|
83
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
84
|
+
--color-secondary: var(--secondary);
|
|
85
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
86
|
+
--color-muted: var(--muted);
|
|
87
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
88
|
+
--color-accent: var(--accent);
|
|
89
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
90
|
+
--color-info: var(--info);
|
|
91
|
+
--color-info-foreground: var(--info-foreground);
|
|
92
|
+
--color-destructive: var(--destructive);
|
|
93
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
94
|
+
--color-success: var(--success);
|
|
95
|
+
--color-success-foreground: var(--success-foreground);
|
|
96
|
+
--color-warning: var(--warning);
|
|
97
|
+
--color-warning-foreground: var(--warning-foreground);
|
|
98
|
+
--color-border: var(--border);
|
|
99
|
+
--color-input: var(--input);
|
|
100
|
+
--color-ring: var(--ring);
|
|
101
|
+
--color-chart-1: var(--chart-1);
|
|
102
|
+
--color-chart-2: var(--chart-2);
|
|
103
|
+
--color-chart-3: var(--chart-3);
|
|
104
|
+
--color-chart-4: var(--chart-4);
|
|
105
|
+
--color-chart-5: var(--chart-5);
|
|
106
|
+
--color-sidebar: var(--sidebar);
|
|
107
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
108
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
109
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
110
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
111
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
112
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
113
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
114
|
+
|
|
115
|
+
--font-sans: var(--font-sans);
|
|
116
|
+
--font-mono: var(--font-mono);
|
|
117
|
+
|
|
118
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
119
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
120
|
+
--radius-lg: var(--radius);
|
|
121
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
122
|
+
|
|
123
|
+
--shadow-2xs: var(--shadow-2xs);
|
|
124
|
+
--shadow-xs: var(--shadow-xs);
|
|
125
|
+
--shadow-sm: var(--shadow-sm);
|
|
126
|
+
--shadow: var(--shadow);
|
|
127
|
+
--shadow-md: var(--shadow-md);
|
|
128
|
+
--shadow-lg: var(--shadow-lg);
|
|
129
|
+
--shadow-xl: var(--shadow-xl);
|
|
130
|
+
--shadow-2xl: var(--shadow-2xl);
|
|
131
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Link } from "react-router-dom";
|
|
2
|
+
|
|
3
|
+
export default function HomePage() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="flex flex-col items-center justify-center py-24">
|
|
6
|
+
<h1 className="text-5xl font-bold tracking-tight sm:text-7xl mb-4">
|
|
7
|
+
Hello OpenClaw
|
|
8
|
+
</h1>
|
|
9
|
+
<p className="text-lg text-muted-foreground mb-8">
|
|
10
|
+
Apex full-stack template
|
|
11
|
+
</p>
|
|
12
|
+
<Link
|
|
13
|
+
to="/todos"
|
|
14
|
+
className="inline-flex items-center justify-center rounded-md bg-primary px-6 py-3 text-sm font-medium text-primary-foreground hover:bg-primary/90"
|
|
15
|
+
>
|
|
16
|
+
Try the Todos Demo
|
|
17
|
+
</Link>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
interface TodoFormProps {
|
|
4
|
+
onSubmit: (title: string) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function TodoForm({ onSubmit }: TodoFormProps) {
|
|
8
|
+
const [title, setTitle] = useState("");
|
|
9
|
+
const [submitting, setSubmitting] = useState(false);
|
|
10
|
+
|
|
11
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
const trimmed = title.trim();
|
|
14
|
+
if (!trimmed) return;
|
|
15
|
+
setSubmitting(true);
|
|
16
|
+
await onSubmit(trimmed);
|
|
17
|
+
setTitle("");
|
|
18
|
+
setSubmitting(false);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<form onSubmit={handleSubmit} className="flex gap-2">
|
|
23
|
+
<input
|
|
24
|
+
type="text"
|
|
25
|
+
value={title}
|
|
26
|
+
onChange={(e) => setTitle(e.target.value)}
|
|
27
|
+
placeholder="What needs to be done?"
|
|
28
|
+
className="flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
29
|
+
disabled={submitting}
|
|
30
|
+
/>
|
|
31
|
+
<button
|
|
32
|
+
type="submit"
|
|
33
|
+
disabled={submitting || !title.trim()}
|
|
34
|
+
className="inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50"
|
|
35
|
+
>
|
|
36
|
+
Add
|
|
37
|
+
</button>
|
|
38
|
+
</form>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Todo } from "@shared/types";
|
|
2
|
+
import { Trash2 } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
interface TodoListProps {
|
|
5
|
+
todos: Todo[];
|
|
6
|
+
onToggle: (id: number, completed: boolean) => Promise<void>;
|
|
7
|
+
onDelete: (id: number) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function TodoList({ todos, onToggle, onDelete }: TodoListProps) {
|
|
11
|
+
if (todos.length === 0) {
|
|
12
|
+
return <p className="text-muted-foreground mt-8 text-center">No todos yet.</p>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<ul className="mt-6 space-y-2">
|
|
17
|
+
{todos.map((todo) => (
|
|
18
|
+
<li
|
|
19
|
+
key={todo.id}
|
|
20
|
+
className="flex items-center gap-3 rounded-md border border-border px-4 py-3"
|
|
21
|
+
>
|
|
22
|
+
<input
|
|
23
|
+
type="checkbox"
|
|
24
|
+
checked={todo.completed}
|
|
25
|
+
onChange={() => onToggle(todo.id, !todo.completed)}
|
|
26
|
+
className="h-4 w-4 rounded border-border"
|
|
27
|
+
/>
|
|
28
|
+
<span
|
|
29
|
+
className={`flex-1 text-sm ${todo.completed ? "line-through text-muted-foreground" : ""}`}
|
|
30
|
+
>
|
|
31
|
+
{todo.title}
|
|
32
|
+
</span>
|
|
33
|
+
<button
|
|
34
|
+
onClick={() => onDelete(todo.id)}
|
|
35
|
+
className="text-muted-foreground hover:text-destructive transition-colors"
|
|
36
|
+
>
|
|
37
|
+
<Trash2 className="h-4 w-4" />
|
|
38
|
+
</button>
|
|
39
|
+
</li>
|
|
40
|
+
))}
|
|
41
|
+
</ul>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import type { Todo } from "@shared/types";
|
|
3
|
+
import { todosApi } from "@/api";
|
|
4
|
+
import { TodoForm } from "./components/todo-form";
|
|
5
|
+
import { TodoList } from "./components/todo-list";
|
|
6
|
+
|
|
7
|
+
export default function TodosPage() {
|
|
8
|
+
const [todos, setTodos] = useState<Todo[]>([]);
|
|
9
|
+
const [loading, setLoading] = useState(true);
|
|
10
|
+
|
|
11
|
+
const refresh = async () => {
|
|
12
|
+
const list = await todosApi.list();
|
|
13
|
+
setTodos(list);
|
|
14
|
+
setLoading(false);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
refresh();
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
const handleCreate = async (title: string) => {
|
|
22
|
+
await todosApi.create({ title });
|
|
23
|
+
await refresh();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const handleToggle = async (id: number, completed: boolean) => {
|
|
27
|
+
await todosApi.update(id, { completed });
|
|
28
|
+
await refresh();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const handleDelete = async (id: number) => {
|
|
32
|
+
await todosApi.remove(id);
|
|
33
|
+
await refresh();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className="max-w-2xl mx-auto py-12">
|
|
38
|
+
<h1 className="text-3xl font-bold mb-8">Todos</h1>
|
|
39
|
+
<TodoForm onSubmit={handleCreate} />
|
|
40
|
+
{loading ? (
|
|
41
|
+
<p className="text-muted-foreground mt-8">Loading...</p>
|
|
42
|
+
) : (
|
|
43
|
+
<TodoList todos={todos} onToggle={handleToggle} onDelete={handleDelete} />
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": false,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "",
|
|
8
|
+
"css": "client/src/index.css",
|
|
9
|
+
"baseColor": "neutral",
|
|
10
|
+
"cssVariables": true,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"aliases": {
|
|
14
|
+
"components": "@/components",
|
|
15
|
+
"utils": "@/lib/utils",
|
|
16
|
+
"ui": "@/components/ui",
|
|
17
|
+
"lib": "@/lib",
|
|
18
|
+
"hooks": "@/hooks"
|
|
19
|
+
},
|
|
20
|
+
"iconLibrary": "lucide"
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import tseslint from 'typescript-eslint'
|
|
6
|
+
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
7
|
+
|
|
8
|
+
export default defineConfig([
|
|
9
|
+
globalIgnores(['dist']),
|
|
10
|
+
{
|
|
11
|
+
files: ['client/**/*.{ts,tsx}'],
|
|
12
|
+
extends: [
|
|
13
|
+
js.configs.recommended,
|
|
14
|
+
tseslint.configs.recommended,
|
|
15
|
+
reactHooks.configs.flat.recommended,
|
|
16
|
+
reactRefresh.configs.vite,
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
globals: globals.browser,
|
|
21
|
+
},
|
|
22
|
+
rules: {
|
|
23
|
+
// 关闭仅语法相关、不影响编译和运行时的规则
|
|
24
|
+
'react-refresh/only-export-components': 'off',
|
|
25
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
26
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
27
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
28
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
29
|
+
'no-empty': 'off',
|
|
30
|
+
'prefer-const': 'off',
|
|
31
|
+
'no-unused-labels': 'off',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
files: ['server/**/*.ts', 'shared/**/*.ts'],
|
|
36
|
+
extends: [
|
|
37
|
+
js.configs.recommended,
|
|
38
|
+
tseslint.configs.recommended,
|
|
39
|
+
],
|
|
40
|
+
languageOptions: {
|
|
41
|
+
ecmaVersion: 2020,
|
|
42
|
+
globals: globals.node,
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
46
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
47
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
48
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
49
|
+
'no-empty': 'off',
|
|
50
|
+
'prefer-const': 'off',
|
|
51
|
+
'no-unused-labels': 'off',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
])
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"mclaw": {
|
|
7
|
+
"stack": "apex",
|
|
8
|
+
"stackVersion": "0.1.0"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "npx tsx --watch server/index.ts & npx vite --host",
|
|
12
|
+
"dev:server": "tsx --watch server/index.ts",
|
|
13
|
+
"dev:client": "vite --host",
|
|
14
|
+
"build": "bash scripts/build.sh",
|
|
15
|
+
"lint": "npm run lint:client && npm run lint:server",
|
|
16
|
+
"lint:client": "eslint client/src",
|
|
17
|
+
"lint:server": "eslint server"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@hookform/resolvers": "^5.2.2",
|
|
21
|
+
"@radix-ui/react-accordion": "^1.2.11",
|
|
22
|
+
"@radix-ui/react-alert-dialog": "^1.1.14",
|
|
23
|
+
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
|
24
|
+
"@radix-ui/react-avatar": "^1.1.10",
|
|
25
|
+
"@radix-ui/react-checkbox": "^1.3.2",
|
|
26
|
+
"@radix-ui/react-collapsible": "^1.1.11",
|
|
27
|
+
"@radix-ui/react-context-menu": "^2.2.14",
|
|
28
|
+
"@radix-ui/react-dialog": "^1.1.14",
|
|
29
|
+
"@radix-ui/react-dropdown-menu": "^2.1.14",
|
|
30
|
+
"@radix-ui/react-hover-card": "^1.1.14",
|
|
31
|
+
"@radix-ui/react-label": "^2.1.7",
|
|
32
|
+
"@radix-ui/react-menubar": "^1.1.14",
|
|
33
|
+
"@radix-ui/react-navigation-menu": "^1.2.13",
|
|
34
|
+
"@radix-ui/react-popover": "^1.1.14",
|
|
35
|
+
"@radix-ui/react-progress": "^1.1.7",
|
|
36
|
+
"@radix-ui/react-radio-group": "^1.3.7",
|
|
37
|
+
"@radix-ui/react-scroll-area": "^1.2.8",
|
|
38
|
+
"@radix-ui/react-select": "^2.1.14",
|
|
39
|
+
"@radix-ui/react-separator": "^1.1.7",
|
|
40
|
+
"@radix-ui/react-slider": "^1.3.5",
|
|
41
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
42
|
+
"@radix-ui/react-switch": "^1.2.5",
|
|
43
|
+
"@radix-ui/react-tabs": "^1.1.11",
|
|
44
|
+
"@radix-ui/react-toggle": "^1.1.9",
|
|
45
|
+
"@radix-ui/react-toggle-group": "^1.1.10",
|
|
46
|
+
"@radix-ui/react-tooltip": "^1.1.18",
|
|
47
|
+
"@formkit/auto-animate": "^0.9.0",
|
|
48
|
+
"framer-motion": "^12.38.0",
|
|
49
|
+
"class-variance-authority": "^0.7.1",
|
|
50
|
+
"clsx": "^2.1.1",
|
|
51
|
+
"cmdk": "^1.1.1",
|
|
52
|
+
"date-fns": "^4.1.0",
|
|
53
|
+
"drizzle-orm": "^0.45.1",
|
|
54
|
+
"embla-carousel-react": "^8.6.0",
|
|
55
|
+
"express": "^5.1.0",
|
|
56
|
+
"hbs": "^4.2.0",
|
|
57
|
+
"input-otp": "^1.4.2",
|
|
58
|
+
"lucide-react": "^1.7.0",
|
|
59
|
+
"next-themes": "^0.4.6",
|
|
60
|
+
"postgres": "^3.4.8",
|
|
61
|
+
"react": "^19.2.4",
|
|
62
|
+
"react-day-picker": "^9.14.0",
|
|
63
|
+
"react-dom": "^19.2.4",
|
|
64
|
+
"react-hook-form": "^7.72.0",
|
|
65
|
+
"react-resizable-panels": "^4.7.6",
|
|
66
|
+
"react-router-dom": "^7.13.2",
|
|
67
|
+
"recharts": "^3.8.0",
|
|
68
|
+
"sonner": "^2.0.7",
|
|
69
|
+
"tailwind-merge": "^3.5.0",
|
|
70
|
+
"tailwindcss": "^4.2.2",
|
|
71
|
+
"tw-animate-css": "^1.2.0",
|
|
72
|
+
"vaul": "^1.1.2",
|
|
73
|
+
"zod": "^4.3.6"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@eslint/js": "^9",
|
|
77
|
+
"@lark-apaas/coding-vite-preset": "^0.1.0",
|
|
78
|
+
"@types/express": "^5",
|
|
79
|
+
"@types/node": "^24",
|
|
80
|
+
"@types/react": "^19",
|
|
81
|
+
"@types/react-dom": "^19",
|
|
82
|
+
"eslint": "^9",
|
|
83
|
+
"eslint-plugin-react-hooks": "^7",
|
|
84
|
+
"eslint-plugin-react-refresh": "^0.5",
|
|
85
|
+
"globals": "^17",
|
|
86
|
+
"tsx": "^4",
|
|
87
|
+
"typescript": "~5.9",
|
|
88
|
+
"typescript-eslint": "^8",
|
|
89
|
+
"vite": "^8"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
5
|
+
OUTPUT="$ROOT/dist/output"
|
|
6
|
+
OUTPUT_RESOURCE="$ROOT/dist/output_resource"
|
|
7
|
+
OUTPUT_STATIC="$ROOT/dist/output_static"
|
|
8
|
+
|
|
9
|
+
# 清理
|
|
10
|
+
rm -rf "$ROOT/dist"
|
|
11
|
+
|
|
12
|
+
# 1. Vite 构建前端 → dist/client/
|
|
13
|
+
npx vite build --outDir "$ROOT/dist/client" --emptyOutDir
|
|
14
|
+
|
|
15
|
+
# 2. tsc 构建服务端 → dist/server/
|
|
16
|
+
npx tsc -p tsconfig.server.json
|
|
17
|
+
|
|
18
|
+
# 3. 组装 dist/output/
|
|
19
|
+
mkdir -p "$OUTPUT"
|
|
20
|
+
|
|
21
|
+
# HTML → dist/output/(部署平台托管静态文件)
|
|
22
|
+
find "$ROOT/dist/client" -maxdepth 1 -name '*.html' -exec mv {} "$OUTPUT/" \;
|
|
23
|
+
|
|
24
|
+
# 生成 routes.json
|
|
25
|
+
echo '{ "version": 1, "type": "apex", "fallback": "index.html" }' > "$OUTPUT/routes.json"
|
|
26
|
+
|
|
27
|
+
# 服务端产物(tsc 输出保留 server/、shared/ 子目录)
|
|
28
|
+
cp -r "$ROOT/dist/server/"* "$OUTPUT/"
|
|
29
|
+
|
|
30
|
+
# 复制 package.json(运行时需要依赖信息)
|
|
31
|
+
cp "$ROOT/package.json" "$OUTPUT/package.json"
|
|
32
|
+
|
|
33
|
+
# 4. assets/ → dist/output_resource/(JS/CSS/字体,上传到 CDN)
|
|
34
|
+
if [ -d "$ROOT/dist/client/assets" ]; then
|
|
35
|
+
mkdir -p "$OUTPUT_RESOURCE"
|
|
36
|
+
cp -r "$ROOT/dist/client/assets" "$OUTPUT_RESOURCE/"
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# 5. 私有静态资源 → dist/output_static/
|
|
40
|
+
if [ -d "$ROOT/shared/static" ]; then
|
|
41
|
+
mkdir -p "$OUTPUT_STATIC"
|
|
42
|
+
rsync -a --exclude='*.ts' --exclude='*.tsx' --exclude='*.js' --exclude='*.jsx' "$ROOT/shared/static/" "$OUTPUT_STATIC/"
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# 清理中间产物
|
|
46
|
+
rm -rf "$ROOT/dist/client" "$ROOT/dist/server"
|
|
47
|
+
|
|
48
|
+
echo "Build complete"
|
|
49
|
+
echo " HTML + Server → dist/output/"
|
|
50
|
+
[ -d "$OUTPUT_RESOURCE" ] && echo " Resource → dist/output_resource/" || true
|
|
51
|
+
[ -d "$OUTPUT_STATIC" ] && echo " Static → dist/output_static/" || true
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
2
|
+
import postgres from "postgres";
|
|
3
|
+
import * as schema from "./schema";
|
|
4
|
+
|
|
5
|
+
const connectionString = process.env.DATABASE_URL!;
|
|
6
|
+
const client = postgres(connectionString);
|
|
7
|
+
|
|
8
|
+
export const db = drizzle(client, { schema });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { pgTable, serial, text, boolean, timestamp } from "drizzle-orm/pg-core";
|
|
2
|
+
|
|
3
|
+
export const todos = pgTable("todos", {
|
|
4
|
+
id: serial("id").primaryKey(),
|
|
5
|
+
title: text("title").notNull(),
|
|
6
|
+
completed: boolean("completed").notNull().default(false),
|
|
7
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
8
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import hbs from "hbs";
|
|
6
|
+
import { registerRoutes } from "./routes/index";
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const port = Number(process.env.PORT) || 3000;
|
|
10
|
+
|
|
11
|
+
const app = express();
|
|
12
|
+
|
|
13
|
+
// JSON body parsing
|
|
14
|
+
app.use(express.json());
|
|
15
|
+
|
|
16
|
+
// Register API routes
|
|
17
|
+
registerRoutes(app);
|
|
18
|
+
|
|
19
|
+
// Page rendering: compile index.html as hbs template, inject runtime data
|
|
20
|
+
// Static assets (JS/CSS/images) are served by the deployment platform / CDN
|
|
21
|
+
const templatePath = path.resolve(__dirname, "../public/index.html");
|
|
22
|
+
const template = hbs.compile(fs.readFileSync(templatePath, "utf-8"));
|
|
23
|
+
|
|
24
|
+
app.get("*", (_req, res) => {
|
|
25
|
+
const html = template({
|
|
26
|
+
appId: process.env.MCLAW_APP_ID || "",
|
|
27
|
+
cdnDomain: process.env.MCLAW_CDN_DOMAIN || "",
|
|
28
|
+
});
|
|
29
|
+
res.type("html").send(html);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
app.listen(port, "0.0.0.0", () => {
|
|
33
|
+
console.log(`Server running at http://localhost:${port}`);
|
|
34
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { eq, desc } from "drizzle-orm";
|
|
3
|
+
import { db } from "../db/index";
|
|
4
|
+
import { todos } from "../db/schema";
|
|
5
|
+
import { createTodoSchema, updateTodoSchema } from "../../shared/api.interface";
|
|
6
|
+
|
|
7
|
+
const router = Router();
|
|
8
|
+
|
|
9
|
+
// GET /api/todos
|
|
10
|
+
router.get("/", async (_req, res) => {
|
|
11
|
+
const list = await db.select().from(todos).orderBy(desc(todos.createdAt));
|
|
12
|
+
res.json(list);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// POST /api/todos
|
|
16
|
+
router.post("/", async (req, res) => {
|
|
17
|
+
const parsed = createTodoSchema.safeParse(req.body);
|
|
18
|
+
if (!parsed.success) {
|
|
19
|
+
res.status(400).json({ error: parsed.error.flatten() });
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const [todo] = await db.insert(todos).values({ title: parsed.data.title }).returning();
|
|
23
|
+
res.status(201).json(todo);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// PATCH /api/todos/:id
|
|
27
|
+
router.patch("/:id", async (req, res) => {
|
|
28
|
+
const id = Number(req.params.id);
|
|
29
|
+
const parsed = updateTodoSchema.safeParse(req.body);
|
|
30
|
+
if (!parsed.success) {
|
|
31
|
+
res.status(400).json({ error: parsed.error.flatten() });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const [todo] = await db.update(todos).set(parsed.data).where(eq(todos.id, id)).returning();
|
|
35
|
+
if (!todo) {
|
|
36
|
+
res.status(404).json({ error: "Not found" });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
res.json(todo);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// DELETE /api/todos/:id
|
|
43
|
+
router.delete("/:id", async (req, res) => {
|
|
44
|
+
const id = Number(req.params.id);
|
|
45
|
+
const [todo] = await db.delete(todos).where(eq(todos.id, id)).returning();
|
|
46
|
+
if (!todo) {
|
|
47
|
+
res.status(404).json({ error: "Not found" });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
res.json(todo);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export default router;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// API 接口契约定义
|
|
2
|
+
// zod schema 做校验,z.infer 推导类型,前后端共享
|
|
3
|
+
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import type { Todo } from "./types";
|
|
6
|
+
|
|
7
|
+
// ----- Todos -----
|
|
8
|
+
|
|
9
|
+
export const createTodoSchema = z.object({
|
|
10
|
+
title: z.string().min(1).max(500),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const updateTodoSchema = z.object({
|
|
14
|
+
title: z.string().min(1).max(500).optional(),
|
|
15
|
+
completed: z.boolean().optional(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type CreateTodoRequest = z.infer<typeof createTodoSchema>;
|
|
19
|
+
export type UpdateTodoRequest = z.infer<typeof updateTodoSchema>;
|
|
20
|
+
export type CreateTodoResponse = Todo;
|
|
21
|
+
export type UpdateTodoResponse = Todo;
|
|
22
|
+
export type DeleteTodoResponse = Todo;
|
|
23
|
+
export type ListTodosResponse = Todo[];
|