修复public故障

This commit is contained in:
Jerry 2025-05-12 16:28:14 +08:00
parent 6a8d4f5b9c
commit 0b08a98229

View File

@ -41,12 +41,13 @@ const apps = {
const filePath = path.join(folderPath, file); const filePath = path.join(folderPath, file);
try { try {
logger.debug(`尝试加载模块: ${filePath}`); //logger.debug(`尝试加载模块: ${filePath}`);
const controllerModule = require(filePath); const controllerModule = require(filePath);
const controller = controllerModule.default; const controller = controllerModule.default;
if (controller?.getRouter) { if (controller?.getRouter) {
const routePath = `/api/${folder}`; const isPublic = folder === 'public';
const routePath = isPublic ? `/${folder}` : `/api/${folder}`;
app.use(routePath, controller.getRouter()); app.use(routePath, controller.getRouter());
logger.debug(`模块路由挂载: ${routePath.padEnd(12)} => ${file}`); logger.debug(`模块路由挂载: ${routePath.padEnd(12)} => ${file}`);