@lark-apaas/coding-templates 0.1.12 → 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.
Files changed (98) hide show
  1. package/meta.json +6 -0
  2. package/package.json +2 -1
  3. package/template-apex/README.md +294 -0
  4. package/template-apex/_env.local.example +1 -0
  5. package/template-apex/_gitignore +27 -0
  6. package/template-apex/client/index.html +20 -0
  7. package/template-apex/client/public/favicon.svg +1 -0
  8. package/template-apex/client/public/icons.svg +24 -0
  9. package/template-apex/client/src/api/index.ts +39 -0
  10. package/template-apex/client/src/app.tsx +21 -0
  11. package/template-apex/client/src/components/layout.tsx +11 -0
  12. package/template-apex/client/src/components/ui/accordion.tsx +66 -0
  13. package/template-apex/client/src/components/ui/alert-dialog.tsx +157 -0
  14. package/template-apex/client/src/components/ui/alert.tsx +71 -0
  15. package/template-apex/client/src/components/ui/aspect-ratio.tsx +11 -0
  16. package/template-apex/client/src/components/ui/avatar.tsx +53 -0
  17. package/template-apex/client/src/components/ui/badge.tsx +42 -0
  18. package/template-apex/client/src/components/ui/breadcrumb.tsx +109 -0
  19. package/template-apex/client/src/components/ui/button-group.tsx +83 -0
  20. package/template-apex/client/src/components/ui/button.tsx +69 -0
  21. package/template-apex/client/src/components/ui/calendar.tsx +213 -0
  22. package/template-apex/client/src/components/ui/card.tsx +82 -0
  23. package/template-apex/client/src/components/ui/carousel.tsx +241 -0
  24. package/template-apex/client/src/components/ui/chart.tsx +357 -0
  25. package/template-apex/client/src/components/ui/checkbox.tsx +32 -0
  26. package/template-apex/client/src/components/ui/collapsible.tsx +33 -0
  27. package/template-apex/client/src/components/ui/command.tsx +208 -0
  28. package/template-apex/client/src/components/ui/context-menu.tsx +324 -0
  29. package/template-apex/client/src/components/ui/dialog.tsx +143 -0
  30. package/template-apex/client/src/components/ui/drawer.tsx +135 -0
  31. package/template-apex/client/src/components/ui/dropdown-menu.tsx +329 -0
  32. package/template-apex/client/src/components/ui/empty.tsx +104 -0
  33. package/template-apex/client/src/components/ui/field.tsx +248 -0
  34. package/template-apex/client/src/components/ui/form.tsx +167 -0
  35. package/template-apex/client/src/components/ui/hover-card.tsx +44 -0
  36. package/template-apex/client/src/components/ui/image.tsx +183 -0
  37. package/template-apex/client/src/components/ui/input-group.tsx +166 -0
  38. package/template-apex/client/src/components/ui/input-otp.tsx +77 -0
  39. package/template-apex/client/src/components/ui/input.tsx +21 -0
  40. package/template-apex/client/src/components/ui/item.tsx +193 -0
  41. package/template-apex/client/src/components/ui/kbd.tsx +28 -0
  42. package/template-apex/client/src/components/ui/label.tsx +24 -0
  43. package/template-apex/client/src/components/ui/menubar.tsx +348 -0
  44. package/template-apex/client/src/components/ui/native-select.tsx +48 -0
  45. package/template-apex/client/src/components/ui/navigation-menu.tsx +168 -0
  46. package/template-apex/client/src/components/ui/pagination.tsx +127 -0
  47. package/template-apex/client/src/components/ui/popover.tsx +48 -0
  48. package/template-apex/client/src/components/ui/progress.tsx +31 -0
  49. package/template-apex/client/src/components/ui/radio-group.tsx +45 -0
  50. package/template-apex/client/src/components/ui/resizable.tsx +56 -0
  51. package/template-apex/client/src/components/ui/scroll-area.tsx +58 -0
  52. package/template-apex/client/src/components/ui/select.tsx +243 -0
  53. package/template-apex/client/src/components/ui/separator.tsx +28 -0
  54. package/template-apex/client/src/components/ui/sheet.tsx +139 -0
  55. package/template-apex/client/src/components/ui/sidebar.tsx +727 -0
  56. package/template-apex/client/src/components/ui/skeleton.tsx +13 -0
  57. package/template-apex/client/src/components/ui/slider.tsx +87 -0
  58. package/template-apex/client/src/components/ui/sonner.tsx +67 -0
  59. package/template-apex/client/src/components/ui/spinner.tsx +16 -0
  60. package/template-apex/client/src/components/ui/switch.tsx +31 -0
  61. package/template-apex/client/src/components/ui/table.tsx +116 -0
  62. package/template-apex/client/src/components/ui/tabs.tsx +66 -0
  63. package/template-apex/client/src/components/ui/textarea.tsx +18 -0
  64. package/template-apex/client/src/components/ui/toggle-group.tsx +83 -0
  65. package/template-apex/client/src/components/ui/toggle.tsx +47 -0
  66. package/template-apex/client/src/components/ui/tooltip.tsx +61 -0
  67. package/template-apex/client/src/hooks/use-mobile.ts +19 -0
  68. package/template-apex/client/src/index.css +131 -0
  69. package/template-apex/client/src/lib/utils.ts +6 -0
  70. package/template-apex/client/src/main.tsx +10 -0
  71. package/template-apex/client/src/pages/home/index.tsx +20 -0
  72. package/template-apex/client/src/pages/todos/components/todo-form.tsx +40 -0
  73. package/template-apex/client/src/pages/todos/components/todo-list.tsx +43 -0
  74. package/template-apex/client/src/pages/todos/index.tsx +47 -0
  75. package/template-apex/components.json +21 -0
  76. package/template-apex/eslint.config.js +54 -0
  77. package/template-apex/package.json +91 -0
  78. package/template-apex/scripts/build.sh +51 -0
  79. package/template-apex/server/db/index.ts +8 -0
  80. package/template-apex/server/db/schema.ts +8 -0
  81. package/template-apex/server/index.ts +34 -0
  82. package/template-apex/server/routes/index.ts +6 -0
  83. package/template-apex/server/routes/todos.ts +53 -0
  84. package/template-apex/server/types.d.ts +4 -0
  85. package/template-apex/shared/api.interface.ts +23 -0
  86. package/template-apex/shared/types.ts +9 -0
  87. package/template-apex/tsconfig.app.json +33 -0
  88. package/template-apex/tsconfig.json +14 -0
  89. package/template-apex/tsconfig.node.json +31 -0
  90. package/template-apex/tsconfig.server.json +19 -0
  91. package/template-apex/vite.config.ts +18 -0
  92. package/template-vite-react/README.md +23 -8
  93. package/template-vite-react/client/src/app.tsx +2 -2
  94. package/template-vite-react/client/src/components/layout.tsx +2 -4
  95. package/template-vite-react/client/src/lib/utils.ts +3 -3
  96. package/template-vite-react/client/src/pages/{home/index.tsx → HomePage/HomePage.tsx} +1 -1
  97. package/template-vite-react/client/src/pages/NotFoundPage/NotFoundPage.tsx +11 -0
  98. /package/{template-vite-react → template-apex}/client/src/pages/not-found/index.tsx +0 -0
