Skip to content

Commit

Permalink
feat(theme): static files provider
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee committed Aug 13, 2022
1 parent ec9e49d commit 3cc11f3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/modules/theme/theme.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,19 @@ export class ThemeController {
async turnOffTheme(@Query('name') name: string) {
return this.themeService.turnOffTheme(name);
}

// ********************************************************
// 以下是针对静态资源访问的接口
@Get('/public/*')
async public(@Res() res, @Param() param: string) {
const filePath = join(THEME_DIR, (await this.themeService.currentTheme())!.name, "public", param['*']);
const file = await fs.readFile(filePath);
if (!file) {
return res.status(404).send();
} else {
res.type(mime.getType(filePath));
res.send(file);
}
}

}

0 comments on commit 3cc11f3

Please sign in to comment.