mirror of
https://github.com/unraid/api.git
synced 2026-01-04 07:29:48 -06:00
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Introduced Docker management UI components: Overview, Logs, Console, Preview, and Edit. - Added responsive Card/Detail layouts with grouping, bulk actions, and tabs. - New UnraidToaster component and global toaster configuration. - Component auto-mounting improved with async loading and multi-selector support. - UI/UX - Overhauled theme system (light/dark tokens, primary/orange accents) and added theme variants. - Header OS version now includes integrated changelog modal. - Registration displays warning states; multiple visual polish updates. - API - CPU load now includes percentGuest and percentSteal metrics. - Chores - Migrated web app to Vite; updated artifacts and manifests. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: mdatelle <mike@datelle.net> Co-authored-by: Michael Datelle <mdatelle@icloud.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
import type { Plugin } from 'vite';
|
|
|
|
export function serveStaticHtml(): Plugin {
|
|
return {
|
|
name: 'serve-static-html',
|
|
configureServer(server) {
|
|
// Serve test pages from public/test-pages
|
|
server.middlewares.use((req, res, next) => {
|
|
// Check if request is for test-pages
|
|
if (req.url?.startsWith('/test-pages')) {
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const filePath = path.join(__dirname, 'public', req.url);
|
|
|
|
// If it's a directory, serve index.html
|
|
let targetPath = filePath;
|
|
if (fs.existsSync(filePath) && fs.statSync(filePath).isDirectory()) {
|
|
targetPath = path.join(filePath, 'index.html');
|
|
}
|
|
|
|
// If no extension, try adding .html
|
|
if (!path.extname(targetPath) && !fs.existsSync(targetPath)) {
|
|
targetPath = targetPath + '.html';
|
|
}
|
|
|
|
// Serve the file if it exists
|
|
if (fs.existsSync(targetPath)) {
|
|
const content = fs.readFileSync(targetPath, 'utf-8');
|
|
res.setHeader('Content-Type', 'text/html');
|
|
res.end(content);
|
|
return;
|
|
}
|
|
}
|
|
|
|
next();
|
|
});
|
|
},
|
|
};
|
|
}
|