@@ -0,0 +1,9 @@
1
+ // 前后端共享类型定义
2
+ // shared 是最底层模块,不依赖 client 或 server
3
+
4
+ export interface Todo {
5
+ id: number;
6
+ title: string;
7
+ completed: boolean;
8
+ createdAt: string;
9
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "ES2023",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
7
+ "module": "ESNext",
8
+ "types": ["vite/client"],
9
+ "skipLibCheck": true,
10
+
11
+ /* Bundler mode */
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "moduleDetection": "force",
16
+ "noEmit": true,
17
+ "jsx": "react-jsx",
18
+
19
+ /* Linting */
20
+ "strict": true,
21
+ "noUnusedLocals": true,
22
+ "noUnusedParameters": true,
23
+ "erasableSyntaxOnly": true,
24
+ "noFallthroughCasesInSwitch": true,
25
+ "noUncheckedSideEffectImports": true,
26
+ "baseUrl": ".",
27
+ "paths": {
28
+ "@/*": ["./client/src/*"],
29
+ "@shared/*": ["./shared/*"]
30
+ }
31
+ },
32
+ "include": ["client/src", "shared"]
33
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "paths": {
5
+ "@/*": ["./client/src/*"],
6
+ "@shared/*": ["./shared/*"]
7
+ }
8
+ },
9
+ "files": [],
10
+ "references": [
11
+ { "path": "./tsconfig.app.json" },
12
+ { "path": "./tsconfig.node.json" }
13
+ ]
14
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "ES2023",
5
+ "lib": ["ES2023"],
6
+ "module": "ESNext",
7
+ "types": ["node"],
8
+ "skipLibCheck": true,
9
+
10
+ /* Bundler mode */
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "verbatimModuleSyntax": true,
14
+ "moduleDetection": "force",
15
+ "noEmit": true,
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "erasableSyntaxOnly": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+ "noUncheckedSideEffectImports": true,
24
+
25
+ "baseUrl": ".",
26
+ "paths": {
27
+ "@shared/*": ["./shared/*"]
28
+ }
29
+ },
30
+ "include": ["vite.config.ts", "server", "shared"]
31
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2023",
4
+ "lib": ["ES2023"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "types": ["node"],
8
+ "skipLibCheck": true,
9
+ "strict": true,
10
+ "erasableSyntaxOnly": true,
11
+ "outDir": "./dist/server",
12
+ "rootDir": ".",
13
+ "baseUrl": ".",
14
+ "paths": {
15
+ "@shared/*": ["./shared/*"]
16
+ }
17
+ },
18
+ "include": ["server", "shared"]
19
+ }
@@ -0,0 +1,18 @@
1
+ import path from 'path'
2
+ import { defineConfig } from '@lark-apaas/coding-vite-preset'
3
+
4
+ // https://vite.dev/config/
5
+ export default defineConfig({
6
+ root: path.resolve(__dirname, 'client'),
7
+ resolve: {
8
+ alias: {
9
+ '@': path.resolve(__dirname, 'client/src'),
10
+ '@shared': path.resolve(__dirname, 'shared'),
11
+ },
12
+ },
13
+ server: {
14
+ proxy: {
15
+ '/api': 'http://localhost:3000',
16
+ },
17
+ },
18
+ })
@@ -21,8 +21,8 @@ client/src/
21
21
  ├── components/ # 基础 UI 组件(禁止存放业务组件)
