Skip to content

Commit

Permalink
fix: error
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Jul 31, 2024
1 parent 864a927 commit 8b4f6e7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/render/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { RenderBase } from './base'
import { randomUUID } from 'crypto'
import { listener } from 'karin/core'
import { common, logger } from 'karin/utils'
import { KarinRenderType } from 'karin/types/render'
import { KarinRenderType, RenderResult } from 'karin/types/render'

export class RenderClient extends RenderBase {
url: string
Expand Down Expand Up @@ -128,7 +128,7 @@ export class RenderClient extends RenderBase {
* 渲染标准方法
* @param options 渲染参数
*/
async<T extends KarinRenderType> (options: T) {
async render<T extends KarinRenderType> (options: T): Promise<RenderResult<T>> {
/** 渲染模板 */
let file = options.file
let action = 'renderHtml'
Expand All @@ -147,7 +147,7 @@ export class RenderClient extends RenderBase {

if (!file) {
logger.error(`[渲染器:${this.id}:${this.index}] 渲染文件不存在:${options.file}`)
return ''
return '' as RenderResult<T>
}

/** 编码 */
Expand All @@ -165,7 +165,7 @@ export class RenderClient extends RenderBase {

return new Promise((resolve, reject) => {
listener.once(echo, (data: { ok: boolean; data: string | string[] }) => {
if (data.ok) return resolve(data.data)
if (data.ok) return resolve((data.data as RenderResult<T>))
reject(new Error(JSON.stringify(data)))
})
})
Expand Down

0 comments on commit 8b4f6e7

Please sign in to comment.