new module federation system
This commit is contained in:
1
web/demo/.gitignore
vendored
Normal file
1
web/demo/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
||||
5764
web/demo/package-lock.json
generated
Normal file
5764
web/demo/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
web/demo/package.json
Normal file
32
web/demo/package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "demo",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "webpack serve --mode development",
|
||||
"build": "webpack --mode production",
|
||||
"dev": "webpack serve --mode development"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"@mantine/core": "^7.0.0",
|
||||
"@mantine/hooks": "^7.0.0",
|
||||
"@tabler/icons-react": "^2.40.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.20.12",
|
||||
"@babel/preset-react": "^7.18.6",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@types/react": "^18.0.28",
|
||||
"@types/react-dom": "^18.0.11",
|
||||
"babel-loader": "^9.1.2",
|
||||
"css-loader": "^6.7.3",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"style-loader": "^3.3.1",
|
||||
"typescript": "^4.9.5",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.1",
|
||||
"webpack-dev-server": "^4.7.4"
|
||||
}
|
||||
}
|
||||
11
web/demo/public/index.html
Normal file
11
web/demo/public/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Demo App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
151
web/demo/src/App.tsx
Normal file
151
web/demo/src/App.tsx
Normal file
@ -0,0 +1,151 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Container,
|
||||
Title,
|
||||
Text,
|
||||
Card,
|
||||
SimpleGrid,
|
||||
Group,
|
||||
Badge,
|
||||
Button,
|
||||
Stack,
|
||||
Progress,
|
||||
ActionIcon,
|
||||
Paper,
|
||||
Divider,
|
||||
Alert,
|
||||
} from '@mantine/core';
|
||||
import {
|
||||
IconRocket,
|
||||
IconChartLine,
|
||||
IconUsers,
|
||||
IconRefresh,
|
||||
IconCheck,
|
||||
IconInfoCircle,
|
||||
} from '@tabler/icons-react';
|
||||
|
||||
const DemoApp: React.FC = () => {
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setProgress((prev) => (prev >= 100 ? 0 : prev + 1));
|
||||
}, 100);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
const handleRefresh = () => {
|
||||
setIsLoading(true);
|
||||
setTimeout(() => setIsLoading(false), 1500);
|
||||
};
|
||||
|
||||
const stats = [
|
||||
{ label: 'Active Users', value: '1,234', icon: IconUsers, color: 'blue' },
|
||||
{ label: 'Total Revenue', value: '$45,678', icon: IconChartLine, color: 'green' },
|
||||
{ label: 'Projects', value: '89', icon: IconRocket, color: 'orange' },
|
||||
];
|
||||
|
||||
const features = [
|
||||
{ title: 'Real-time Analytics', description: 'Monitor your data in real-time' },
|
||||
{ title: 'Team Collaboration', description: 'Work together seamlessly' },
|
||||
{ title: 'Cloud Integration', description: 'Connect with cloud services' },
|
||||
{ title: 'Custom Reports', description: 'Generate detailed reports' },
|
||||
];
|
||||
|
||||
return (
|
||||
<Container size="xl" py="xl">
|
||||
<Stack gap="xl">
|
||||
<Group justify="space-between" align="center">
|
||||
<div>
|
||||
<Title order={1}>Demo Application</Title>
|
||||
<Text c="dimmed" size="lg" mt="xs">
|
||||
A sample federated application showcasing module federation
|
||||
</Text>
|
||||
</div>
|
||||
<ActionIcon
|
||||
size="lg"
|
||||
variant="light"
|
||||
loading={isLoading}
|
||||
onClick={handleRefresh}
|
||||
>
|
||||
<IconRefresh size={18} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
|
||||
<Alert icon={<IconInfoCircle size={16} />} title="Welcome!" color="blue" variant="light">
|
||||
This is a demo application loaded via Module Federation. It demonstrates how
|
||||
microfrontends can be seamlessly integrated into the shell application.
|
||||
</Alert>
|
||||
|
||||
<SimpleGrid cols={{ base: 1, sm: 3 }} spacing="md">
|
||||
{stats.map((stat) => (
|
||||
<Paper key={stat.label} p="md" radius="md" withBorder>
|
||||
<Group justify="space-between">
|
||||
<div>
|
||||
<Text c="dimmed" size="sm" fw={500} tt="uppercase">
|
||||
{stat.label}
|
||||
</Text>
|
||||
<Text fw={700} size="xl">
|
||||
{stat.value}
|
||||
</Text>
|
||||
</div>
|
||||
<stat.icon size={24} color={`var(--mantine-color-${stat.color}-6)`} />
|
||||
</Group>
|
||||
</Paper>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
|
||||
<Card shadow="sm" padding="lg" radius="md" withBorder>
|
||||
<Card.Section withBorder inheritPadding py="xs">
|
||||
<Group justify="space-between">
|
||||
<Text fw={500}>System Performance</Text>
|
||||
<Badge color="green" variant="light">
|
||||
Healthy
|
||||
</Badge>
|
||||
</Group>
|
||||
</Card.Section>
|
||||
|
||||
<Card.Section inheritPadding py="md">
|
||||
<Stack gap="xs">
|
||||
<Text size="sm" c="dimmed">
|
||||
CPU Usage: {progress.toFixed(1)}%
|
||||
</Text>
|
||||
<Progress value={progress} size="sm" color="blue" animated />
|
||||
</Stack>
|
||||
</Card.Section>
|
||||
</Card>
|
||||
|
||||
<div>
|
||||
<Title order={2} mb="md">Features</Title>
|
||||
<SimpleGrid cols={{ base: 1, sm: 2 }} spacing="md">
|
||||
{features.map((feature, index) => (
|
||||
<Card key={index} shadow="sm" padding="lg" radius="md" withBorder>
|
||||
<Group mb="xs">
|
||||
<IconCheck size={16} color="var(--mantine-color-green-6)" />
|
||||
<Text fw={500}>{feature.title}</Text>
|
||||
</Group>
|
||||
<Text size="sm" c="dimmed">
|
||||
{feature.description}
|
||||
</Text>
|
||||
</Card>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
<Group justify="center">
|
||||
<Button variant="outline" size="md">
|
||||
View Documentation
|
||||
</Button>
|
||||
<Button size="md">
|
||||
Get Started
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default DemoApp;
|
||||
14
web/demo/src/index.tsx
Normal file
14
web/demo/src/index.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { MantineProvider } from '@mantine/core';
|
||||
import App from './App';
|
||||
import '@mantine/core/styles.css';
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<MantineProvider>
|
||||
<App />
|
||||
</MantineProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
76
web/demo/webpack.config.js
Normal file
76
web/demo/webpack.config.js
Normal file
@ -0,0 +1,76 @@
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const { ModuleFederationPlugin } = require('webpack').container;
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
entry: './src/index.tsx',
|
||||
devServer: {
|
||||
port: 3001,
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.js', '.jsx'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(js|jsx|ts|tsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: [
|
||||
'@babel/preset-react',
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ['style-loader', 'css-loader'],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new ModuleFederationPlugin({
|
||||
name: 'demo',
|
||||
filename: 'remoteEntry.js',
|
||||
exposes: {
|
||||
'./App': './src/App.tsx',
|
||||
},
|
||||
shared: {
|
||||
react: {
|
||||
singleton: true,
|
||||
requiredVersion: '^18.2.0',
|
||||
eager: false,
|
||||
},
|
||||
'react-dom': {
|
||||
singleton: true,
|
||||
requiredVersion: '^18.2.0',
|
||||
eager: false,
|
||||
},
|
||||
'@mantine/core': {
|
||||
singleton: true,
|
||||
requiredVersion: '^7.0.0',
|
||||
eager: false,
|
||||
},
|
||||
'@mantine/hooks': {
|
||||
singleton: true,
|
||||
requiredVersion: '^7.0.0',
|
||||
eager: false,
|
||||
},
|
||||
'@tabler/icons-react': {
|
||||
singleton: true,
|
||||
requiredVersion: '^2.40.0',
|
||||
eager: false,
|
||||
},
|
||||
},
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: './public/index.html',
|
||||
}),
|
||||
],
|
||||
};
|
||||
1
web/shell/.gitignore
vendored
Normal file
1
web/shell/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
||||
5857
web/shell/package-lock.json
generated
Normal file
5857
web/shell/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
34
web/shell/package.json
Normal file
34
web/shell/package.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "shell",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "webpack serve --mode development",
|
||||
"build": "webpack --mode production",
|
||||
"dev": "webpack serve --mode development"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "^6.8.0",
|
||||
"@mantine/core": "^7.0.0",
|
||||
"@mantine/hooks": "^7.0.0",
|
||||
"@mantine/notifications": "^7.0.0",
|
||||
"@tabler/icons-react": "^2.40.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.20.12",
|
||||
"@babel/preset-react": "^7.18.6",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@types/react": "^18.0.28",
|
||||
"@types/react-dom": "^18.0.11",
|
||||
"babel-loader": "^9.1.2",
|
||||
"css-loader": "^6.7.3",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"style-loader": "^3.3.1",
|
||||
"typescript": "^4.9.5",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.1",
|
||||
"webpack-dev-server": "^4.7.4"
|
||||
}
|
||||
}
|
||||
11
web/shell/public/index.html
Normal file
11
web/shell/public/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Skybridge Shell</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
32
web/shell/src/App.tsx
Normal file
32
web/shell/src/App.tsx
Normal file
@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import { Routes, Route } from 'react-router-dom';
|
||||
import { AppShell } from '@mantine/core';
|
||||
import Header from './components/Header';
|
||||
import Navigation from './components/Navigation';
|
||||
import HomePage from './pages/HomePage';
|
||||
import AppLoader from './components/AppLoader';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<AppShell
|
||||
header={{ height: 60 }}
|
||||
navbar={{ width: 300, breakpoint: 'sm' }}
|
||||
padding="md"
|
||||
>
|
||||
<AppShell.Header>
|
||||
<Header />
|
||||
</AppShell.Header>
|
||||
<AppShell.Navbar>
|
||||
<Navigation />
|
||||
</AppShell.Navbar>
|
||||
<AppShell.Main>
|
||||
<Routes>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
<Route path="/app/:appName/*" element={<AppLoader />} />
|
||||
</Routes>
|
||||
</AppShell.Main>
|
||||
</AppShell>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
57
web/shell/src/components/AppLoader.tsx
Normal file
57
web/shell/src/components/AppLoader.tsx
Normal file
@ -0,0 +1,57 @@
|
||||
import React, { Suspense } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { Loader, Center, Text, Stack, Alert } from '@mantine/core';
|
||||
import { IconAlertCircle } from '@tabler/icons-react';
|
||||
import Breadcrumbs from './Breadcrumbs';
|
||||
|
||||
const DemoApp = React.lazy(() => import('demo/App'));
|
||||
|
||||
const AppLoader: React.FC = () => {
|
||||
const { appName } = useParams<{ appName: string }>();
|
||||
|
||||
const LoadingFallback = () => (
|
||||
<Center h={400}>
|
||||
<Stack align="center" gap="md">
|
||||
<Loader size="lg" />
|
||||
<Text>Loading {appName}...</Text>
|
||||
</Stack>
|
||||
</Center>
|
||||
);
|
||||
|
||||
const ErrorFallback = ({ error }: { error: string }) => (
|
||||
<Alert
|
||||
icon={<IconAlertCircle size={16} />}
|
||||
title="Failed to load application"
|
||||
color="red"
|
||||
variant="light"
|
||||
>
|
||||
{error}
|
||||
</Alert>
|
||||
);
|
||||
|
||||
const renderApp = () => {
|
||||
switch (appName) {
|
||||
case 'demo':
|
||||
return (
|
||||
<Suspense fallback={<LoadingFallback />}>
|
||||
<DemoApp />
|
||||
</Suspense>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<ErrorFallback
|
||||
error={`Application "${appName}" is not available or not configured.`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack gap="md">
|
||||
<Breadcrumbs />
|
||||
{renderApp()}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default AppLoader;
|
||||
61
web/shell/src/components/Breadcrumbs.tsx
Normal file
61
web/shell/src/components/Breadcrumbs.tsx
Normal file
@ -0,0 +1,61 @@
|
||||
import React from 'react';
|
||||
import { Breadcrumbs as MantineBreadcrumbs, Anchor } from '@mantine/core';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
|
||||
const Breadcrumbs: React.FC = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const pathSegments = location.pathname.split('/').filter(Boolean);
|
||||
|
||||
const breadcrumbItems = [
|
||||
{ label: 'Home', path: '/' },
|
||||
...pathSegments.map((segment, index) => {
|
||||
const path = '/' + pathSegments.slice(0, index + 1).join('/');
|
||||
let label = segment;
|
||||
|
||||
// Convert common path segments to readable labels
|
||||
if (segment === 'app') {
|
||||
label = 'Applications';
|
||||
} else if (segment === 'demo') {
|
||||
label = 'Demo App';
|
||||
} else if (segment === 'analytics') {
|
||||
label = 'Analytics';
|
||||
} else {
|
||||
// Capitalize first letter and replace hyphens/underscores with spaces
|
||||
label = segment.charAt(0).toUpperCase() + segment.slice(1).replace(/[-_]/g, ' ');
|
||||
}
|
||||
|
||||
return { label, path };
|
||||
}),
|
||||
];
|
||||
|
||||
// Remove duplicates and empty segments
|
||||
const uniqueBreadcrumbs = breadcrumbItems.filter((item, index, arr) =>
|
||||
item.path !== '/' || index === 0
|
||||
);
|
||||
|
||||
if (uniqueBreadcrumbs.length <= 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<MantineBreadcrumbs separator=">" separatorMargin="md" mt="xs">
|
||||
{uniqueBreadcrumbs.map((item, index) => (
|
||||
<Anchor
|
||||
key={item.path}
|
||||
onClick={() => navigate(item.path)}
|
||||
c={index === uniqueBreadcrumbs.length - 1 ? 'dimmed' : 'blue'}
|
||||
style={{
|
||||
cursor: index === uniqueBreadcrumbs.length - 1 ? 'default' : 'pointer',
|
||||
textDecoration: 'none',
|
||||
}}
|
||||
>
|
||||
{item.label}
|
||||
</Anchor>
|
||||
))}
|
||||
</MantineBreadcrumbs>
|
||||
);
|
||||
};
|
||||
|
||||
export default Breadcrumbs;
|
||||
169
web/shell/src/components/Header.tsx
Normal file
169
web/shell/src/components/Header.tsx
Normal file
@ -0,0 +1,169 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Group,
|
||||
ActionIcon,
|
||||
Select,
|
||||
TextInput,
|
||||
Text,
|
||||
Avatar,
|
||||
Flex,
|
||||
Box,
|
||||
Menu,
|
||||
} from '@mantine/core';
|
||||
import {
|
||||
IconSearch,
|
||||
IconBell,
|
||||
IconSettings,
|
||||
IconMail,
|
||||
IconUser,
|
||||
IconLogout,
|
||||
} from '@tabler/icons-react';
|
||||
|
||||
const Header: React.FC = () => {
|
||||
const [currentTime, setCurrentTime] = React.useState(new Date());
|
||||
|
||||
React.useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setCurrentTime(new Date());
|
||||
}, 1000);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
const timezones = [
|
||||
{
|
||||
label: 'PST',
|
||||
value: 'pst',
|
||||
timezone: 'America/Los_Angeles'
|
||||
},
|
||||
{
|
||||
label: 'EST',
|
||||
value: 'est',
|
||||
timezone: 'America/New_York'
|
||||
},
|
||||
{
|
||||
label: 'CST',
|
||||
value: 'cst',
|
||||
timezone: 'America/Chicago'
|
||||
},
|
||||
{
|
||||
label: 'IST',
|
||||
value: 'ist',
|
||||
timezone: 'Asia/Kolkata'
|
||||
},
|
||||
];
|
||||
|
||||
const formatTime = (timezone: string) => {
|
||||
return currentTime.toLocaleTimeString('en-US', {
|
||||
timeZone: timezone,
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: true
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Box h={60} px="md">
|
||||
<Flex align="center" h="100%" gap="md">
|
||||
{/* Logo */}
|
||||
<Text size="xl" fw={700} c="blue">
|
||||
Skybridge
|
||||
</Text>
|
||||
|
||||
{/* Icon Buttons */}
|
||||
<Group gap="xs">
|
||||
<ActionIcon variant="subtle" size="lg">
|
||||
<IconBell size={18} />
|
||||
</ActionIcon>
|
||||
<ActionIcon variant="subtle" size="lg">
|
||||
<IconMail size={18} />
|
||||
</ActionIcon>
|
||||
<ActionIcon variant="subtle" size="lg">
|
||||
<IconSettings size={18} />
|
||||
</ActionIcon>
|
||||
<ActionIcon variant="subtle" size="lg">
|
||||
<IconUser size={18} />
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
|
||||
{/* Application Dropdown */}
|
||||
<Select
|
||||
placeholder="Select Application"
|
||||
data={[
|
||||
{ value: 'demo', label: 'Demo App' },
|
||||
{ value: 'dashboard', label: 'Dashboard' },
|
||||
{ value: 'analytics', label: 'Analytics' },
|
||||
]}
|
||||
w={200}
|
||||
/>
|
||||
|
||||
{/* Search Box */}
|
||||
<TextInput
|
||||
placeholder="Search..."
|
||||
leftSection={<IconSearch size={16} />}
|
||||
w={250}
|
||||
/>
|
||||
|
||||
{/* Spacer to push right content to the right */}
|
||||
<Box style={{ flexGrow: 1 }} />
|
||||
|
||||
{/* Timezone Section */}
|
||||
<Group gap="lg">
|
||||
{timezones.map((tz) => (
|
||||
<Box key={tz.value} ta="center">
|
||||
<Text size="xs" c="dimmed" fw={500}>
|
||||
{tz.label}
|
||||
</Text>
|
||||
<Text size="sm" fw={600}>
|
||||
{formatTime(tz.timezone)}
|
||||
</Text>
|
||||
</Box>
|
||||
))}
|
||||
</Group>
|
||||
|
||||
{/* User Profile with Dropdown */}
|
||||
<Menu shadow="md" width={200}>
|
||||
<Menu.Target>
|
||||
<Avatar
|
||||
color="blue"
|
||||
radius="xl"
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
transition: 'all 0.2s ease',
|
||||
':hover': {
|
||||
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
||||
transform: 'translateY(-1px)',
|
||||
}
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.boxShadow = '0 4px 12px rgba(34, 139, 230, 0.4)';
|
||||
e.currentTarget.style.transform = 'translateY(-1px)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.boxShadow = 'none';
|
||||
e.currentTarget.style.transform = 'translateY(0)';
|
||||
}}
|
||||
>
|
||||
JD
|
||||
</Avatar>
|
||||
</Menu.Target>
|
||||
|
||||
<Menu.Dropdown>
|
||||
<Menu.Label>Account</Menu.Label>
|
||||
<Menu.Item leftSection={<IconSettings size={14} />}>
|
||||
Settings
|
||||
</Menu.Item>
|
||||
<Menu.Divider />
|
||||
<Menu.Item
|
||||
leftSection={<IconLogout size={14} />}
|
||||
color="red"
|
||||
>
|
||||
Logout
|
||||
</Menu.Item>
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
</Flex>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default Header;
|
||||
80
web/shell/src/components/Navigation.tsx
Normal file
80
web/shell/src/components/Navigation.tsx
Normal file
@ -0,0 +1,80 @@
|
||||
import React from 'react';
|
||||
import { NavLink, Stack, Text, Group } from '@mantine/core';
|
||||
import { useNavigate, useLocation } from 'react-router-dom';
|
||||
import {
|
||||
IconHome,
|
||||
IconApps,
|
||||
IconDashboard,
|
||||
IconChartLine,
|
||||
IconStar,
|
||||
} from '@tabler/icons-react';
|
||||
|
||||
const Navigation: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const navigationItems = [
|
||||
{
|
||||
label: 'Home',
|
||||
icon: IconHome,
|
||||
path: '/',
|
||||
},
|
||||
{
|
||||
label: 'Favorites',
|
||||
icon: IconStar,
|
||||
path: '/favorites',
|
||||
},
|
||||
{
|
||||
label: 'All Applications',
|
||||
icon: IconApps,
|
||||
path: '/apps',
|
||||
},
|
||||
];
|
||||
|
||||
const applications = [
|
||||
{
|
||||
label: 'Demo App',
|
||||
icon: IconDashboard,
|
||||
path: '/app/demo',
|
||||
},
|
||||
{
|
||||
label: 'Analytics',
|
||||
icon: IconChartLine,
|
||||
path: '/app/analytics',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<Stack gap="xs" p="md">
|
||||
<Text size="sm" fw={600} c="dimmed" tt="uppercase" mb="xs">
|
||||
Navigation
|
||||
</Text>
|
||||
|
||||
{navigationItems.map((item) => (
|
||||
<NavLink
|
||||
key={item.path}
|
||||
label={item.label}
|
||||
leftSection={<item.icon size={16} />}
|
||||
active={location.pathname === item.path}
|
||||
onClick={() => navigate(item.path)}
|
||||
/>
|
||||
))}
|
||||
|
||||
<Text size="sm" fw={600} c="dimmed" tt="uppercase" mt="lg" mb="xs">
|
||||
Applications
|
||||
</Text>
|
||||
|
||||
{applications.map((app) => (
|
||||
<NavLink
|
||||
key={app.path}
|
||||
label={app.label}
|
||||
leftSection={<app.icon size={16} />}
|
||||
active={location.pathname.startsWith(app.path)}
|
||||
onClick={() => navigate(app.path)}
|
||||
/>
|
||||
))}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default Navigation;
|
||||
20
web/shell/src/index.tsx
Normal file
20
web/shell/src/index.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { MantineProvider } from '@mantine/core';
|
||||
import { Notifications } from '@mantine/notifications';
|
||||
import App from './App';
|
||||
import '@mantine/core/styles.css';
|
||||
import '@mantine/notifications/styles.css';
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<MantineProvider>
|
||||
<Notifications />
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</MantineProvider>
|
||||
</React.StrictMode>
|
||||
);
|
||||
176
web/shell/src/pages/HomePage.tsx
Normal file
176
web/shell/src/pages/HomePage.tsx
Normal file
@ -0,0 +1,176 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
SimpleGrid,
|
||||
Card,
|
||||
Text,
|
||||
ActionIcon,
|
||||
Group,
|
||||
Stack,
|
||||
Title,
|
||||
Badge,
|
||||
} from '@mantine/core';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
IconStar,
|
||||
IconStarFilled,
|
||||
IconDashboard,
|
||||
IconChartLine,
|
||||
IconSettings,
|
||||
IconUsers,
|
||||
IconFiles,
|
||||
IconMail,
|
||||
} from '@tabler/icons-react';
|
||||
import Breadcrumbs from '../components/Breadcrumbs';
|
||||
|
||||
interface App {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: React.ComponentType<any>;
|
||||
path: string;
|
||||
category: string;
|
||||
}
|
||||
|
||||
const HomePage: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const [favoriteApps, setFavoriteApps] = useState<string[]>(['demo', 'analytics']);
|
||||
|
||||
const availableApps: App[] = [
|
||||
{
|
||||
id: 'demo',
|
||||
name: 'Demo App',
|
||||
description: 'Sample application for testing',
|
||||
icon: IconDashboard,
|
||||
path: '/app/demo',
|
||||
category: 'Development',
|
||||
},
|
||||
{
|
||||
id: 'analytics',
|
||||
name: 'Analytics',
|
||||
description: 'Data analytics and reporting',
|
||||
icon: IconChartLine,
|
||||
path: '/app/analytics',
|
||||
category: 'Analytics',
|
||||
},
|
||||
{
|
||||
id: 'settings',
|
||||
name: 'Settings',
|
||||
description: 'System configuration',
|
||||
icon: IconSettings,
|
||||
path: '/app/settings',
|
||||
category: 'System',
|
||||
},
|
||||
{
|
||||
id: 'users',
|
||||
name: 'User Management',
|
||||
description: 'Manage users and permissions',
|
||||
icon: IconUsers,
|
||||
path: '/app/users',
|
||||
category: 'Administration',
|
||||
},
|
||||
{
|
||||
id: 'files',
|
||||
name: 'File Manager',
|
||||
description: 'Browse and manage files',
|
||||
icon: IconFiles,
|
||||
path: '/app/files',
|
||||
category: 'Utilities',
|
||||
},
|
||||
{
|
||||
id: 'mail',
|
||||
name: 'Mail Client',
|
||||
description: 'Email management',
|
||||
icon: IconMail,
|
||||
path: '/app/mail',
|
||||
category: 'Communication',
|
||||
},
|
||||
];
|
||||
|
||||
const toggleFavorite = (appId: string) => {
|
||||
setFavoriteApps(prev =>
|
||||
prev.includes(appId)
|
||||
? prev.filter(id => id !== appId)
|
||||
: [...prev, appId]
|
||||
);
|
||||
};
|
||||
|
||||
const favoriteAppsList = availableApps.filter(app => favoriteApps.includes(app.id));
|
||||
const otherApps = availableApps.filter(app => !favoriteApps.includes(app.id));
|
||||
|
||||
const AppTile: React.FC<{ app: App }> = ({ app }) => {
|
||||
const IconComponent = app.icon;
|
||||
|
||||
return (
|
||||
<Card
|
||||
shadow="sm"
|
||||
padding="lg"
|
||||
radius="md"
|
||||
withBorder
|
||||
style={{ cursor: 'pointer', height: '100%' }}
|
||||
onClick={() => navigate(app.path)}
|
||||
>
|
||||
<Group justify="space-between" align="flex-start" mb="xs">
|
||||
<IconComponent size={32} color="var(--mantine-color-blue-6)" />
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
toggleFavorite(app.id);
|
||||
}}
|
||||
>
|
||||
{favoriteApps.includes(app.id) ? (
|
||||
<IconStarFilled size={16} color="gold" />
|
||||
) : (
|
||||
<IconStar size={16} />
|
||||
)}
|
||||
</ActionIcon>
|
||||
</Group>
|
||||
|
||||
<Stack gap="xs">
|
||||
<Text fw={500} size="lg">
|
||||
{app.name}
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
{app.description}
|
||||
</Text>
|
||||
<Badge variant="light" size="sm">
|
||||
{app.category}
|
||||
</Badge>
|
||||
</Stack>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack gap="xl">
|
||||
<Breadcrumbs />
|
||||
|
||||
{favoriteAppsList.length > 0 && (
|
||||
<div>
|
||||
<Group mb="md">
|
||||
<IconStarFilled size={20} color="gold" />
|
||||
<Title order={2}>Favorite Applications</Title>
|
||||
</Group>
|
||||
<SimpleGrid cols={{ base: 1, sm: 2, md: 3, lg: 4 }} spacing="md">
|
||||
{favoriteAppsList.map(app => (
|
||||
<AppTile key={app.id} app={app} />
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<Title order={2} mb="md">
|
||||
All Applications
|
||||
</Title>
|
||||
<SimpleGrid cols={{ base: 1, sm: 2, md: 3, lg: 4 }} spacing="md">
|
||||
{otherApps.map(app => (
|
||||
<AppTile key={app.id} app={app} />
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</div>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default HomePage;
|
||||
87
web/shell/webpack.config.js
Normal file
87
web/shell/webpack.config.js
Normal file
@ -0,0 +1,87 @@
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const { ModuleFederationPlugin } = require('webpack').container;
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
entry: './src/index.tsx',
|
||||
devServer: {
|
||||
port: 3000,
|
||||
historyApiFallback: true,
|
||||
static: {
|
||||
directory: './public',
|
||||
},
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
},
|
||||
},
|
||||
output: {
|
||||
publicPath: '/',
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.tsx', '.ts', '.js', '.jsx'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(js|jsx|ts|tsx)$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: [
|
||||
'@babel/preset-react',
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ['style-loader', 'css-loader'],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new ModuleFederationPlugin({
|
||||
name: 'shell',
|
||||
remotes: {
|
||||
demo: 'demo@http://localhost:3001/remoteEntry.js',
|
||||
},
|
||||
shared: {
|
||||
react: {
|
||||
singleton: true,
|
||||
requiredVersion: '^18.2.0',
|
||||
eager: true,
|
||||
},
|
||||
'react-dom': {
|
||||
singleton: true,
|
||||
requiredVersion: '^18.2.0',
|
||||
eager: true,
|
||||
},
|
||||
'@mantine/core': {
|
||||
singleton: true,
|
||||
requiredVersion: '^7.0.0',
|
||||
eager: true,
|
||||
},
|
||||
'@mantine/hooks': {
|
||||
singleton: true,
|
||||
requiredVersion: '^7.0.0',
|
||||
eager: true,
|
||||
},
|
||||
'@mantine/notifications': {
|
||||
singleton: true,
|
||||
requiredVersion: '^7.0.0',
|
||||
eager: true,
|
||||
},
|
||||
'@tabler/icons-react': {
|
||||
singleton: true,
|
||||
requiredVersion: '^2.40.0',
|
||||
eager: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: './public/index.html',
|
||||
}),
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user