perf: 是否允许爬虫爬取增加ui设置选项

This commit is contained in:
xiaojunnuo
2025-02-27 00:10:07 +08:00
parent 5d29a08ab7
commit 779db9da70
4 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { Controller, Get, Inject, Provide } from '@midwayjs/core';
import { Constants, SysSettingsService } from '@certd/lib-server';
@Provide()
@Controller('/')
export class HomeController {
@Inject()
sysSettingsService: SysSettingsService;
@Get('/robots.txt', { summary: Constants.per.guest })
async robots(): Promise<string> {
const publicSettings = await this.sysSettingsService.getPublicSettings();
if (!publicSettings.robots) {
return 'User-agent: *\nDisallow: /';
} else {
return 'User-agent: *\nAllow: /';
}
}
}