feat(lark-msg): genCard支持直接传入卡片定义
All checks were successful
/ release (push) Successful in 23s

This commit is contained in:
zhaoyingbo 2024-10-15 03:04:26 +00:00
parent 219ddc7c7b
commit 3a783260b1

View File

@ -1,5 +1,5 @@
import logger from "@egg/logger"
import _ from "lodash"
import _, { isObject } from "lodash"
import { Logger } from "winston"
import { baseErrorCard, basePendingCard, baseSuccessCard } from "./component"
@ -67,8 +67,8 @@ class LarkCard<
)
}
genCard(cardKey: keyof TCardMap, variables: { [key: string]: any }) {
const card = this.cardMap[cardKey]
genCard(cardKey: keyof TCardMap | object, variables: { [key: string]: any }) {
const card = isObject(cardKey) ? cardKey : this.cardMap[cardKey]
if (!card) {
this.logger.error(`Card ${String(cardKey)} not found`)
throw new Error(`Card ${String(cardKey)} not found`)