disable时不开启静态资源

This commit is contained in:
Pan Qiancheng 2025-05-08 16:15:07 +08:00
parent 398a35477d
commit 93d8a7c852
2 changed files with 29 additions and 21 deletions

View File

@ -315,7 +315,9 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
ctx.response.body = endpoints;
});
// 注册静态资源
koa.use((0, koa_mount_1.default)('/socket-admin', (0, koa_static_1.default)(socketAdminUI)));
if (!ui?.disable) {
koa.use((0, koa_mount_1.default)('/socket-admin', (0, koa_static_1.default)(socketAdminUI)));
}
koa.use(router.routes());
koa.on('error', (err) => {
console.error(err);
@ -330,16 +332,18 @@ async function startup(path, connector, omitWatchers, omitTimers, routine) {
console.log(chalk_1.default.greenBright.bold('\n🚀 Server started successfully!\n'));
console.log(`🔗 ${chalk_1.default.cyan('Server URL')}: ${chalk_1.default.underline(baseUrl)}`);
// socketio地址
console.log(`🔗 ${chalk_1.default.cyan('Socket URL')}: ${chalk_1.default.underline(concat(url, socketPath))}`);
console.log(`🛠️ ${chalk_1.default.magenta('Socket Admin UI')}: ${chalk_1.default.underline(adminUIUrl)}`);
// 账号密码
// 是否设置密码
if (isPasswordSet) {
console.log(`🔑 ${chalk_1.default.yellow('Socket Admin UI Password has been set, check the config file\n')}`);
}
else {
console.log(chalk_1.default.yellow('Socket Admin UI Password Generated: ') + chalk_1.default.red(passwordForAdminUI));
console.log(chalk_1.default.yellow('Please set the password when running prod env.\n'));
console.log(`🔗 ${chalk_1.default.cyan('Socket URL')}: ${chalk_1.default.underline(concat(url, socketPath))}\n`);
if (!ui?.disable) {
console.log(`🛠️ ${chalk_1.default.magenta('Socket Admin UI')}: ${chalk_1.default.underline(adminUIUrl)}`);
// 账号密码
// 是否设置密码
if (isPasswordSet) {
console.log(`🔑 ${chalk_1.default.yellow('Socket Admin UI Password has been set, check the config file\n')}`);
}
else {
console.log(chalk_1.default.yellow('Socket Admin UI Password Generated: ') + chalk_1.default.red(passwordForAdminUI));
console.log(chalk_1.default.yellow('Please set the password when running prod env.\n'));
}
}
});
if (!omitWatchers) {

View File

@ -394,7 +394,9 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
});
// 注册静态资源
koa.use(mount('/socket-admin', serve(socketAdminUI)));
if (!ui?.disable) {
koa.use(mount('/socket-admin', serve(socketAdminUI)));
}
koa.use(router.routes());
@ -413,15 +415,17 @@ export async function startup<ED extends EntityDict & BaseEntityDict, FrontCxt e
console.log(chalk.greenBright.bold('\n🚀 Server started successfully!\n'));
console.log(`🔗 ${chalk.cyan('Server URL')}: ${chalk.underline(baseUrl)}`);
// socketio地址
console.log(`🔗 ${chalk.cyan('Socket URL')}: ${chalk.underline(concat(url, socketPath))}`);
console.log(`🛠️ ${chalk.magenta('Socket Admin UI')}: ${chalk.underline(adminUIUrl)}`);
// 账号密码
// 是否设置密码
if (isPasswordSet) {
console.log(`🔑 ${chalk.yellow('Socket Admin UI Password has been set, check the config file\n')}`)
} else {
console.log(chalk.yellow('Socket Admin UI Password Generated: ') + chalk.red(passwordForAdminUI));
console.log(chalk.yellow('Please set the password when running prod env.\n'));
console.log(`🔗 ${chalk.cyan('Socket URL')}: ${chalk.underline(concat(url, socketPath))}\n`);
if (!ui?.disable) {
console.log(`🛠️ ${chalk.magenta('Socket Admin UI')}: ${chalk.underline(adminUIUrl)}`);
// 账号密码
// 是否设置密码
if (isPasswordSet) {
console.log(`🔑 ${chalk.yellow('Socket Admin UI Password has been set, check the config file\n')}`)
} else {
console.log(chalk.yellow('Socket Admin UI Password Generated: ') + chalk.red(passwordForAdminUI));
console.log(chalk.yellow('Please set the password when running prod env.\n'));
}
}
});