import { IRequestOptions } from '../intf/IRequestOptions' /** 处理中止的响应结果 */ export const cancelResponse = () => { return function (_target: any, _methodName: any, desc: any) { // 1. 保存当前的方法 const oMethod = desc.value // 2. 改写方法 desc.value = async function (req: IRequestOptions) { try { return await oMethod.apply(this, [req]) } catch (error) { if ((error as Error)?.message?.toLowerCase() === 'request about') { // 通过一个 空 promise, 中断未完成请求响应过程. return new Promise(() => {}) } else { throw error } } } } }