feat: add support for dual frontend (JS and React) in the CCW application

- Updated CLI to include `--frontend` option for selecting frontend type (js, react, both).
- Modified serve command to start React frontend when specified.
- Implemented React frontend startup and shutdown logic.
- Enhanced server routing to handle requests for both JS and React frontends.
- Added workspace selector component with i18n support.
- Updated tests to reflect changes in header and A2UI components.
- Introduced new Radix UI components for improved UI consistency.
- Refactored A2UIButton and A2UIDateTimeInput components for better code clarity.
- Created migration plan for gradual transition from JS to React frontend.
This commit is contained in:
catlog22
2026-01-31 16:46:45 +08:00
parent 345437415f
commit 35f9116cce
13 changed files with 798 additions and 96 deletions

View File

@@ -57,12 +57,7 @@ import { getCliToolsStatus } from '../tools/cli-executor.js';
import type { ServerConfig } from '../types/config.js';
import type { PostRequestHandler } from './routes/types.js';
interface ServerOptions {
port?: number;
initialPath?: string;
host?: string;
open?: boolean;
}
type PostHandler = PostRequestHandler;
@@ -664,22 +659,7 @@ export async function startServer(options: ServerOptions = {}): Promise<http.Ser
if (await handleSystemRoutes(routeContext)) return;
}
// Serve dashboard HTML
if (pathname === '/' || pathname === '/index.html') {
// Set session cookie and CSRF token for all requests
const tokenResult = tokenManager.getOrCreateAuthToken();
setAuthCookie(res, tokenResult.token, tokenResult.expiresAt);
const sessionId = getOrCreateSessionId(req, res);
const csrfToken = getCsrfTokenManager().generateToken(sessionId);
res.setHeader('X-CSRF-Token', csrfToken);
setCsrfCookie(res, csrfToken, 15 * 60);
const html = generateServerDashboard(initialPath);
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
res.end(html);
return;
}
// Handle favicon.ico (return empty response to prevent 404)
if (pathname === '/favicon.ico') {