mirror of
https://github.com/certd/certd.git
synced 2026-04-23 11:37:23 +08:00
perf: favicon支持自定义
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
import { Controller, Get, Provide } from '@midwayjs/core';
|
||||
import { BaseController, Constants } from '@certd/lib-server';
|
||||
import { Controller, Get, Inject, Provide } from '@midwayjs/core';
|
||||
import { BaseController, Constants, FileService, SysSettingsService, SysSiteInfo } from '@certd/lib-server';
|
||||
import { http, logger } from '@certd/basic';
|
||||
import { isComm } from '@certd/plus-core';
|
||||
|
||||
/**
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/app/')
|
||||
export class AppController extends BaseController {
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
@Inject()
|
||||
fileService: FileService;
|
||||
|
||||
@Get('/latest', { summary: Constants.per.authOnly })
|
||||
async latest(): Promise<any> {
|
||||
const res = await http.request({
|
||||
@@ -20,4 +27,21 @@ export class AppController extends BaseController {
|
||||
return this.ok('');
|
||||
}
|
||||
}
|
||||
|
||||
@Get('/favicon', { summary: Constants.per.guest })
|
||||
public async getFavicon() {
|
||||
if (isComm()) {
|
||||
const siteInfo = await this.sysSettingsService.getSetting<SysSiteInfo>(SysSiteInfo);
|
||||
const favicon = siteInfo.logo;
|
||||
if (favicon) {
|
||||
const redirect = '/api/basic/file/download?key=' + favicon;
|
||||
this.ctx.response.redirect(redirect);
|
||||
this.ctx.response.set('Cache-Control', 'public,max-age=25920');
|
||||
return;
|
||||
}
|
||||
}
|
||||
const redirect = '/static/images/logo/logo.svg';
|
||||
this.ctx.response.redirect(redirect);
|
||||
this.ctx.response.set('Cache-Control', 'public,max-age=25920');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user