mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -35,6 +35,7 @@ const TEMPLATE_PATH = join(import.meta.dirname, '../templates/dashboard.html');
|
||||
const MODULE_CSS_DIR = join(import.meta.dirname, '../templates/dashboard-css');
|
||||
const JS_FILE = join(import.meta.dirname, '../templates/dashboard.js');
|
||||
const MODULE_JS_DIR = join(import.meta.dirname, '../templates/dashboard-js');
|
||||
const ASSETS_DIR = join(import.meta.dirname, '../templates/assets');
|
||||
|
||||
// Modular CSS files in load order
|
||||
const MODULE_CSS_FILES = [
|
||||
@@ -582,6 +583,34 @@ export async function startServer(options = {}) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Serve static assets (js, css)
|
||||
if (pathname.startsWith('/assets/')) {
|
||||
const assetPath = join(ASSETS_DIR, pathname.replace('/assets/', ''));
|
||||
if (existsSync(assetPath)) {
|
||||
const ext = assetPath.split('.').pop().toLowerCase();
|
||||
const mimeTypes = {
|
||||
'js': 'application/javascript',
|
||||
'css': 'text/css',
|
||||
'json': 'application/json',
|
||||
'png': 'image/png',
|
||||
'jpg': 'image/jpeg',
|
||||
'jpeg': 'image/jpeg',
|
||||
'svg': 'image/svg+xml',
|
||||
'woff': 'font/woff',
|
||||
'woff2': 'font/woff2',
|
||||
'ttf': 'font/ttf'
|
||||
};
|
||||
const contentType = mimeTypes[ext] || 'application/octet-stream';
|
||||
const content = readFileSync(assetPath);
|
||||
res.writeHead(200, {
|
||||
'Content-Type': contentType,
|
||||
'Cache-Control': 'public, max-age=31536000'
|
||||
});
|
||||
res.end(content);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 404
|
||||
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
||||
res.end('Not Found');
|
||||
|
||||
Reference in New Issue
Block a user