22
22
  │ └── ui/ # shadcn/ui 内置组件(勿手动修改)
23
23
  ├── pages/ # 页面模块(每个页面一个目录)
24
- │ └── home/
25
- │ ├── index.tsx # 页面入口
24
+ │ └── HomePage/ # 页面目录使用 PascalCase 命名
25
+ │ ├── HomePage.tsx # 页面入口文件与目录同名
26
26
  │ └── components/ # 页面专属组件
27
27
  ├── hooks/ # 自定义 Hooks
28
28
  └── lib/ # 工具函数(cn() 等)
@@ -88,17 +88,32 @@ export default function DashboardPage() {
88
88
  新增页面在 `client/src/app.tsx` 中注册:
89
89
 
90
90
  ```tsx
91
- <Route element={<Layout />}>
92
- <Route index element={<HomePage />} />
93
- <Route path="dashboard" element={<DashboardPage />} />
94
- <Route path="*" element={<NotFoundPage />} />
95
- </Route>
91
+ import { BrowserRouter, Routes, Route } from "react-router-dom";
92
+ import { Layout } from "@/components/layout";
93
+ import HomePage from "@/pages/HomePage/HomePage";
94
+ import NotFoundPage from "@/pages/NotFoundPage/NotFoundPage";
95
+
96
+ declare const __APP_BASE_PATH__: string;
97
+
98
+ export default function App() {
99
+ return (
100
+ <BrowserRouter basename={__APP_BASE_PATH__}>
101
+ <Routes>
102
+ <Route element={<Layout />}>
103
+ <Route index element={<HomePage />} />
104
+ <Route path="*" element={<NotFoundPage />} />
105
+ </Route>
106
+ </Routes>
107
+ </BrowserRouter>
108
+ );
109
+ }
96
110
  ```
97
111
 
98
112
  **新增页面步骤:**
99
113
 
100
- 1. 在 `client/src/pages/` 下新建页面目录和 `index.tsx`
114
+ 1. 在 `client/src/pages/` 下新建页面目录(如 `DashboardPage`)和 `DashboardPage.tsx`
101
115
  2. 在 `app.tsx` 的 `<Routes>` 内添加 `<Route>` 配置
116
+ 3. **必须调整首页路由**:根据业务需求修改 `index` 路由对应的页面组件(默认的 `HomePage` 仅作为示例,实际开发时需替换为真实的业务首页)
102
117
 
103
118
  **路由跳转必须使用 react-router-dom:**
104
119
 
@@ -1,7 +1,7 @@
1
1
  import { BrowserRouter, Routes, Route } from "react-router-dom";
2
2
  import { Layout } from "@/components/layout";
3
- import HomePage from "@/pages/home";
4
- import NotFoundPage from "@/pages/not-found";
3
+ import HomePage from "@/pages/HomePage/HomePage";
4
+ import NotFoundPage from "@/pages/NotFoundPage/NotFoundPage";
5
5
 
6
6
  declare const __APP_BASE_PATH__: string;
7
7
 
@@ -2,10 +2,8 @@ import { Outlet } from "react-router-dom";
2
2
 
3
3
  export function Layout() {
4
4
  return (
5
- <div className="min-h-screen bg-background text-foreground">
6
- <main className="container mx-auto px-4 py-8">
7
- <Outlet />
8
- </main>
5
+ <div className="w-screen h-screen">
6
+ <Outlet />
9
7
  </div>
10
8
  );
11
9
  }
@@ -1,6 +1,6 @@
1
- import { clsx, type ClassValue } from "clsx";
2
- import { twMerge } from "tailwind-merge";
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
3
 
4
4
  export function cn(...inputs: ClassValue[]) {
5
- return twMerge(clsx(inputs));
5
+ return twMerge(clsx(inputs))
6
6
  }
@@ -5,7 +5,7 @@ export default function HomePage() {
5
5
  👋 Hello OpenClaw
6
6
  </h1>
7
7
  <p className="text-lg text-muted-foreground">
8
- Start building your app by editing <code className="px-1.5 py-0.5 rounded bg-muted font-mono text-sm">client/src/pages/home/index.tsx</code>
8
+ Start building your app by editing <code className="px-1.5 py-0.5 rounded bg-muted font-mono text-sm">client/src/pages/HomePage/HomePage.tsx</code>
9
9
  </p>
10
10
  </div>
11
11
  );
@@ -0,0 +1,11 @@
1
+ import { Link } from "react-router-dom";
2
+
3
+ export default function NotFoundPage() {
4
+ return (
5
+ <div className="flex flex-col items-center justify-center py-24">
6
+ <h1 className="text-6xl font-bold mb-4">404</h1>
7
+ <p className="text-lg text-muted-foreground mb-8">页面不存在</p>
8
+ <Link to="/" className="text-primary hover:underline">返回首页</Link>
9
+ </div>
10
+ );
11
+ }