/** 缓存函数,函数返回值不可以为 null */ export const cacheResult = any>(func: T) => { let res = null as unknown as ReturnType; return function (this: ThisType, ...args: Parameters) { if (res === null) { res = func.apply(this, args); } return res; } as T; };