perf: 优化部份判断

This commit is contained in:
ChenZhaoYu
2023-03-17 08:57:27 +08:00
parent b3cfe7a976
commit 2ad7567548
5 changed files with 63 additions and 45 deletions

View File

@@ -1,10 +1,10 @@
interface SendResponseOptions {
interface SendResponseOptions<T = any> {
type: 'Success' | 'Fail'
message?: string
data?: any
data?: T
}
export function sendResponse(options: SendResponseOptions) {
export function sendResponse<T>(options: SendResponseOptions<T>) {
if (options.type === 'Success') {
return Promise.resolve({
message: options.message ?? null,