diff --git a/src/modules/render/render.controller.ts b/src/modules/render/render.controller.ts index 998b707a..dea54fb0 100644 --- a/src/modules/render/render.controller.ts +++ b/src/modules/render/render.controller.ts @@ -61,13 +61,12 @@ export class RenderEjsController { this.configs.getMaster(), ]) - if (!isMaster) { - if ( - ('hide' in document && document.hide) || - ('password' in document && !isNil(document.password)) - ) { - throw new ForbiddenException('该文章已隐藏或加密') - } + const isPrivateOrEncrypt = + ('hide' in document && document.hide) || + ('password' in document && !isNil(document.password)) + + if (!isMaster && isPrivateOrEncrypt) { + throw new ForbiddenException('该文章已隐藏或加密') } const relativePath = (() => { @@ -93,17 +92,20 @@ export class RenderEjsController { const html = render(await this.service.getMarkdownEjsRenderTemplate(), { ...structure, + info: isPrivateOrEncrypt ? '正在查看的文章还未公开' : undefined, title: document.title, - footer: `

本文渲染于 ${getShortDateTime( + footer: `

本文渲染于 ${getShortDateTime( new Date(), )},由 marked.js 解析生成,用时 ${(performance.now() - now).toFixed( 2, - )}ms

-

作者:${username},撰写于${dayjs(document.created).format('llll')}

-

原文地址:${decodeURIComponent( + )}ms

+
作者:${username},撰写于${dayjs(document.created).format( + 'llll', + )}
+
原文地址:${decodeURIComponent( url.toString(), - )}

+ )}
`, })