mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-25 06:04:54 +00:00
Compare commits
1 Commits
copilot/re
...
codex/upda
| Author | SHA1 | Date | |
|---|---|---|---|
| 1dfd891e24 |
@@ -245,6 +245,17 @@
|
|||||||
"type": "single"
|
"type": "single"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "json-ui-schema",
|
||||||
|
"title": "JSON UI Schema",
|
||||||
|
"description": "Schema-driven JSON UI page",
|
||||||
|
"icon": "Code",
|
||||||
|
"type": "json",
|
||||||
|
"schemaPath": "json-ui-showcase-page.json",
|
||||||
|
"layout": {
|
||||||
|
"type": "single"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "sass",
|
"id": "sass",
|
||||||
"title": "Sass Styles",
|
"title": "Sass Styles",
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ export interface PageConfig {
|
|||||||
id: string
|
id: string
|
||||||
title: string
|
title: string
|
||||||
icon: string
|
icon: string
|
||||||
component: string
|
type?: 'component' | 'json'
|
||||||
|
component?: string
|
||||||
|
schemaPath?: string
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
isRoot?: boolean
|
isRoot?: boolean
|
||||||
toggleKey?: string
|
toggleKey?: string
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ export const SimplePageConfigSchema = z.object({
|
|||||||
id: z.string(),
|
id: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
icon: z.string(),
|
icon: z.string(),
|
||||||
component: z.string(),
|
type: z.enum(['component', 'json']).optional(),
|
||||||
|
component: z.string().optional(),
|
||||||
|
schemaPath: z.string().optional(),
|
||||||
enabled: z.boolean(),
|
enabled: z.boolean(),
|
||||||
toggleKey: z.string().optional(),
|
toggleKey: z.string().optional(),
|
||||||
shortcut: z.string().optional(),
|
shortcut: z.string().optional(),
|
||||||
@@ -70,7 +72,9 @@ export const PageConfigSchema = z.object({
|
|||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
icon: z.string(),
|
icon: z.string(),
|
||||||
component: z.string(),
|
type: z.enum(['component', 'json']).optional(),
|
||||||
|
component: z.string().optional(),
|
||||||
|
schemaPath: z.string().optional(),
|
||||||
layout: LayoutConfigSchema,
|
layout: LayoutConfigSchema,
|
||||||
features: z.array(FeatureConfigSchema).optional(),
|
features: z.array(FeatureConfigSchema).optional(),
|
||||||
permissions: z.array(z.string()).optional(),
|
permissions: z.array(z.string()).optional(),
|
||||||
|
|||||||
@@ -365,6 +365,16 @@
|
|||||||
"order": 22,
|
"order": 22,
|
||||||
"props": {}
|
"props": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "json-ui-schema",
|
||||||
|
"title": "JSON UI Schema",
|
||||||
|
"icon": "Code",
|
||||||
|
"type": "json",
|
||||||
|
"schemaPath": "json-ui-showcase-page.json",
|
||||||
|
"enabled": true,
|
||||||
|
"order": 22.05,
|
||||||
|
"props": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "json-conversion-showcase",
|
"id": "json-conversion-showcase",
|
||||||
"title": "JSON Conversion Showcase",
|
"title": "JSON Conversion Showcase",
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ export function validatePageConfig(): ValidationError[] {
|
|||||||
]
|
]
|
||||||
|
|
||||||
pagesConfig.pages.forEach((page: PageConfig) => {
|
pagesConfig.pages.forEach((page: PageConfig) => {
|
||||||
|
const pageType = page.type ?? 'component'
|
||||||
|
|
||||||
if (!page.id) {
|
if (!page.id) {
|
||||||
errors.push({
|
errors.push({
|
||||||
page: page.title || 'Unknown',
|
page: page.title || 'Unknown',
|
||||||
@@ -57,7 +59,16 @@ export function validatePageConfig(): ValidationError[] {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!page.component) {
|
if (page.type && !['component', 'json'].includes(page.type)) {
|
||||||
|
errors.push({
|
||||||
|
page: page.id || 'Unknown',
|
||||||
|
field: 'type',
|
||||||
|
message: `Unknown page type: ${page.type}. Expected "component" or "json".`,
|
||||||
|
severity: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageType === 'component' && !page.component) {
|
||||||
errors.push({
|
errors.push({
|
||||||
page: page.id || 'Unknown',
|
page: page.id || 'Unknown',
|
||||||
field: 'component',
|
field: 'component',
|
||||||
@@ -66,6 +77,15 @@ export function validatePageConfig(): ValidationError[] {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pageType === 'json' && !page.schemaPath) {
|
||||||
|
errors.push({
|
||||||
|
page: page.id || 'Unknown',
|
||||||
|
field: 'schemaPath',
|
||||||
|
message: 'schemaPath is required for JSON pages',
|
||||||
|
severity: 'error',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (!page.icon) {
|
if (!page.icon) {
|
||||||
errors.push({
|
errors.push({
|
||||||
page: page.id || 'Unknown',
|
page: page.id || 'Unknown',
|
||||||
|
|||||||
@@ -79,6 +79,12 @@ export class RoutePreloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (page.type === 'json') {
|
||||||
|
console.log(`[PRELOAD_MGR] 🧩 Skipping component preload for JSON page: ${pageId}`)
|
||||||
|
this.preloadedRoutes.add(pageId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const componentName = page.component as ComponentName
|
const componentName = page.component as ComponentName
|
||||||
console.log(`[PRELOAD_MGR] 🚀 Preloading ${pageId} → ${componentName}`)
|
console.log(`[PRELOAD_MGR] 🚀 Preloading ${pageId} → ${componentName}`)
|
||||||
preloadComponentByName(componentName)
|
preloadComponentByName(componentName)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { lazy, Suspense } from 'react'
|
|||||||
import { RouteObject, Navigate } from 'react-router-dom'
|
import { RouteObject, Navigate } from 'react-router-dom'
|
||||||
import { LoadingFallback } from '@/components/molecules'
|
import { LoadingFallback } from '@/components/molecules'
|
||||||
import { NotFoundPage } from '@/components/NotFoundPage'
|
import { NotFoundPage } from '@/components/NotFoundPage'
|
||||||
|
import { JSONSchemaPageLoader } from '@/components/JSONSchemaPageLoader'
|
||||||
import { getEnabledPages, resolveProps } from '@/config/page-loader'
|
import { getEnabledPages, resolveProps } from '@/config/page-loader'
|
||||||
import { ComponentRegistry } from '@/lib/component-registry'
|
import { ComponentRegistry } from '@/lib/component-registry'
|
||||||
import { FeatureToggles } from '@/types/project'
|
import { FeatureToggles } from '@/types/project'
|
||||||
@@ -80,12 +81,14 @@ export function createRoutes(
|
|||||||
console.log('[ROUTES] 📄 Enabled pages details:', JSON.stringify(enabledPages.map(p => ({
|
console.log('[ROUTES] 📄 Enabled pages details:', JSON.stringify(enabledPages.map(p => ({
|
||||||
id: p.id,
|
id: p.id,
|
||||||
component: p.component,
|
component: p.component,
|
||||||
|
type: p.type,
|
||||||
|
schemaPath: p.schemaPath,
|
||||||
isRoot: p.isRoot,
|
isRoot: p.isRoot,
|
||||||
enabled: p.enabled
|
enabled: p.enabled
|
||||||
})), null, 2))
|
})), null, 2))
|
||||||
|
|
||||||
const rootPage = enabledPages.find(p => p.isRoot)
|
const rootPage = enabledPages.find(p => p.isRoot)
|
||||||
console.log('[ROUTES] 🏠 Root page search result:', rootPage ? `Found: ${rootPage.id} (${rootPage.component})` : 'NOT FOUND - will redirect to /dashboard')
|
console.log('[ROUTES] 🏠 Root page search result:', rootPage ? `Found: ${rootPage.id} (${rootPage.type ?? 'component'})` : 'NOT FOUND - will redirect to /dashboard')
|
||||||
|
|
||||||
const routes: RouteObject[] = enabledPages
|
const routes: RouteObject[] = enabledPages
|
||||||
.filter(p => !p.isRoot)
|
.filter(p => !p.isRoot)
|
||||||
@@ -96,7 +99,14 @@ export function createRoutes(
|
|||||||
? resolveProps(page.props, stateContext, actionContext)
|
? resolveProps(page.props, stateContext, actionContext)
|
||||||
: {}
|
: {}
|
||||||
|
|
||||||
if (page.requiresResizable && page.resizableConfig) {
|
if (page.type === 'json' && page.schemaPath) {
|
||||||
|
return {
|
||||||
|
path: `/${page.id}`,
|
||||||
|
element: <JSONSchemaPageLoader schemaPath={page.schemaPath} />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page.requiresResizable && page.resizableConfig && page.component) {
|
||||||
console.log('[ROUTES] 🔀 Page requires resizable layout:', page.id)
|
console.log('[ROUTES] 🔀 Page requires resizable layout:', page.id)
|
||||||
const config = page.resizableConfig
|
const config = page.resizableConfig
|
||||||
const leftProps = resolveProps(config.leftProps, stateContext, actionContext)
|
const leftProps = resolveProps(config.leftProps, stateContext, actionContext)
|
||||||
@@ -117,20 +127,31 @@ export function createRoutes(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
path: `/${page.id}`,
|
path: `/${page.id}`,
|
||||||
element: <LazyComponent componentName={page.component} props={props} />
|
element: page.component
|
||||||
|
? <LazyComponent componentName={page.component} props={props} />
|
||||||
|
: <LoadingFallback message={`Component not configured for ${page.id}`} />
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (rootPage) {
|
if (rootPage) {
|
||||||
console.log('[ROUTES] ✅ Adding root route from JSON config:', rootPage.component)
|
console.log('[ROUTES] ✅ Adding root route from JSON config:', rootPage.type ?? 'component')
|
||||||
const props = rootPage.props
|
if (rootPage.type === 'json' && rootPage.schemaPath) {
|
||||||
? resolveProps(rootPage.props, stateContext, actionContext)
|
routes.push({
|
||||||
: {}
|
path: '/',
|
||||||
|
element: <JSONSchemaPageLoader schemaPath={rootPage.schemaPath} />
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const props = rootPage.props
|
||||||
|
? resolveProps(rootPage.props, stateContext, actionContext)
|
||||||
|
: {}
|
||||||
|
|
||||||
routes.push({
|
routes.push({
|
||||||
path: '/',
|
path: '/',
|
||||||
element: <LazyComponent componentName={rootPage.component} props={props} />
|
element: rootPage.component
|
||||||
})
|
? <LazyComponent componentName={rootPage.component} props={props} />
|
||||||
|
: <LoadingFallback message="Root component not configured" />
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('[ROUTES] ⚠️ No root page in config, redirecting to /dashboard')
|
console.log('[ROUTES] ⚠️ No root page in config, redirecting to /dashboard')
|
||||||
routes.push({
|
routes.push({
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ export interface PageConfig {
|
|||||||
id: string
|
id: string
|
||||||
title: string
|
title: string
|
||||||
icon: string
|
icon: string
|
||||||
|
type?: 'component' | 'json'
|
||||||
component?: string
|
component?: string
|
||||||
|
schemaPath?: string
|
||||||
schema?: string
|
schema?: string
|
||||||
enabled: boolean
|
enabled: boolean
|
||||||
isRoot?: boolean
|
isRoot?: boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user