Skip to content

Commit d253e9f

Browse files
committed
添加 react-router-dom 依赖,更新 Tailwind CSS 配置以支持 monorepo 结构,新增 PageSchema 接口
1 parent a0addbb commit d253e9f

File tree

4 files changed

+84
-5
lines changed

4 files changed

+84
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"prettier": "^3.8.0",
6464
"react": "18.3.1",
6565
"react-dom": "18.3.1",
66+
"react-router-dom": "^7.12.0",
6667
"tailwindcss": "^3.0.0",
6768
"tslib": "^2.6.0",
6869
"turbo": "^2.6.3",

packages/cli/src/utils/app-generator.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,13 @@ export default {
287287
const isMonorepo = existsSync(join(cwd, 'pnpm-workspace.yaml'));
288288

289289
// Define Tailwind Content Paths
290-
const contentPaths = ["'./index.html'", "'./src/**/*.{js,ts,jsx,tsx}'"];
290+
// Include JSON files specifically
291+
const contentPaths = ["'./index.html'", "'./src/**/*.{js,ts,jsx,tsx,json}'"];
291292
if (isMonorepo) {
292-
contentPaths.push("'../../packages/components/src/**/*.{ts,tsx}'");
293-
contentPaths.push("'../../packages/plugin-*/src/**/*.{ts,tsx}'");
293+
const componentsPath = join(cwd, 'packages/components/src/**/*.{ts,tsx}');
294+
const pluginsPath = join(cwd, 'packages/plugin-*/src/**/*.{ts,tsx}');
295+
contentPaths.push(`'${componentsPath}'`);
296+
contentPaths.push(`'${pluginsPath}'`);
294297
}
295298

296299
// Create tailwind.config.js
@@ -491,7 +494,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
491494

492495
const layoutCode = `
493496
import { Link, useLocation } from 'react-router-dom';
494-
import { cn } from '@object-ui/components/lib/utils'; // Try to use from components lib if available or generated utils
497+
import { cn } from '@object-ui/components';
495498
496499
const AppLayout = ({ app, children }) => {
497500
const location = useLocation();
@@ -547,6 +550,8 @@ const AppLayout = ({ app, children }) => {
547550
</div>
548551
);
549552
};
553+
554+
export default AppLayout;
550555
`;
551556
writeFileSync(join(srcDir, 'Layout.tsx'), layoutCode);
552557

@@ -651,11 +656,24 @@ export default App;`;
651656

652657
writeFileSync(join(srcDir, 'index.css'), indexCss);
653658

659+
const cwd = process.cwd();
660+
const isMonorepo = existsSync(join(cwd, 'pnpm-workspace.yaml'));
661+
662+
// Define Tailwind Content Paths
663+
// Include JSON files specifically
664+
const contentPaths = ["'./index.html'", "'./src/**/*.{js,ts,jsx,tsx,json}'"];
665+
if (isMonorepo) {
666+
const componentsPath = join(cwd, 'packages/components/src/**/*.{ts,tsx}');
667+
const pluginsPath = join(cwd, 'packages/plugin-*/src/**/*.{ts,tsx}');
668+
contentPaths.push(`'${componentsPath}'`);
669+
contentPaths.push(`'${pluginsPath}'`);
670+
}
671+
654672
// Create tailwind.config.js
655673
const tailwindConfig = `/** @type {import('tailwindcss').Config} */
656674
export default {
657675
darkMode: ['class'],
658-
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
676+
content: [${contentPaths.join(', ')}],
659677
theme: {
660678
extend: {
661679
borderRadius: {

packages/types/src/layout.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,18 @@ export type LayoutSchema =
430430
| ScrollAreaSchema
431431
| ResizableSchema
432432
| PageSchema;
433+
434+
/**
435+
* Page container component
436+
*/
437+
export interface PageSchema extends BaseSchema {
438+
type: 'page';
439+
/**
440+
* Page title
441+
*/
442+
title?: string;
443+
/**
444+
* Child components
445+
*/
446+
children?: SchemaNode | SchemaNode[];
447+
}

pnpm-lock.yaml

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)